You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
546 B
21 lines
546 B
'use strict'; |
|
|
|
var has = require('has'); |
|
|
|
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 (!has(Array.prototype, method)) { |
|
throw new $TypeError('method must be on Array.prototype'); |
|
} |
|
if (hasUnscopables) { |
|
map[method] = true; |
|
} |
|
};
|
|
|