core-js 3.33.0 → 3.33.3
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/array/virtual/group-by-to-map.js +2 -2
- package/actual/array/virtual/group-by.js +2 -2
- package/actual/array/virtual/group-to-map.js +2 -2
- package/actual/array/virtual/group.js +2 -2
- package/es/README.md +1 -1
- package/es/array/virtual/at.js +2 -2
- package/es/array/virtual/concat.js +2 -2
- package/es/array/virtual/copy-within.js +2 -2
- package/es/array/virtual/entries.js +2 -2
- package/es/array/virtual/every.js +2 -2
- package/es/array/virtual/fill.js +2 -2
- package/es/array/virtual/filter.js +2 -2
- package/es/array/virtual/find-index.js +2 -2
- package/es/array/virtual/find-last-index.js +2 -2
- package/es/array/virtual/find-last.js +2 -2
- package/es/array/virtual/find.js +2 -2
- package/es/array/virtual/flat-map.js +2 -2
- package/es/array/virtual/flat.js +2 -2
- package/es/array/virtual/for-each.js +2 -2
- package/es/array/virtual/includes.js +2 -2
- package/es/array/virtual/index-of.js +2 -2
- package/es/array/virtual/iterator.js +2 -2
- package/es/array/virtual/join.js +2 -2
- package/es/array/virtual/keys.js +2 -2
- package/es/array/virtual/last-index-of.js +2 -2
- package/es/array/virtual/map.js +2 -2
- package/es/array/virtual/push.js +2 -2
- package/es/array/virtual/reduce-right.js +2 -2
- package/es/array/virtual/reduce.js +2 -2
- package/es/array/virtual/reverse.js +2 -2
- package/es/array/virtual/slice.js +2 -2
- package/es/array/virtual/some.js +2 -2
- package/es/array/virtual/sort.js +2 -2
- package/es/array/virtual/splice.js +2 -2
- package/es/array/virtual/to-reversed.js +2 -2
- package/es/array/virtual/to-sorted.js +2 -2
- package/es/array/virtual/to-spliced.js +2 -2
- package/es/array/virtual/unshift.js +2 -2
- package/es/array/virtual/values.js +2 -2
- package/es/array/virtual/with.js +2 -2
- package/es/function/virtual/bind.js +2 -2
- package/es/number/virtual/to-exponential.js +2 -2
- package/es/number/virtual/to-fixed.js +2 -2
- package/es/number/virtual/to-precision.js +2 -2
- package/es/string/virtual/anchor.js +2 -2
- package/es/string/virtual/at.js +2 -2
- package/es/string/virtual/big.js +2 -2
- package/es/string/virtual/blink.js +2 -2
- package/es/string/virtual/bold.js +2 -2
- package/es/string/virtual/code-point-at.js +2 -2
- package/es/string/virtual/ends-with.js +2 -2
- package/es/string/virtual/fixed.js +2 -2
- package/es/string/virtual/fontcolor.js +2 -2
- package/es/string/virtual/fontsize.js +2 -2
- package/es/string/virtual/includes.js +2 -2
- package/es/string/virtual/is-well-formed.js +2 -1
- package/es/string/virtual/italics.js +2 -2
- package/es/string/virtual/link.js +2 -2
- package/es/string/virtual/match-all.js +2 -2
- package/es/string/virtual/pad-end.js +2 -2
- package/es/string/virtual/pad-start.js +2 -2
- package/es/string/virtual/repeat.js +2 -2
- package/es/string/virtual/replace-all.js +2 -2
- package/es/string/virtual/small.js +2 -2
- package/es/string/virtual/starts-with.js +2 -2
- package/es/string/virtual/strike.js +2 -2
- package/es/string/virtual/sub.js +2 -2
- package/es/string/virtual/substr.js +2 -2
- package/es/string/virtual/sup.js +2 -2
- package/es/string/virtual/to-well-formed.js +2 -1
- package/es/string/virtual/trim-end.js +2 -2
- package/es/string/virtual/trim-left.js +2 -2
- package/es/string/virtual/trim-right.js +2 -2
- package/es/string/virtual/trim-start.js +2 -2
- package/es/string/virtual/trim.js +2 -2
- package/full/array/virtual/filter-out.js +2 -2
- package/full/array/virtual/filter-reject.js +2 -2
- package/full/array/virtual/unique-by.js +2 -2
- package/full/function/virtual/demethodize.js +2 -2
- package/full/function/virtual/un-this.js +2 -2
- package/full/string/virtual/at.js +2 -2
- package/full/string/virtual/code-points.js +2 -1
- package/internals/array-from-async.js +2 -2
- package/internals/engine-is-bun.js +1 -1
- package/internals/error-to-string.js +2 -3
- package/internals/get-async-iterator-flattenable.js +1 -1
- package/internals/get-built-in-prototype-method.js +8 -0
- package/internals/global.js +2 -1
- package/internals/shared.js +2 -2
- package/modules/es.array.iterator.js +1 -2
- package/modules/es.array.to-sorted.js +2 -2
- package/modules/es.symbol.constructor.js +5 -4
- package/modules/esnext.data-view.get-uint8-clamped.js +1 -1
- package/modules/esnext.data-view.set-uint8-clamped.js +1 -1
- package/modules/esnext.number.from-string.js +10 -7
- package/modules/esnext.string.dedent.js +7 -12
- package/modules/esnext.symbol.metadata-key.js +1 -0
- package/modules/esnext.symbol.metadata.js +0 -1
- package/modules/web.structured-clone.js +52 -159
- package/modules/web.url-search-params.constructor.js +20 -11
- package/package.json +2 -1
- package/proposals/array-buffer-transfer.js +1 -0
- package/proposals/data-view-get-set-uint8-clamped.js +1 -1
- package/proposals/well-formed-unicode-strings.js +1 -0
- package/stable/instance/for-each.js +1 -1
- package/stage/README.md +1 -1
- package/web/README.md +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.small');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'small');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.starts-with');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'startsWith');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.strike');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'strike');
|
package/es/string/virtual/sub.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.sub');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'sub');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.substr');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'substr');
|
package/es/string/virtual/sup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.sup');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'sup');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.to-well-formed');
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
3
4
|
|
|
4
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'toWellFormed');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.trim-end');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'trimRight');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.trim-start');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'trimLeft');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.trim-end');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'trimRight');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.trim-start');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'trimLeft');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.string.trim');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('String', 'trim');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// TODO: Remove from `core-js@4`
|
|
3
3
|
require('../../../modules/esnext.array.filter-out');
|
|
4
|
-
var
|
|
4
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
5
5
|
|
|
6
|
-
module.exports =
|
|
6
|
+
module.exports = getBuiltInPrototypeMethod('Array', 'filterOut');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/esnext.array.filter-reject');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('Array', 'filterReject');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.map');
|
|
3
3
|
require('../../../modules/esnext.array.unique-by');
|
|
4
|
-
var
|
|
4
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
5
5
|
|
|
6
|
-
module.exports =
|
|
6
|
+
module.exports = getBuiltInPrototypeMethod('Array', 'uniqueBy');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/esnext.function.demethodize');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('Function', 'demethodize');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/esnext.function.un-this');
|
|
3
|
-
var
|
|
3
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
4
|
|
|
5
|
-
module.exports =
|
|
5
|
+
module.exports = getBuiltInPrototypeMethod('Function', 'unThis');
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
require('../../../actual/string/virtual/at');
|
|
3
3
|
// TODO: Remove from `core-js@4`
|
|
4
4
|
require('../../../modules/esnext.string.at');
|
|
5
|
-
var
|
|
5
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
6
6
|
|
|
7
|
-
module.exports =
|
|
7
|
+
module.exports = getBuiltInPrototypeMethod('String', 'at');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
require('../../../modules/es.object.to-string');
|
|
3
3
|
require('../../../modules/esnext.string.code-points');
|
|
4
|
+
var getBuiltInPrototypeMethod = require('../../../internals/get-built-in-prototype-method');
|
|
4
5
|
|
|
5
|
-
module.exports =
|
|
6
|
+
module.exports = getBuiltInPrototypeMethod('String', 'codePoints');
|
|
@@ -8,14 +8,14 @@ var getIterator = require('../internals/get-iterator');
|
|
|
8
8
|
var getIteratorDirect = require('../internals/get-iterator-direct');
|
|
9
9
|
var getIteratorMethod = require('../internals/get-iterator-method');
|
|
10
10
|
var getMethod = require('../internals/get-method');
|
|
11
|
-
var getVirtual = require('../internals/entry-virtual');
|
|
12
11
|
var getBuiltIn = require('../internals/get-built-in');
|
|
12
|
+
var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method');
|
|
13
13
|
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
14
14
|
var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
|
|
15
15
|
var toArray = require('../internals/async-iterator-iteration').toArray;
|
|
16
16
|
|
|
17
17
|
var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator');
|
|
18
|
-
var arrayIterator = uncurryThis(
|
|
18
|
+
var arrayIterator = uncurryThis(getBuiltInPrototypeMethod('Array', 'values'));
|
|
19
19
|
var arrayIteratorNext = uncurryThis(arrayIterator([]).next);
|
|
20
20
|
|
|
21
21
|
var safeArrayIterator = function () {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
var DESCRIPTORS = require('../internals/descriptors');
|
|
3
3
|
var fails = require('../internals/fails');
|
|
4
4
|
var anObject = require('../internals/an-object');
|
|
5
|
-
var create = require('../internals/object-create');
|
|
6
5
|
var normalizeStringArgument = require('../internals/normalize-string-argument');
|
|
7
6
|
|
|
8
7
|
var nativeErrorToString = Error.prototype.toString;
|
|
@@ -10,8 +9,8 @@ var nativeErrorToString = Error.prototype.toString;
|
|
|
10
9
|
var INCORRECT_TO_STRING = fails(function () {
|
|
11
10
|
if (DESCRIPTORS) {
|
|
12
11
|
// Chrome 32- incorrectly call accessor
|
|
13
|
-
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
14
|
-
var object = create(Object.defineProperty({}, 'name', { get: function () {
|
|
12
|
+
// eslint-disable-next-line es/no-object-create, es/no-object-defineproperty -- safe
|
|
13
|
+
var object = Object.create(Object.defineProperty({}, 'name', { get: function () {
|
|
15
14
|
return this === object;
|
|
16
15
|
} }));
|
|
17
16
|
if (nativeErrorToString.call(object) !== 'true') return true;
|
|
@@ -10,7 +10,7 @@ var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
|
|
|
10
10
|
|
|
11
11
|
var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator');
|
|
12
12
|
|
|
13
|
-
module.exports = function
|
|
13
|
+
module.exports = function (obj) {
|
|
14
14
|
var object = anObject(obj);
|
|
15
15
|
var alreadyAsync = true;
|
|
16
16
|
var method = getMethod(object, ASYNC_ITERATOR);
|
package/internals/global.js
CHANGED
|
@@ -11,5 +11,6 @@ module.exports =
|
|
|
11
11
|
// eslint-disable-next-line no-restricted-globals -- safe
|
|
12
12
|
check(typeof self == 'object' && self) ||
|
|
13
13
|
check(typeof global == 'object' && global) ||
|
|
14
|
+
check(typeof this == 'object' && this) ||
|
|
14
15
|
// eslint-disable-next-line no-new-func -- fallback
|
|
15
|
-
(function () { return this; })() ||
|
|
16
|
+
(function () { return this; })() || Function('return this')();
|
package/internals/shared.js
CHANGED
|
@@ -5,9 +5,9 @@ var store = require('../internals/shared-store');
|
|
|
5
5
|
(module.exports = function (key, value) {
|
|
6
6
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
7
7
|
})('versions', []).push({
|
|
8
|
-
version: '3.33.
|
|
8
|
+
version: '3.33.3',
|
|
9
9
|
mode: IS_PURE ? 'pure' : 'global',
|
|
10
10
|
copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
|
|
11
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.33.
|
|
11
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.33.3/LICENSE',
|
|
12
12
|
source: 'https://github.com/zloirock/core-js'
|
|
13
13
|
});
|
|
@@ -35,13 +35,12 @@ module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
|
|
|
35
35
|
}, function () {
|
|
36
36
|
var state = getInternalState(this);
|
|
37
37
|
var target = state.target;
|
|
38
|
-
var kind = state.kind;
|
|
39
38
|
var index = state.index++;
|
|
40
39
|
if (!target || index >= target.length) {
|
|
41
40
|
state.target = undefined;
|
|
42
41
|
return createIterResultObject(undefined, true);
|
|
43
42
|
}
|
|
44
|
-
switch (kind) {
|
|
43
|
+
switch (state.kind) {
|
|
45
44
|
case 'keys': return createIterResultObject(index, false);
|
|
46
45
|
case 'values': return createIterResultObject(target[index], false);
|
|
47
46
|
} return createIterResultObject([index, target[index]], false);
|
|
@@ -4,11 +4,11 @@ var uncurryThis = require('../internals/function-uncurry-this');
|
|
|
4
4
|
var aCallable = require('../internals/a-callable');
|
|
5
5
|
var toIndexedObject = require('../internals/to-indexed-object');
|
|
6
6
|
var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
|
|
7
|
-
var
|
|
7
|
+
var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method');
|
|
8
8
|
var addToUnscopables = require('../internals/add-to-unscopables');
|
|
9
9
|
|
|
10
10
|
var $Array = Array;
|
|
11
|
-
var sort = uncurryThis(
|
|
11
|
+
var sort = uncurryThis(getBuiltInPrototypeMethod('Array', 'sort'));
|
|
12
12
|
|
|
13
13
|
// `Array.prototype.toSorted` method
|
|
14
14
|
// https://tc39.es/ecma262/#sec-array.prototype.tosorted
|
|
@@ -168,14 +168,15 @@ if (!NATIVE_SYMBOL) {
|
|
|
168
168
|
var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
|
|
169
169
|
var tag = uid(description);
|
|
170
170
|
var setter = function (value) {
|
|
171
|
-
|
|
172
|
-
if (
|
|
171
|
+
var $this = this === undefined ? global : this;
|
|
172
|
+
if ($this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
|
|
173
|
+
if (hasOwn($this, HIDDEN) && hasOwn($this[HIDDEN], tag)) $this[HIDDEN][tag] = false;
|
|
173
174
|
var descriptor = createPropertyDescriptor(1, value);
|
|
174
175
|
try {
|
|
175
|
-
setSymbolDescriptor(this, tag, descriptor);
|
|
176
|
+
setSymbolDescriptor($this, tag, descriptor);
|
|
176
177
|
} catch (error) {
|
|
177
178
|
if (!(error instanceof RangeError)) throw error;
|
|
178
|
-
fallbackDefineProperty(this, tag, descriptor);
|
|
179
|
+
fallbackDefineProperty($this, tag, descriptor);
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
|
|
@@ -6,7 +6,7 @@ var uncurryThis = require('../internals/function-uncurry-this');
|
|
|
6
6
|
var getUint8 = uncurryThis(DataView.prototype.getUint8);
|
|
7
7
|
|
|
8
8
|
// `DataView.prototype.getUint8Clamped` method
|
|
9
|
-
// https://github.com/tc39/proposal-dataview-get-set-
|
|
9
|
+
// https://github.com/tc39/proposal-dataview-get-set-uint8clamped
|
|
10
10
|
$({ target: 'DataView', proto: true, forced: true }, {
|
|
11
11
|
getUint8Clamped: function getUint8Clamped(byteOffset) {
|
|
12
12
|
return getUint8(this, byteOffset);
|
|
@@ -10,7 +10,7 @@ var $TypeError = TypeError;
|
|
|
10
10
|
var setUint8 = uncurryThis(DataView.prototype.setUint8);
|
|
11
11
|
|
|
12
12
|
// `DataView.prototype.setUint8Clamped` method
|
|
13
|
-
// https://github.com/tc39/proposal-dataview-get-set-
|
|
13
|
+
// https://github.com/tc39/proposal-dataview-get-set-uint8clamped
|
|
14
14
|
$({ target: 'DataView', proto: true, forced: true }, {
|
|
15
15
|
setUint8Clamped: function setUint8Clamped(byteOffset, value) {
|
|
16
16
|
if (classof(this) !== 'DataView') throw new $TypeError('Incorrect receiver');
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
3
|
var uncurryThis = require('../internals/function-uncurry-this');
|
|
4
4
|
var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
|
5
|
-
var parseInt = require('../internals/number-parse-int');
|
|
6
5
|
|
|
7
6
|
var INVALID_NUMBER_REPRESENTATION = 'Invalid number representation';
|
|
8
7
|
var INVALID_RADIX = 'Invalid radix';
|
|
9
8
|
var $RangeError = RangeError;
|
|
10
9
|
var $SyntaxError = SyntaxError;
|
|
11
10
|
var $TypeError = TypeError;
|
|
12
|
-
var
|
|
11
|
+
var $parseInt = parseInt;
|
|
12
|
+
var pow = Math.pow;
|
|
13
|
+
var valid = /^[\d.a-z]+$/;
|
|
13
14
|
var charAt = uncurryThis(''.charAt);
|
|
14
15
|
var exec = uncurryThis(valid.exec);
|
|
15
16
|
var numberToString = uncurryThis(1.0.toString);
|
|
16
17
|
var stringSlice = uncurryThis(''.slice);
|
|
18
|
+
var split = uncurryThis(''.split);
|
|
17
19
|
|
|
18
20
|
// `Number.fromString` method
|
|
19
21
|
// https://github.com/tc39/proposal-number-fromstring
|
|
20
22
|
$({ target: 'Number', stat: true, forced: true }, {
|
|
21
23
|
fromString: function fromString(string, radix) {
|
|
22
24
|
var sign = 1;
|
|
23
|
-
var R, mathNum;
|
|
24
25
|
if (typeof string != 'string') throw new $TypeError(INVALID_NUMBER_REPRESENTATION);
|
|
25
26
|
if (!string.length) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION);
|
|
26
27
|
if (charAt(string, 0) === '-') {
|
|
@@ -28,11 +29,13 @@ $({ target: 'Number', stat: true, forced: true }, {
|
|
|
28
29
|
string = stringSlice(string, 1);
|
|
29
30
|
if (!string.length) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION);
|
|
30
31
|
}
|
|
31
|
-
R = radix === undefined ? 10 : toIntegerOrInfinity(radix);
|
|
32
|
+
var R = radix === undefined ? 10 : toIntegerOrInfinity(radix);
|
|
32
33
|
if (R < 2 || R > 36) throw new $RangeError(INVALID_RADIX);
|
|
33
|
-
if (!exec(valid, string)
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (!exec(valid, string)) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION);
|
|
35
|
+
var parts = split(string, '.');
|
|
36
|
+
var mathNum = $parseInt(parts[0], R);
|
|
37
|
+
if (parts.length > 1) mathNum += $parseInt(parts[1], R) / pow(R, parts[1].length);
|
|
38
|
+
if (numberToString(mathNum, R) !== string) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION);
|
|
36
39
|
return sign * mathNum;
|
|
37
40
|
}
|
|
38
41
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var FREEZING = require('../internals/freezing');
|
|
3
3
|
var $ = require('../internals/export');
|
|
4
|
-
var shared = require('../internals/shared');
|
|
5
|
-
var getBuiltIn = require('../internals/get-built-in');
|
|
6
4
|
var makeBuiltIn = require('../internals/make-built-in');
|
|
7
5
|
var uncurryThis = require('../internals/function-uncurry-this');
|
|
8
6
|
var apply = require('../internals/function-apply');
|
|
@@ -12,18 +10,15 @@ var isCallable = require('../internals/is-callable');
|
|
|
12
10
|
var lengthOfArrayLike = require('../internals/length-of-array-like');
|
|
13
11
|
var defineProperty = require('../internals/object-define-property').f;
|
|
14
12
|
var createArrayFromList = require('../internals/array-slice-simple');
|
|
13
|
+
var WeakMapHelpers = require('../internals/weak-map-helpers');
|
|
15
14
|
var cooked = require('../internals/string-cooked');
|
|
16
15
|
var parse = require('../internals/string-parse');
|
|
17
16
|
var whitespaces = require('../internals/whitespaces');
|
|
18
17
|
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
globalDedentRegistry.has = globalDedentRegistry.has;
|
|
24
|
-
globalDedentRegistry.get = globalDedentRegistry.get;
|
|
25
|
-
globalDedentRegistry.set = globalDedentRegistry.set;
|
|
26
|
-
/* eslint-enable no-self-assign -- prototype methods protection */
|
|
18
|
+
var DedentMap = new WeakMapHelpers.WeakMap();
|
|
19
|
+
var weakMapGet = WeakMapHelpers.get;
|
|
20
|
+
var weakMapHas = WeakMapHelpers.has;
|
|
21
|
+
var weakMapSet = WeakMapHelpers.set;
|
|
27
22
|
|
|
28
23
|
var $Array = Array;
|
|
29
24
|
var $TypeError = TypeError;
|
|
@@ -48,14 +43,14 @@ var dedentTemplateStringsArray = function (template) {
|
|
|
48
43
|
var rawInput = template.raw;
|
|
49
44
|
// https://github.com/tc39/proposal-string-dedent/issues/75
|
|
50
45
|
if (FREEZING && !isFrozen(rawInput)) throw new $TypeError('Raw template should be frozen');
|
|
51
|
-
if (
|
|
46
|
+
if (weakMapHas(DedentMap, rawInput)) return weakMapGet(DedentMap, rawInput);
|
|
52
47
|
var raw = dedentStringsArray(rawInput);
|
|
53
48
|
var cookedArr = cookStrings(raw);
|
|
54
49
|
defineProperty(cookedArr, 'raw', {
|
|
55
50
|
value: freeze(raw)
|
|
56
51
|
});
|
|
57
52
|
freeze(cookedArr);
|
|
58
|
-
|
|
53
|
+
weakMapSet(DedentMap, rawInput, cookedArr);
|
|
59
54
|
return cookedArr;
|
|
60
55
|
};
|
|
61
56
|
|