Lobashov_Ivan_PIBD-21_IP/Lab2/node_modules/.es-shim-unscopables-S6yUY0TM/index.js

22 lines
555 B
JavaScript
Raw Permalink Normal View History

2024-01-10 22:39:31 +04:00
'use strict';
var hasOwn = require('hasown');
var hasUnscopables = typeof Symbol === 'function' && typeof Symbol.unscopables === 'symbol';
var map = hasUnscopables && Array.prototype[Symbol.unscopables];
var $TypeError = TypeError;
module.exports = function shimUnscopables(method) {
if (typeof method !== 'string' || !method) {
throw new $TypeError('method must be a non-empty string');
}
if (!hasOwn(Array.prototype, method)) {
throw new $TypeError('method must be on Array.prototype');
}
if (hasUnscopables) {
map[method] = true;
}
};