Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
962 bytes
|
Line | |
---|
1 | var $ = require('../internals/export');
|
---|
2 | var isArray = require('../internals/is-array');
|
---|
3 |
|
---|
4 | // eslint-disable-next-line es/no-object-isfrozen -- safe
|
---|
5 | var isFrozen = Object.isFrozen;
|
---|
6 |
|
---|
7 | var isFrozenStringArray = function (array, allowUndefined) {
|
---|
8 | if (!isFrozen || !isArray(array) || !isFrozen(array)) return false;
|
---|
9 | var index = 0;
|
---|
10 | var length = array.length;
|
---|
11 | var element;
|
---|
12 | while (index < length) {
|
---|
13 | element = array[index++];
|
---|
14 | if (!(typeof element === 'string' || (allowUndefined && typeof element === 'undefined'))) {
|
---|
15 | return false;
|
---|
16 | }
|
---|
17 | } return length !== 0;
|
---|
18 | };
|
---|
19 |
|
---|
20 | // `Array.isTemplateObject` method
|
---|
21 | // https://github.com/tc39/proposal-array-is-template-object
|
---|
22 | $({ target: 'Array', stat: true }, {
|
---|
23 | isTemplateObject: function isTemplateObject(value) {
|
---|
24 | if (!isFrozenStringArray(value, true)) return false;
|
---|
25 | var raw = value.raw;
|
---|
26 | if (raw.length !== value.length || !isFrozenStringArray(raw, false)) return false;
|
---|
27 | return true;
|
---|
28 | }
|
---|
29 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.