core-js 3.46.0 → 3.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actual/iterator/concat.js +2 -18
- package/actual/iterator/index.js +3 -0
- package/actual/iterator/zip-keyed.js +24 -0
- package/actual/iterator/zip.js +22 -0
- package/actual/json/index.js +0 -3
- package/actual/json/is-raw-json.js +2 -2
- package/actual/json/parse.js +2 -3
- package/actual/json/raw-json.js +3 -4
- package/es/index.js +4 -0
- package/es/iterator/concat.js +21 -0
- package/es/iterator/index.js +1 -0
- package/es/json/index.js +6 -0
- package/es/json/is-raw-json.js +5 -0
- package/es/json/parse.js +6 -0
- package/es/json/raw-json.js +7 -0
- package/full/index.js +4 -0
- package/full/iterator/index.js +1 -3
- package/full/iterator/zip-keyed.js +2 -22
- package/full/iterator/zip.js +2 -20
- package/internals/check-correctness-of-iteration.js +2 -0
- package/internals/fix-regexp-well-known-symbol-logic.js +6 -4
- package/internals/internal-metadata.js +1 -0
- package/internals/set-method-accept-set-like.js +1 -3
- package/internals/shared-store.js +2 -2
- package/internals/to-string-tag-support.js +1 -1
- package/modules/es.error.cause.js +2 -0
- package/modules/es.iterator.concat.js +56 -0
- package/modules/es.json.is-raw-json.js +11 -0
- package/modules/es.json.parse.js +251 -0
- package/modules/es.json.raw-json.js +39 -0
- package/modules/es.json.stringify.js +78 -19
- package/modules/esnext.iterator.concat.js +2 -55
- package/modules/esnext.iterator.zip-keyed.js +1 -1
- package/modules/esnext.iterator.zip.js +1 -1
- package/modules/esnext.json.is-raw-json.js +2 -10
- package/modules/esnext.json.parse.js +2 -250
- package/modules/esnext.json.raw-json.js +2 -85
- package/modules/web.url-search-params.constructor.js +1 -1
- package/package.json +2 -1
- package/stable/index.js +4 -0
- package/stable/iterator/concat.js +5 -0
- package/stable/json/is-raw-json.js +4 -0
- package/stable/json/parse.js +4 -0
- package/stable/json/raw-json.js +4 -0
- package/stage/2.7.js +0 -1
- package/stage/3.js +1 -2
- package/stage/4.js +2 -0
- package/internals/get-json-replacer-function.js +0 -30
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var DESCRIPTORS = require('../internals/descriptors');
|
|
4
|
+
var globalThis = require('../internals/global-this');
|
|
5
|
+
var getBuiltIn = require('../internals/get-built-in');
|
|
6
|
+
var uncurryThis = require('../internals/function-uncurry-this');
|
|
7
|
+
var call = require('../internals/function-call');
|
|
8
|
+
var isCallable = require('../internals/is-callable');
|
|
9
|
+
var isObject = require('../internals/is-object');
|
|
10
|
+
var isArray = require('../internals/is-array');
|
|
11
|
+
var hasOwn = require('../internals/has-own-property');
|
|
12
|
+
var toString = require('../internals/to-string');
|
|
13
|
+
var lengthOfArrayLike = require('../internals/length-of-array-like');
|
|
14
|
+
var createProperty = require('../internals/create-property');
|
|
15
|
+
var fails = require('../internals/fails');
|
|
16
|
+
var parseJSONString = require('../internals/parse-json-string');
|
|
17
|
+
var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection');
|
|
18
|
+
|
|
19
|
+
var JSON = globalThis.JSON;
|
|
20
|
+
var Number = globalThis.Number;
|
|
21
|
+
var SyntaxError = globalThis.SyntaxError;
|
|
22
|
+
var nativeParse = JSON && JSON.parse;
|
|
23
|
+
var enumerableOwnProperties = getBuiltIn('Object', 'keys');
|
|
24
|
+
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
25
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
26
|
+
var at = uncurryThis(''.charAt);
|
|
27
|
+
var slice = uncurryThis(''.slice);
|
|
28
|
+
var exec = uncurryThis(/./.exec);
|
|
29
|
+
var push = uncurryThis([].push);
|
|
30
|
+
|
|
31
|
+
var IS_DIGIT = /^\d$/;
|
|
32
|
+
var IS_NON_ZERO_DIGIT = /^[1-9]$/;
|
|
33
|
+
var IS_NUMBER_START = /^[\d-]$/;
|
|
34
|
+
var IS_WHITESPACE = /^[\t\n\r ]$/;
|
|
35
|
+
|
|
36
|
+
var PRIMITIVE = 0;
|
|
37
|
+
var OBJECT = 1;
|
|
38
|
+
|
|
39
|
+
var $parse = function (source, reviver) {
|
|
40
|
+
source = toString(source);
|
|
41
|
+
var context = new Context(source, 0, '');
|
|
42
|
+
var root = context.parse();
|
|
43
|
+
var value = root.value;
|
|
44
|
+
var endIndex = context.skip(IS_WHITESPACE, root.end);
|
|
45
|
+
if (endIndex < source.length) {
|
|
46
|
+
throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
|
|
47
|
+
}
|
|
48
|
+
return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var internalize = function (holder, name, reviver, node) {
|
|
52
|
+
var val = holder[name];
|
|
53
|
+
var unmodified = node && val === node.value;
|
|
54
|
+
var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
|
|
55
|
+
var elementRecordsLen, keys, len, i, P;
|
|
56
|
+
if (isObject(val)) {
|
|
57
|
+
var nodeIsArray = isArray(val);
|
|
58
|
+
var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
|
|
59
|
+
if (nodeIsArray) {
|
|
60
|
+
elementRecordsLen = nodes.length;
|
|
61
|
+
len = lengthOfArrayLike(val);
|
|
62
|
+
for (i = 0; i < len; i++) {
|
|
63
|
+
internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
keys = enumerableOwnProperties(val);
|
|
67
|
+
len = lengthOfArrayLike(keys);
|
|
68
|
+
for (i = 0; i < len; i++) {
|
|
69
|
+
P = keys[i];
|
|
70
|
+
internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return call(reviver, holder, name, val, context);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var internalizeProperty = function (object, key, value) {
|
|
78
|
+
if (DESCRIPTORS) {
|
|
79
|
+
var descriptor = getOwnPropertyDescriptor(object, key);
|
|
80
|
+
if (descriptor && !descriptor.configurable) return;
|
|
81
|
+
}
|
|
82
|
+
if (value === undefined) delete object[key];
|
|
83
|
+
else createProperty(object, key, value);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var Node = function (value, end, source, nodes) {
|
|
87
|
+
this.value = value;
|
|
88
|
+
this.end = end;
|
|
89
|
+
this.source = source;
|
|
90
|
+
this.nodes = nodes;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var Context = function (source, index) {
|
|
94
|
+
this.source = source;
|
|
95
|
+
this.index = index;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// https://www.json.org/json-en.html
|
|
99
|
+
Context.prototype = {
|
|
100
|
+
fork: function (nextIndex) {
|
|
101
|
+
return new Context(this.source, nextIndex);
|
|
102
|
+
},
|
|
103
|
+
parse: function () {
|
|
104
|
+
var source = this.source;
|
|
105
|
+
var i = this.skip(IS_WHITESPACE, this.index);
|
|
106
|
+
var fork = this.fork(i);
|
|
107
|
+
var chr = at(source, i);
|
|
108
|
+
if (exec(IS_NUMBER_START, chr)) return fork.number();
|
|
109
|
+
switch (chr) {
|
|
110
|
+
case '{':
|
|
111
|
+
return fork.object();
|
|
112
|
+
case '[':
|
|
113
|
+
return fork.array();
|
|
114
|
+
case '"':
|
|
115
|
+
return fork.string();
|
|
116
|
+
case 't':
|
|
117
|
+
return fork.keyword(true);
|
|
118
|
+
case 'f':
|
|
119
|
+
return fork.keyword(false);
|
|
120
|
+
case 'n':
|
|
121
|
+
return fork.keyword(null);
|
|
122
|
+
} throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
|
|
123
|
+
},
|
|
124
|
+
node: function (type, value, start, end, nodes) {
|
|
125
|
+
return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
|
|
126
|
+
},
|
|
127
|
+
object: function () {
|
|
128
|
+
var source = this.source;
|
|
129
|
+
var i = this.index + 1;
|
|
130
|
+
var expectKeypair = false;
|
|
131
|
+
var object = {};
|
|
132
|
+
var nodes = {};
|
|
133
|
+
while (i < source.length) {
|
|
134
|
+
i = this.until(['"', '}'], i);
|
|
135
|
+
if (at(source, i) === '}' && !expectKeypair) {
|
|
136
|
+
i++;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
// Parsing the key
|
|
140
|
+
var result = this.fork(i).string();
|
|
141
|
+
var key = result.value;
|
|
142
|
+
i = result.end;
|
|
143
|
+
i = this.until([':'], i) + 1;
|
|
144
|
+
// Parsing value
|
|
145
|
+
i = this.skip(IS_WHITESPACE, i);
|
|
146
|
+
result = this.fork(i).parse();
|
|
147
|
+
createProperty(nodes, key, result);
|
|
148
|
+
createProperty(object, key, result.value);
|
|
149
|
+
i = this.until([',', '}'], result.end);
|
|
150
|
+
var chr = at(source, i);
|
|
151
|
+
if (chr === ',') {
|
|
152
|
+
expectKeypair = true;
|
|
153
|
+
i++;
|
|
154
|
+
} else if (chr === '}') {
|
|
155
|
+
i++;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return this.node(OBJECT, object, this.index, i, nodes);
|
|
160
|
+
},
|
|
161
|
+
array: function () {
|
|
162
|
+
var source = this.source;
|
|
163
|
+
var i = this.index + 1;
|
|
164
|
+
var expectElement = false;
|
|
165
|
+
var array = [];
|
|
166
|
+
var nodes = [];
|
|
167
|
+
while (i < source.length) {
|
|
168
|
+
i = this.skip(IS_WHITESPACE, i);
|
|
169
|
+
if (at(source, i) === ']' && !expectElement) {
|
|
170
|
+
i++;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
var result = this.fork(i).parse();
|
|
174
|
+
push(nodes, result);
|
|
175
|
+
push(array, result.value);
|
|
176
|
+
i = this.until([',', ']'], result.end);
|
|
177
|
+
if (at(source, i) === ',') {
|
|
178
|
+
expectElement = true;
|
|
179
|
+
i++;
|
|
180
|
+
} else if (at(source, i) === ']') {
|
|
181
|
+
i++;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return this.node(OBJECT, array, this.index, i, nodes);
|
|
186
|
+
},
|
|
187
|
+
string: function () {
|
|
188
|
+
var index = this.index;
|
|
189
|
+
var parsed = parseJSONString(this.source, this.index + 1);
|
|
190
|
+
return this.node(PRIMITIVE, parsed.value, index, parsed.end);
|
|
191
|
+
},
|
|
192
|
+
number: function () {
|
|
193
|
+
var source = this.source;
|
|
194
|
+
var startIndex = this.index;
|
|
195
|
+
var i = startIndex;
|
|
196
|
+
if (at(source, i) === '-') i++;
|
|
197
|
+
if (at(source, i) === '0') i++;
|
|
198
|
+
else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, i + 1);
|
|
199
|
+
else throw new SyntaxError('Failed to parse number at: ' + i);
|
|
200
|
+
if (at(source, i) === '.') i = this.skip(IS_DIGIT, i + 1);
|
|
201
|
+
if (at(source, i) === 'e' || at(source, i) === 'E') {
|
|
202
|
+
i++;
|
|
203
|
+
if (at(source, i) === '+' || at(source, i) === '-') i++;
|
|
204
|
+
var exponentStartIndex = i;
|
|
205
|
+
i = this.skip(IS_DIGIT, i);
|
|
206
|
+
if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i);
|
|
207
|
+
}
|
|
208
|
+
return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
|
|
209
|
+
},
|
|
210
|
+
keyword: function (value) {
|
|
211
|
+
var keyword = '' + value;
|
|
212
|
+
var index = this.index;
|
|
213
|
+
var endIndex = index + keyword.length;
|
|
214
|
+
if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index);
|
|
215
|
+
return this.node(PRIMITIVE, value, index, endIndex);
|
|
216
|
+
},
|
|
217
|
+
skip: function (regex, i) {
|
|
218
|
+
var source = this.source;
|
|
219
|
+
for (; i < source.length; i++) if (!exec(regex, at(source, i))) break;
|
|
220
|
+
return i;
|
|
221
|
+
},
|
|
222
|
+
until: function (array, i) {
|
|
223
|
+
i = this.skip(IS_WHITESPACE, i);
|
|
224
|
+
var chr = at(this.source, i);
|
|
225
|
+
for (var j = 0; j < array.length; j++) if (array[j] === chr) return i;
|
|
226
|
+
throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var NO_SOURCE_SUPPORT = fails(function () {
|
|
231
|
+
var unsafeInt = '9007199254740993';
|
|
232
|
+
var source;
|
|
233
|
+
nativeParse(unsafeInt, function (key, value, context) {
|
|
234
|
+
source = context.source;
|
|
235
|
+
});
|
|
236
|
+
return source !== unsafeInt;
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
|
|
240
|
+
// Safari 9 bug
|
|
241
|
+
return 1 / nativeParse('-0 \t') !== -Infinity;
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// `JSON.parse` method
|
|
245
|
+
// https://tc39.es/ecma262/#sec-json.parse
|
|
246
|
+
// https://github.com/tc39/proposal-json-parse-with-source
|
|
247
|
+
$({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, {
|
|
248
|
+
parse: function parse(text, reviver) {
|
|
249
|
+
return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var FREEZING = require('../internals/freezing');
|
|
4
|
+
var NATIVE_RAW_JSON = require('../internals/native-raw-json');
|
|
5
|
+
var getBuiltIn = require('../internals/get-built-in');
|
|
6
|
+
var uncurryThis = require('../internals/function-uncurry-this');
|
|
7
|
+
var toString = require('../internals/to-string');
|
|
8
|
+
var createProperty = require('../internals/create-property');
|
|
9
|
+
var setInternalState = require('../internals/internal-state').set;
|
|
10
|
+
|
|
11
|
+
var $SyntaxError = SyntaxError;
|
|
12
|
+
var parse = getBuiltIn('JSON', 'parse');
|
|
13
|
+
var create = getBuiltIn('Object', 'create');
|
|
14
|
+
var freeze = getBuiltIn('Object', 'freeze');
|
|
15
|
+
var at = uncurryThis(''.charAt);
|
|
16
|
+
|
|
17
|
+
var ERROR_MESSAGE = 'Unacceptable as raw JSON';
|
|
18
|
+
|
|
19
|
+
var isWhitespace = function (it) {
|
|
20
|
+
return it === ' ' || it === '\t' || it === '\n' || it === '\r';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// `JSON.rawJSON` method
|
|
24
|
+
// https://tc39.es/proposal-json-parse-with-source/#sec-json.rawjson
|
|
25
|
+
// https://github.com/tc39/proposal-json-parse-with-source
|
|
26
|
+
$({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, {
|
|
27
|
+
rawJSON: function rawJSON(text) {
|
|
28
|
+
var jsonString = toString(text);
|
|
29
|
+
if (jsonString === '' || isWhitespace(at(jsonString, 0)) || isWhitespace(at(jsonString, jsonString.length - 1))) {
|
|
30
|
+
throw new $SyntaxError(ERROR_MESSAGE);
|
|
31
|
+
}
|
|
32
|
+
var parsed = parse(jsonString);
|
|
33
|
+
if (typeof parsed == 'object' && parsed !== null) throw new $SyntaxError(ERROR_MESSAGE);
|
|
34
|
+
var obj = create(null);
|
|
35
|
+
setInternalState(obj, { type: 'RawJSON' });
|
|
36
|
+
createProperty(obj, 'rawJSON', jsonString);
|
|
37
|
+
return FREEZING ? freeze(obj) : obj;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -5,11 +5,17 @@ var apply = require('../internals/function-apply');
|
|
|
5
5
|
var call = require('../internals/function-call');
|
|
6
6
|
var uncurryThis = require('../internals/function-uncurry-this');
|
|
7
7
|
var fails = require('../internals/fails');
|
|
8
|
+
var isArray = require('../internals/is-array');
|
|
8
9
|
var isCallable = require('../internals/is-callable');
|
|
10
|
+
var isRawJSON = require('../internals/is-raw-json');
|
|
9
11
|
var isSymbol = require('../internals/is-symbol');
|
|
12
|
+
var classof = require('../internals/classof-raw');
|
|
13
|
+
var toString = require('../internals/to-string');
|
|
10
14
|
var arraySlice = require('../internals/array-slice');
|
|
11
|
-
var
|
|
15
|
+
var parseJSONString = require('../internals/parse-json-string');
|
|
16
|
+
var uid = require('../internals/uid');
|
|
12
17
|
var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection');
|
|
18
|
+
var NATIVE_RAW_JSON = require('../internals/native-raw-json');
|
|
13
19
|
|
|
14
20
|
var $String = String;
|
|
15
21
|
var $stringify = getBuiltIn('JSON', 'stringify');
|
|
@@ -17,11 +23,16 @@ var exec = uncurryThis(/./.exec);
|
|
|
17
23
|
var charAt = uncurryThis(''.charAt);
|
|
18
24
|
var charCodeAt = uncurryThis(''.charCodeAt);
|
|
19
25
|
var replace = uncurryThis(''.replace);
|
|
26
|
+
var slice = uncurryThis(''.slice);
|
|
27
|
+
var push = uncurryThis([].push);
|
|
20
28
|
var numberToString = uncurryThis(1.1.toString);
|
|
21
29
|
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
30
|
+
var surrogates = /[\uD800-\uDFFF]/g;
|
|
31
|
+
var lowSurrogates = /^[\uD800-\uDBFF]$/;
|
|
32
|
+
var hiSurrogates = /^[\uDC00-\uDFFF]$/;
|
|
33
|
+
|
|
34
|
+
var MARK = uid();
|
|
35
|
+
var MARK_LENGTH = MARK.length;
|
|
25
36
|
|
|
26
37
|
var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
|
|
27
38
|
var symbol = getBuiltIn('Symbol')('stringify detection');
|
|
@@ -39,7 +50,7 @@ var ILL_FORMED_UNICODE = fails(function () {
|
|
|
39
50
|
|| $stringify('\uDEAD') !== '"\\udead"';
|
|
40
51
|
});
|
|
41
52
|
|
|
42
|
-
var
|
|
53
|
+
var stringifyWithProperSymbolsConversion = WRONG_SYMBOLS_CONVERSION ? function (it, replacer) {
|
|
43
54
|
var args = arraySlice(arguments);
|
|
44
55
|
var $replacer = getReplacerFunction(replacer);
|
|
45
56
|
if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined
|
|
@@ -49,25 +60,73 @@ var stringifyWithSymbolsFix = function (it, replacer) {
|
|
|
49
60
|
if (!isSymbol(value)) return value;
|
|
50
61
|
};
|
|
51
62
|
return apply($stringify, null, args);
|
|
52
|
-
};
|
|
63
|
+
} : $stringify;
|
|
53
64
|
|
|
54
|
-
var
|
|
65
|
+
var fixIllFormedJSON = function (match, offset, string) {
|
|
55
66
|
var prev = charAt(string, offset - 1);
|
|
56
67
|
var next = charAt(string, offset + 1);
|
|
57
|
-
if ((exec(
|
|
68
|
+
if ((exec(lowSurrogates, match) && !exec(hiSurrogates, next)) || (exec(hiSurrogates, match) && !exec(lowSurrogates, prev))) {
|
|
58
69
|
return '\\u' + numberToString(charCodeAt(match, 0), 16);
|
|
59
70
|
} return match;
|
|
60
71
|
};
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
var getReplacerFunction = function (replacer) {
|
|
74
|
+
if (isCallable(replacer)) return replacer;
|
|
75
|
+
if (!isArray(replacer)) return;
|
|
76
|
+
var rawLength = replacer.length;
|
|
77
|
+
var keys = [];
|
|
78
|
+
for (var i = 0; i < rawLength; i++) {
|
|
79
|
+
var element = replacer[i];
|
|
80
|
+
if (typeof element == 'string') push(keys, element);
|
|
81
|
+
else if (typeof element == 'number' || classof(element) === 'Number' || classof(element) === 'String') push(keys, toString(element));
|
|
82
|
+
}
|
|
83
|
+
var keysLength = keys.length;
|
|
84
|
+
var root = true;
|
|
85
|
+
return function (key, value) {
|
|
86
|
+
if (root) {
|
|
87
|
+
root = false;
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
if (isArray(this)) return value;
|
|
91
|
+
for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// `JSON.stringify` method
|
|
96
|
+
// https://tc39.es/ecma262/#sec-json.stringify
|
|
97
|
+
// https://github.com/tc39/proposal-json-parse-with-source
|
|
98
|
+
if ($stringify) $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE || !NATIVE_RAW_JSON }, {
|
|
99
|
+
stringify: function stringify(text, replacer, space) {
|
|
100
|
+
var replacerFunction = getReplacerFunction(replacer);
|
|
101
|
+
var rawStrings = [];
|
|
102
|
+
|
|
103
|
+
var json = stringifyWithProperSymbolsConversion(text, function (key, value) {
|
|
104
|
+
// some old implementations (like WebKit) could pass numbers as keys
|
|
105
|
+
var v = isCallable(replacerFunction) ? call(replacerFunction, this, $String(key), value) : value;
|
|
106
|
+
return !NATIVE_RAW_JSON && isRawJSON(v) ? MARK + (push(rawStrings, v.rawJSON) - 1) : v;
|
|
107
|
+
}, space);
|
|
108
|
+
|
|
109
|
+
if (typeof json != 'string') return json;
|
|
110
|
+
|
|
111
|
+
if (ILL_FORMED_UNICODE) json = replace(json, surrogates, fixIllFormedJSON);
|
|
112
|
+
|
|
113
|
+
if (NATIVE_RAW_JSON) return json;
|
|
114
|
+
|
|
115
|
+
var result = '';
|
|
116
|
+
var length = json.length;
|
|
117
|
+
|
|
118
|
+
for (var i = 0; i < length; i++) {
|
|
119
|
+
var chr = charAt(json, i);
|
|
120
|
+
if (chr === '"') {
|
|
121
|
+
var end = parseJSONString(json, ++i).end - 1;
|
|
122
|
+
var string = slice(json, i, end);
|
|
123
|
+
result += slice(string, 0, MARK_LENGTH) === MARK
|
|
124
|
+
? rawStrings[slice(string, MARK_LENGTH)]
|
|
125
|
+
: '"' + string + '"';
|
|
126
|
+
i = end;
|
|
127
|
+
} else result += chr;
|
|
71
128
|
}
|
|
72
|
-
|
|
73
|
-
|
|
129
|
+
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
@@ -1,56 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var aCallable = require('../internals/a-callable');
|
|
5
|
-
var anObject = require('../internals/an-object');
|
|
6
|
-
var getIteratorMethod = require('../internals/get-iterator-method');
|
|
7
|
-
var createIteratorProxy = require('../internals/iterator-create-proxy');
|
|
8
|
-
|
|
9
|
-
var $Array = Array;
|
|
10
|
-
|
|
11
|
-
var IteratorProxy = createIteratorProxy(function () {
|
|
12
|
-
while (true) {
|
|
13
|
-
var iterator = this.iterator;
|
|
14
|
-
if (!iterator) {
|
|
15
|
-
var iterableIndex = this.nextIterableIndex++;
|
|
16
|
-
var iterables = this.iterables;
|
|
17
|
-
if (iterableIndex >= iterables.length) {
|
|
18
|
-
this.done = true;
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
var entry = iterables[iterableIndex];
|
|
22
|
-
this.iterables[iterableIndex] = null;
|
|
23
|
-
iterator = this.iterator = call(entry.method, entry.iterable);
|
|
24
|
-
this.next = iterator.next;
|
|
25
|
-
}
|
|
26
|
-
var result = anObject(call(this.next, iterator));
|
|
27
|
-
if (result.done) {
|
|
28
|
-
this.iterator = null;
|
|
29
|
-
this.next = null;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
return result.value;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// `Iterator.concat` method
|
|
37
|
-
// https://github.com/tc39/proposal-iterator-sequencing
|
|
38
|
-
$({ target: 'Iterator', stat: true }, {
|
|
39
|
-
concat: function concat() {
|
|
40
|
-
var length = arguments.length;
|
|
41
|
-
var iterables = $Array(length);
|
|
42
|
-
for (var index = 0; index < length; index++) {
|
|
43
|
-
var item = anObject(arguments[index]);
|
|
44
|
-
iterables[index] = {
|
|
45
|
-
iterable: item,
|
|
46
|
-
method: aCallable(getIteratorMethod(item))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return new IteratorProxy({
|
|
50
|
-
iterables: iterables,
|
|
51
|
-
nextIterableIndex: 0,
|
|
52
|
-
iterator: null,
|
|
53
|
-
next: null
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
2
|
+
// TODO: Remove from `core-js@4`
|
|
3
|
+
require('../modules/es.iterator.concat');
|
|
@@ -19,7 +19,7 @@ var THROW = 'throw';
|
|
|
19
19
|
|
|
20
20
|
// `Iterator.zipKeyed` method
|
|
21
21
|
// https://github.com/tc39/proposal-joint-iteration
|
|
22
|
-
$({ target: 'Iterator', stat: true
|
|
22
|
+
$({ target: 'Iterator', stat: true }, {
|
|
23
23
|
zipKeyed: function zipKeyed(iterables /* , options */) {
|
|
24
24
|
anObject(iterables);
|
|
25
25
|
var options = arguments.length > 1 ? anObjectOrUndefined(arguments[1]) : undefined;
|
|
@@ -17,7 +17,7 @@ var THROW = 'throw';
|
|
|
17
17
|
|
|
18
18
|
// `Iterator.zip` method
|
|
19
19
|
// https://github.com/tc39/proposal-joint-iteration
|
|
20
|
-
$({ target: 'Iterator', stat: true
|
|
20
|
+
$({ target: 'Iterator', stat: true }, {
|
|
21
21
|
zip: function zip(iterables /* , options */) {
|
|
22
22
|
anObject(iterables);
|
|
23
23
|
var options = arguments.length > 1 ? anObjectOrUndefined(arguments[1]) : undefined;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var isRawJSON = require('../internals/is-raw-json');
|
|
5
|
-
|
|
6
|
-
// `JSON.isRawJSON` method
|
|
7
|
-
// https://tc39.es/proposal-json-parse-with-source/#sec-json.israwjson
|
|
8
|
-
// https://github.com/tc39/proposal-json-parse-with-source
|
|
9
|
-
$({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, {
|
|
10
|
-
isRawJSON: isRawJSON
|
|
11
|
-
});
|
|
2
|
+
// TODO: Remove from `core-js@4`
|
|
3
|
+
require('../modules/es.json.is-raw-json');
|