PIbd-21_Danilov_V.V._Intern.../Lab4/node_modules/es-shim-unscopables/index.js
Владимир Данилов ab1cc7aeac Отчет лаб 4
2024-01-09 05:30:48 +04:00

22 lines
555 B
JavaScript

'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;
}
};