main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
555 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var hasOwn = require('hasown');
|
---|
4 |
|
---|
5 | var hasUnscopables = typeof Symbol === 'function' && typeof Symbol.unscopables === 'symbol';
|
---|
6 |
|
---|
7 | var map = hasUnscopables && Array.prototype[Symbol.unscopables];
|
---|
8 |
|
---|
9 | var $TypeError = TypeError;
|
---|
10 |
|
---|
11 | module.exports = function shimUnscopables(method) {
|
---|
12 | if (typeof method !== 'string' || !method) {
|
---|
13 | throw new $TypeError('method must be a non-empty string');
|
---|
14 | }
|
---|
15 | if (!hasOwn(Array.prototype, method)) {
|
---|
16 | throw new $TypeError('method must be on Array.prototype');
|
---|
17 | }
|
---|
18 | if (hasUnscopables) {
|
---|
19 | map[method] = true;
|
---|
20 | }
|
---|
21 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.