core-js 3.40.0 → 3.41.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/data-view/get-float16.js +3 -0
- package/actual/data-view/set-float16.js +3 -0
- package/actual/math/f16round.js +2 -2
- package/actual/regexp/escape.js +2 -2
- package/es/data-view/get-float16.js +2 -0
- package/es/data-view/index.js +2 -0
- package/es/data-view/set-float16.js +2 -0
- package/es/index.js +4 -0
- package/es/math/f16round.js +5 -0
- package/es/math/index.js +1 -0
- package/es/regexp/escape.js +5 -0
- package/es/regexp/index.js +1 -0
- package/full/index.js +4 -0
- package/internals/a-number.js +7 -0
- package/internals/shared-store.js +2 -2
- package/modules/es.data-view.get-float16.js +31 -0
- package/modules/es.data-view.set-float16.js +54 -0
- package/modules/es.math.f16round.js +15 -0
- package/modules/es.regexp.escape.js +70 -0
- package/modules/esnext.async-disposable-stack.constructor.js +6 -1
- package/modules/esnext.async-iterator.flat-map.js +1 -1
- package/modules/esnext.data-view.get-float16.js +2 -30
- package/modules/esnext.data-view.set-float16.js +2 -53
- package/modules/esnext.math.clamp.js +13 -5
- package/modules/esnext.math.f16round.js +2 -14
- package/modules/esnext.regexp.escape.js +2 -70
- package/package.json +1 -1
- package/proposals/math-clamp.js +3 -0
- package/stable/data-view/get-float16.js +4 -0
- package/stable/data-view/set-float16.js +4 -0
- package/stable/index.js +4 -0
- package/stable/math/f16round.js +4 -0
- package/stable/regexp/escape.js +4 -0
- package/stage/1.js +1 -0
- package/stage/3.js +0 -2
- package/stage/4.js +2 -0
package/actual/math/f16round.js
CHANGED
package/actual/regexp/escape.js
CHANGED
package/es/data-view/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
require('../../modules/es.array-buffer.constructor');
|
|
3
3
|
require('../../modules/es.array-buffer.slice');
|
|
4
4
|
require('../../modules/es.data-view');
|
|
5
|
+
require('../../modules/es.data-view.get-float16');
|
|
6
|
+
require('../../modules/es.data-view.set-float16');
|
|
5
7
|
require('../../modules/es.object.to-string');
|
|
6
8
|
var path = require('../../internals/path');
|
|
7
9
|
|
package/es/index.js
CHANGED
|
@@ -60,6 +60,8 @@ require('../modules/es.array-buffer.constructor');
|
|
|
60
60
|
require('../modules/es.array-buffer.is-view');
|
|
61
61
|
require('../modules/es.array-buffer.slice');
|
|
62
62
|
require('../modules/es.data-view');
|
|
63
|
+
require('../modules/es.data-view.get-float16');
|
|
64
|
+
require('../modules/es.data-view.set-float16');
|
|
63
65
|
require('../modules/es.array-buffer.detached');
|
|
64
66
|
require('../modules/es.array-buffer.transfer');
|
|
65
67
|
require('../modules/es.array-buffer.transfer-to-fixed-length');
|
|
@@ -101,6 +103,7 @@ require('../modules/es.math.clz32');
|
|
|
101
103
|
require('../modules/es.math.cosh');
|
|
102
104
|
require('../modules/es.math.expm1');
|
|
103
105
|
require('../modules/es.math.fround');
|
|
106
|
+
require('../modules/es.math.f16round');
|
|
104
107
|
require('../modules/es.math.hypot');
|
|
105
108
|
require('../modules/es.math.imul');
|
|
106
109
|
require('../modules/es.math.log10');
|
|
@@ -175,6 +178,7 @@ require('../modules/es.reflect.set');
|
|
|
175
178
|
require('../modules/es.reflect.set-prototype-of');
|
|
176
179
|
require('../modules/es.reflect.to-string-tag');
|
|
177
180
|
require('../modules/es.regexp.constructor');
|
|
181
|
+
require('../modules/es.regexp.escape');
|
|
178
182
|
require('../modules/es.regexp.dot-all');
|
|
179
183
|
require('../modules/es.regexp.exec');
|
|
180
184
|
require('../modules/es.regexp.flags');
|
package/es/math/index.js
CHANGED
|
@@ -7,6 +7,7 @@ require('../../modules/es.math.clz32');
|
|
|
7
7
|
require('../../modules/es.math.cosh');
|
|
8
8
|
require('../../modules/es.math.expm1');
|
|
9
9
|
require('../../modules/es.math.fround');
|
|
10
|
+
require('../../modules/es.math.f16round');
|
|
10
11
|
require('../../modules/es.math.hypot');
|
|
11
12
|
require('../../modules/es.math.imul');
|
|
12
13
|
require('../../modules/es.math.log10');
|
package/es/regexp/index.js
CHANGED
package/full/index.js
CHANGED
|
@@ -60,6 +60,8 @@ require('../modules/es.array-buffer.constructor');
|
|
|
60
60
|
require('../modules/es.array-buffer.is-view');
|
|
61
61
|
require('../modules/es.array-buffer.slice');
|
|
62
62
|
require('../modules/es.data-view');
|
|
63
|
+
require('../modules/es.data-view.get-float16');
|
|
64
|
+
require('../modules/es.data-view.set-float16');
|
|
63
65
|
require('../modules/es.array-buffer.detached');
|
|
64
66
|
require('../modules/es.array-buffer.transfer');
|
|
65
67
|
require('../modules/es.array-buffer.transfer-to-fixed-length');
|
|
@@ -101,6 +103,7 @@ require('../modules/es.math.clz32');
|
|
|
101
103
|
require('../modules/es.math.cosh');
|
|
102
104
|
require('../modules/es.math.expm1');
|
|
103
105
|
require('../modules/es.math.fround');
|
|
106
|
+
require('../modules/es.math.f16round');
|
|
104
107
|
require('../modules/es.math.hypot');
|
|
105
108
|
require('../modules/es.math.imul');
|
|
106
109
|
require('../modules/es.math.log10');
|
|
@@ -175,6 +178,7 @@ require('../modules/es.reflect.set');
|
|
|
175
178
|
require('../modules/es.reflect.set-prototype-of');
|
|
176
179
|
require('../modules/es.reflect.to-string-tag');
|
|
177
180
|
require('../modules/es.regexp.constructor');
|
|
181
|
+
require('../modules/es.regexp.escape');
|
|
178
182
|
require('../modules/es.regexp.dot-all');
|
|
179
183
|
require('../modules/es.regexp.exec');
|
|
180
184
|
require('../modules/es.regexp.flags');
|
|
@@ -7,9 +7,9 @@ var SHARED = '__core-js_shared__';
|
|
|
7
7
|
var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
|
|
8
8
|
|
|
9
9
|
(store.versions || (store.versions = [])).push({
|
|
10
|
-
version: '3.
|
|
10
|
+
version: '3.41.0',
|
|
11
11
|
mode: IS_PURE ? 'pure' : 'global',
|
|
12
12
|
copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
|
|
13
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
13
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE',
|
|
14
14
|
source: 'https://github.com/zloirock/core-js'
|
|
15
15
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var uncurryThis = require('../internals/function-uncurry-this');
|
|
4
|
+
|
|
5
|
+
var pow = Math.pow;
|
|
6
|
+
|
|
7
|
+
var EXP_MASK16 = 31; // 2 ** 5 - 1
|
|
8
|
+
var SIGNIFICAND_MASK16 = 1023; // 2 ** 10 - 1
|
|
9
|
+
var MIN_SUBNORMAL16 = pow(2, -24); // 2 ** -10 * 2 ** -14
|
|
10
|
+
var SIGNIFICAND_DENOM16 = 0.0009765625; // 2 ** -10
|
|
11
|
+
|
|
12
|
+
var unpackFloat16 = function (bytes) {
|
|
13
|
+
var sign = bytes >>> 15;
|
|
14
|
+
var exponent = bytes >>> 10 & EXP_MASK16;
|
|
15
|
+
var significand = bytes & SIGNIFICAND_MASK16;
|
|
16
|
+
if (exponent === EXP_MASK16) return significand === 0 ? (sign === 0 ? Infinity : -Infinity) : NaN;
|
|
17
|
+
if (exponent === 0) return significand * (sign === 0 ? MIN_SUBNORMAL16 : -MIN_SUBNORMAL16);
|
|
18
|
+
return pow(2, exponent - 15) * (sign === 0 ? 1 + significand * SIGNIFICAND_DENOM16 : -1 - significand * SIGNIFICAND_DENOM16);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line es/no-typed-arrays -- safe
|
|
22
|
+
var getUint16 = uncurryThis(DataView.prototype.getUint16);
|
|
23
|
+
|
|
24
|
+
// `DataView.prototype.getFloat16` method
|
|
25
|
+
// https://tc39.es/ecma262/#sec-dataview.prototype.getfloat16
|
|
26
|
+
$({ target: 'DataView', proto: true }, {
|
|
27
|
+
getFloat16: function getFloat16(byteOffset /* , littleEndian */) {
|
|
28
|
+
var uint16 = getUint16(this, byteOffset, arguments.length > 1 ? arguments[1] : false);
|
|
29
|
+
return unpackFloat16(uint16);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var uncurryThis = require('../internals/function-uncurry-this');
|
|
4
|
+
var aDataView = require('../internals/a-data-view');
|
|
5
|
+
var toIndex = require('../internals/to-index');
|
|
6
|
+
// TODO: Replace with module dependency in `core-js@4`
|
|
7
|
+
var log2 = require('../internals/math-log2');
|
|
8
|
+
var roundTiesToEven = require('../internals/math-round-ties-to-even');
|
|
9
|
+
|
|
10
|
+
var pow = Math.pow;
|
|
11
|
+
|
|
12
|
+
var MIN_INFINITY16 = 65520; // (2 - 2 ** -11) * 2 ** 15
|
|
13
|
+
var MIN_NORMAL16 = 0.000061005353927612305; // (1 - 2 ** -11) * 2 ** -14
|
|
14
|
+
var REC_MIN_SUBNORMAL16 = 16777216; // 2 ** 10 * 2 ** 14
|
|
15
|
+
var REC_SIGNIFICAND_DENOM16 = 1024; // 2 ** 10;
|
|
16
|
+
|
|
17
|
+
var packFloat16 = function (value) {
|
|
18
|
+
// eslint-disable-next-line no-self-compare -- NaN check
|
|
19
|
+
if (value !== value) return 0x7E00; // NaN
|
|
20
|
+
if (value === 0) return (1 / value === -Infinity) << 15; // +0 or -0
|
|
21
|
+
|
|
22
|
+
var neg = value < 0;
|
|
23
|
+
if (neg) value = -value;
|
|
24
|
+
if (value >= MIN_INFINITY16) return neg << 15 | 0x7C00; // Infinity
|
|
25
|
+
if (value < MIN_NORMAL16) return neg << 15 | roundTiesToEven(value * REC_MIN_SUBNORMAL16); // subnormal
|
|
26
|
+
|
|
27
|
+
// normal
|
|
28
|
+
var exponent = log2(value) | 0;
|
|
29
|
+
if (exponent === -15) {
|
|
30
|
+
// we round from a value between 2 ** -15 * (1 + 1022/1024) (the largest subnormal) and 2 ** -14 * (1 + 0/1024) (the smallest normal)
|
|
31
|
+
// to the latter (former impossible because of the subnormal check above)
|
|
32
|
+
return neg << 15 | REC_SIGNIFICAND_DENOM16;
|
|
33
|
+
}
|
|
34
|
+
var significand = roundTiesToEven((value * pow(2, -exponent) - 1) * REC_SIGNIFICAND_DENOM16);
|
|
35
|
+
if (significand === REC_SIGNIFICAND_DENOM16) {
|
|
36
|
+
// we round from a value between 2 ** n * (1 + 1023/1024) and 2 ** (n + 1) * (1 + 0/1024) to the latter
|
|
37
|
+
return neg << 15 | exponent + 16 << 10;
|
|
38
|
+
}
|
|
39
|
+
return neg << 15 | exponent + 15 << 10 | significand;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line es/no-typed-arrays -- safe
|
|
43
|
+
var setUint16 = uncurryThis(DataView.prototype.setUint16);
|
|
44
|
+
|
|
45
|
+
// `DataView.prototype.setFloat16` method
|
|
46
|
+
// https://tc39.es/ecma262/#sec-dataview.prototype.setfloat16
|
|
47
|
+
$({ target: 'DataView', proto: true }, {
|
|
48
|
+
setFloat16: function setFloat16(byteOffset, value /* , littleEndian */) {
|
|
49
|
+
aDataView(this);
|
|
50
|
+
var offset = toIndex(byteOffset);
|
|
51
|
+
var bytes = packFloat16(+value);
|
|
52
|
+
return setUint16(this, offset, bytes, arguments.length > 2 ? arguments[2] : false);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var floatRound = require('../internals/math-float-round');
|
|
4
|
+
|
|
5
|
+
var FLOAT16_EPSILON = 0.0009765625;
|
|
6
|
+
var FLOAT16_MAX_VALUE = 65504;
|
|
7
|
+
var FLOAT16_MIN_VALUE = 6.103515625e-05;
|
|
8
|
+
|
|
9
|
+
// `Math.f16round` method
|
|
10
|
+
// https://tc39.es/ecma262/#sec-math.f16round
|
|
11
|
+
$({ target: 'Math', stat: true }, {
|
|
12
|
+
f16round: function f16round(x) {
|
|
13
|
+
return floatRound(x, FLOAT16_EPSILON, FLOAT16_MAX_VALUE, FLOAT16_MIN_VALUE);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var uncurryThis = require('../internals/function-uncurry-this');
|
|
4
|
+
var aString = require('../internals/a-string');
|
|
5
|
+
var hasOwn = require('../internals/has-own-property');
|
|
6
|
+
var padStart = require('../internals/string-pad').start;
|
|
7
|
+
var WHITESPACES = require('../internals/whitespaces');
|
|
8
|
+
|
|
9
|
+
var $Array = Array;
|
|
10
|
+
var $escape = RegExp.escape;
|
|
11
|
+
var charAt = uncurryThis(''.charAt);
|
|
12
|
+
var charCodeAt = uncurryThis(''.charCodeAt);
|
|
13
|
+
var numberToString = uncurryThis(1.1.toString);
|
|
14
|
+
var join = uncurryThis([].join);
|
|
15
|
+
var FIRST_DIGIT_OR_ASCII = /^[0-9a-z]/i;
|
|
16
|
+
var SYNTAX_SOLIDUS = /^[$()*+./?[\\\]^{|}]/;
|
|
17
|
+
var OTHER_PUNCTUATORS_AND_WHITESPACES = RegExp('^[!"#%&\',\\-:;<=>@`~' + WHITESPACES + ']');
|
|
18
|
+
var exec = uncurryThis(FIRST_DIGIT_OR_ASCII.exec);
|
|
19
|
+
|
|
20
|
+
var ControlEscape = {
|
|
21
|
+
'\u0009': 't',
|
|
22
|
+
'\u000A': 'n',
|
|
23
|
+
'\u000B': 'v',
|
|
24
|
+
'\u000C': 'f',
|
|
25
|
+
'\u000D': 'r'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var escapeChar = function (chr) {
|
|
29
|
+
var hex = numberToString(charCodeAt(chr, 0), 16);
|
|
30
|
+
return hex.length < 3 ? '\\x' + padStart(hex, 2, '0') : '\\u' + padStart(hex, 4, '0');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Avoiding the use of polyfills of the previous iteration of this proposal
|
|
34
|
+
var FORCED = !$escape || $escape('ab') !== '\\x61b';
|
|
35
|
+
|
|
36
|
+
// `RegExp.escape` method
|
|
37
|
+
// https://tc39.es/ecma262/#sec-regexp.escape
|
|
38
|
+
$({ target: 'RegExp', stat: true, forced: FORCED }, {
|
|
39
|
+
escape: function escape(S) {
|
|
40
|
+
aString(S);
|
|
41
|
+
var length = S.length;
|
|
42
|
+
var result = $Array(length);
|
|
43
|
+
|
|
44
|
+
for (var i = 0; i < length; i++) {
|
|
45
|
+
var chr = charAt(S, i);
|
|
46
|
+
if (i === 0 && exec(FIRST_DIGIT_OR_ASCII, chr)) {
|
|
47
|
+
result[i] = escapeChar(chr);
|
|
48
|
+
} else if (hasOwn(ControlEscape, chr)) {
|
|
49
|
+
result[i] = '\\' + ControlEscape[chr];
|
|
50
|
+
} else if (exec(SYNTAX_SOLIDUS, chr)) {
|
|
51
|
+
result[i] = '\\' + chr;
|
|
52
|
+
} else if (exec(OTHER_PUNCTUATORS_AND_WHITESPACES, chr)) {
|
|
53
|
+
result[i] = escapeChar(chr);
|
|
54
|
+
} else {
|
|
55
|
+
var charCode = charCodeAt(chr, 0);
|
|
56
|
+
// single UTF-16 code unit
|
|
57
|
+
if ((charCode & 0xF800) !== 0xD800) result[i] = chr;
|
|
58
|
+
// unpaired surrogate
|
|
59
|
+
else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) !== 0xDC00) result[i] = escapeChar(chr);
|
|
60
|
+
// surrogate pair
|
|
61
|
+
else {
|
|
62
|
+
result[i] = chr;
|
|
63
|
+
result[++i] = charAt(S, i);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return join(result, '');
|
|
69
|
+
}
|
|
70
|
+
});
|
|
@@ -11,6 +11,7 @@ var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
|
|
|
11
11
|
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
12
12
|
var InternalStateModule = require('../internals/internal-state');
|
|
13
13
|
var addDisposableResource = require('../internals/add-disposable-resource');
|
|
14
|
+
var V8_VERSION = require('../internals/environment-v8-version');
|
|
14
15
|
|
|
15
16
|
var Promise = getBuiltIn('Promise');
|
|
16
17
|
var SuppressedError = getBuiltIn('SuppressedError');
|
|
@@ -125,6 +126,10 @@ if (DESCRIPTORS) defineBuiltInAccessor(AsyncDisposableStackPrototype, 'disposed'
|
|
|
125
126
|
defineBuiltIn(AsyncDisposableStackPrototype, ASYNC_DISPOSE, AsyncDisposableStackPrototype.disposeAsync, { name: 'disposeAsync' });
|
|
126
127
|
defineBuiltIn(AsyncDisposableStackPrototype, TO_STRING_TAG, ASYNC_DISPOSABLE_STACK, { nonWritable: true });
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
// https://github.com/tc39/proposal-explicit-resource-management/issues/256
|
|
130
|
+
// can't be detected synchronously
|
|
131
|
+
var SYNC_DISPOSE_RETURNING_PROMISE_RESOLUTION_BUG = V8_VERSION && V8_VERSION < 136;
|
|
132
|
+
|
|
133
|
+
$({ global: true, constructor: true, forced: SYNC_DISPOSE_RETURNING_PROMISE_RESOLUTION_BUG }, {
|
|
129
134
|
AsyncDisposableStack: $AsyncDisposableStack
|
|
130
135
|
});
|
|
@@ -74,7 +74,7 @@ var AsyncIteratorProxy = createAsyncIteratorProxy(function (Promise) {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
// `AsyncIterator.prototype.
|
|
77
|
+
// `AsyncIterator.prototype.flatMap` method
|
|
78
78
|
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
79
79
|
$({ target: 'AsyncIterator', proto: true, real: true, forced: IS_PURE }, {
|
|
80
80
|
flatMap: function flatMap(mapper) {
|
|
@@ -1,31 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var pow = Math.pow;
|
|
6
|
-
|
|
7
|
-
var EXP_MASK16 = 31; // 2 ** 5 - 1
|
|
8
|
-
var SIGNIFICAND_MASK16 = 1023; // 2 ** 10 - 1
|
|
9
|
-
var MIN_SUBNORMAL16 = pow(2, -24); // 2 ** -10 * 2 ** -14
|
|
10
|
-
var SIGNIFICAND_DENOM16 = 0.0009765625; // 2 ** -10
|
|
11
|
-
|
|
12
|
-
var unpackFloat16 = function (bytes) {
|
|
13
|
-
var sign = bytes >>> 15;
|
|
14
|
-
var exponent = bytes >>> 10 & EXP_MASK16;
|
|
15
|
-
var significand = bytes & SIGNIFICAND_MASK16;
|
|
16
|
-
if (exponent === EXP_MASK16) return significand === 0 ? (sign === 0 ? Infinity : -Infinity) : NaN;
|
|
17
|
-
if (exponent === 0) return significand * (sign === 0 ? MIN_SUBNORMAL16 : -MIN_SUBNORMAL16);
|
|
18
|
-
return pow(2, exponent - 15) * (sign === 0 ? 1 + significand * SIGNIFICAND_DENOM16 : -1 - significand * SIGNIFICAND_DENOM16);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line es/no-typed-arrays -- safe
|
|
22
|
-
var getUint16 = uncurryThis(DataView.prototype.getUint16);
|
|
23
|
-
|
|
24
|
-
// `DataView.prototype.getFloat16` method
|
|
25
|
-
// https://github.com/tc39/proposal-float16array
|
|
26
|
-
$({ target: 'DataView', proto: true }, {
|
|
27
|
-
getFloat16: function getFloat16(byteOffset /* , littleEndian */) {
|
|
28
|
-
var uint16 = getUint16(this, byteOffset, arguments.length > 1 ? arguments[1] : false);
|
|
29
|
-
return unpackFloat16(uint16);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
2
|
+
// TODO: Remove from `core-js@4`
|
|
3
|
+
require('../modules/es.data-view.get-float16');
|
|
@@ -1,54 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var aDataView = require('../internals/a-data-view');
|
|
5
|
-
var toIndex = require('../internals/to-index');
|
|
6
|
-
// TODO: Replace with module dependency in `core-js@4`
|
|
7
|
-
var log2 = require('../internals/math-log2');
|
|
8
|
-
var roundTiesToEven = require('../internals/math-round-ties-to-even');
|
|
9
|
-
|
|
10
|
-
var pow = Math.pow;
|
|
11
|
-
|
|
12
|
-
var MIN_INFINITY16 = 65520; // (2 - 2 ** -11) * 2 ** 15
|
|
13
|
-
var MIN_NORMAL16 = 0.000061005353927612305; // (1 - 2 ** -11) * 2 ** -14
|
|
14
|
-
var REC_MIN_SUBNORMAL16 = 16777216; // 2 ** 10 * 2 ** 14
|
|
15
|
-
var REC_SIGNIFICAND_DENOM16 = 1024; // 2 ** 10;
|
|
16
|
-
|
|
17
|
-
var packFloat16 = function (value) {
|
|
18
|
-
// eslint-disable-next-line no-self-compare -- NaN check
|
|
19
|
-
if (value !== value) return 0x7E00; // NaN
|
|
20
|
-
if (value === 0) return (1 / value === -Infinity) << 15; // +0 or -0
|
|
21
|
-
|
|
22
|
-
var neg = value < 0;
|
|
23
|
-
if (neg) value = -value;
|
|
24
|
-
if (value >= MIN_INFINITY16) return neg << 15 | 0x7C00; // Infinity
|
|
25
|
-
if (value < MIN_NORMAL16) return neg << 15 | roundTiesToEven(value * REC_MIN_SUBNORMAL16); // subnormal
|
|
26
|
-
|
|
27
|
-
// normal
|
|
28
|
-
var exponent = log2(value) | 0;
|
|
29
|
-
if (exponent === -15) {
|
|
30
|
-
// we round from a value between 2 ** -15 * (1 + 1022/1024) (the largest subnormal) and 2 ** -14 * (1 + 0/1024) (the smallest normal)
|
|
31
|
-
// to the latter (former impossible because of the subnormal check above)
|
|
32
|
-
return neg << 15 | REC_SIGNIFICAND_DENOM16;
|
|
33
|
-
}
|
|
34
|
-
var significand = roundTiesToEven((value * pow(2, -exponent) - 1) * REC_SIGNIFICAND_DENOM16);
|
|
35
|
-
if (significand === REC_SIGNIFICAND_DENOM16) {
|
|
36
|
-
// we round from a value between 2 ** n * (1 + 1023/1024) and 2 ** (n + 1) * (1 + 0/1024) to the latter
|
|
37
|
-
return neg << 15 | exponent + 16 << 10;
|
|
38
|
-
}
|
|
39
|
-
return neg << 15 | exponent + 15 << 10 | significand;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// eslint-disable-next-line es/no-typed-arrays -- safe
|
|
43
|
-
var setUint16 = uncurryThis(DataView.prototype.setUint16);
|
|
44
|
-
|
|
45
|
-
// `DataView.prototype.setFloat16` method
|
|
46
|
-
// https://github.com/tc39/proposal-float16array
|
|
47
|
-
$({ target: 'DataView', proto: true }, {
|
|
48
|
-
setFloat16: function setFloat16(byteOffset, value /* , littleEndian */) {
|
|
49
|
-
aDataView(this);
|
|
50
|
-
var offset = toIndex(byteOffset);
|
|
51
|
-
var bytes = packFloat16(+value);
|
|
52
|
-
return setUint16(this, offset, bytes, arguments.length > 2 ? arguments[2] : false);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
2
|
+
// TODO: Remove from `core-js@4`
|
|
3
|
+
require('../modules/es.data-view.set-float16');
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
|
+
var aNumber = require('../internals/a-number');
|
|
4
|
+
var notANaN = require('../internals/not-a-nan');
|
|
5
|
+
var sameValue = require('../internals/same-value');
|
|
3
6
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
7
|
+
var $RangeError = RangeError;
|
|
8
|
+
var $min = Math.min;
|
|
9
|
+
var $max = Math.max;
|
|
6
10
|
|
|
7
11
|
// `Math.clamp` method
|
|
8
|
-
// https://
|
|
12
|
+
// https://github.com/tc39/proposal-math-clamp
|
|
9
13
|
$({ target: 'Math', stat: true, forced: true }, {
|
|
10
|
-
clamp: function clamp(
|
|
11
|
-
|
|
14
|
+
clamp: function clamp(value, min, max) {
|
|
15
|
+
aNumber(value);
|
|
16
|
+
notANaN(aNumber(min));
|
|
17
|
+
notANaN(aNumber(max));
|
|
18
|
+
if ((sameValue(min, 0) && sameValue(max, -0)) || min > max) throw new $RangeError('`min` should be smaller than `max`');
|
|
19
|
+
return $min(max, $max(min, value));
|
|
12
20
|
}
|
|
13
21
|
});
|
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var FLOAT16_EPSILON = 0.0009765625;
|
|
6
|
-
var FLOAT16_MAX_VALUE = 65504;
|
|
7
|
-
var FLOAT16_MIN_VALUE = 6.103515625e-05;
|
|
8
|
-
|
|
9
|
-
// `Math.f16round` method
|
|
10
|
-
// https://github.com/tc39/proposal-float16array
|
|
11
|
-
$({ target: 'Math', stat: true }, {
|
|
12
|
-
f16round: function f16round(x) {
|
|
13
|
-
return floatRound(x, FLOAT16_EPSILON, FLOAT16_MAX_VALUE, FLOAT16_MIN_VALUE);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
2
|
+
// TODO: Remove from `core-js@4`
|
|
3
|
+
require('../modules/es.math.f16round');
|
|
@@ -1,71 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var aString = require('../internals/a-string');
|
|
5
|
-
var hasOwn = require('../internals/has-own-property');
|
|
6
|
-
var padStart = require('../internals/string-pad').start;
|
|
7
|
-
var WHITESPACES = require('../internals/whitespaces');
|
|
8
|
-
|
|
9
|
-
var $Array = Array;
|
|
10
|
-
// eslint-disable-next-line es/no-nonstandard-regexp-properties -- safe
|
|
11
|
-
var $escape = RegExp.escape;
|
|
12
|
-
var charAt = uncurryThis(''.charAt);
|
|
13
|
-
var charCodeAt = uncurryThis(''.charCodeAt);
|
|
14
|
-
var numberToString = uncurryThis(1.1.toString);
|
|
15
|
-
var join = uncurryThis([].join);
|
|
16
|
-
var FIRST_DIGIT_OR_ASCII = /^[0-9a-z]/i;
|
|
17
|
-
var SYNTAX_SOLIDUS = /^[$()*+./?[\\\]^{|}]/;
|
|
18
|
-
var OTHER_PUNCTUATORS_AND_WHITESPACES = RegExp('^[!"#%&\',\\-:;<=>@`~' + WHITESPACES + ']');
|
|
19
|
-
var exec = uncurryThis(FIRST_DIGIT_OR_ASCII.exec);
|
|
20
|
-
|
|
21
|
-
var ControlEscape = {
|
|
22
|
-
'\u0009': 't',
|
|
23
|
-
'\u000A': 'n',
|
|
24
|
-
'\u000B': 'v',
|
|
25
|
-
'\u000C': 'f',
|
|
26
|
-
'\u000D': 'r'
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var escapeChar = function (chr) {
|
|
30
|
-
var hex = numberToString(charCodeAt(chr, 0), 16);
|
|
31
|
-
return hex.length < 3 ? '\\x' + padStart(hex, 2, '0') : '\\u' + padStart(hex, 4, '0');
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Avoiding the use of polyfills of the previous iteration of this proposal
|
|
35
|
-
var FORCED = !$escape || $escape('ab') !== '\\x61b';
|
|
36
|
-
|
|
37
|
-
// `RegExp.escape` method
|
|
38
|
-
// https://github.com/tc39/proposal-regex-escaping
|
|
39
|
-
$({ target: 'RegExp', stat: true, forced: FORCED }, {
|
|
40
|
-
escape: function escape(S) {
|
|
41
|
-
aString(S);
|
|
42
|
-
var length = S.length;
|
|
43
|
-
var result = $Array(length);
|
|
44
|
-
|
|
45
|
-
for (var i = 0; i < length; i++) {
|
|
46
|
-
var chr = charAt(S, i);
|
|
47
|
-
if (i === 0 && exec(FIRST_DIGIT_OR_ASCII, chr)) {
|
|
48
|
-
result[i] = escapeChar(chr);
|
|
49
|
-
} else if (hasOwn(ControlEscape, chr)) {
|
|
50
|
-
result[i] = '\\' + ControlEscape[chr];
|
|
51
|
-
} else if (exec(SYNTAX_SOLIDUS, chr)) {
|
|
52
|
-
result[i] = '\\' + chr;
|
|
53
|
-
} else if (exec(OTHER_PUNCTUATORS_AND_WHITESPACES, chr)) {
|
|
54
|
-
result[i] = escapeChar(chr);
|
|
55
|
-
} else {
|
|
56
|
-
var charCode = charCodeAt(chr, 0);
|
|
57
|
-
// single UTF-16 code unit
|
|
58
|
-
if ((charCode & 0xF800) !== 0xD800) result[i] = chr;
|
|
59
|
-
// unpaired surrogate
|
|
60
|
-
else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) !== 0xDC00) result[i] = escapeChar(chr);
|
|
61
|
-
// surrogate pair
|
|
62
|
-
else {
|
|
63
|
-
result[i] = chr;
|
|
64
|
-
result[++i] = charAt(S, i);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return join(result, '');
|
|
70
|
-
}
|
|
71
|
-
});
|
|
2
|
+
// TODO: Remove from `core-js@4`
|
|
3
|
+
require('../modules/es.regexp.escape.js');
|
package/package.json
CHANGED
package/stable/index.js
CHANGED
|
@@ -60,6 +60,8 @@ require('../modules/es.array-buffer.constructor');
|
|
|
60
60
|
require('../modules/es.array-buffer.is-view');
|
|
61
61
|
require('../modules/es.array-buffer.slice');
|
|
62
62
|
require('../modules/es.data-view');
|
|
63
|
+
require('../modules/es.data-view.get-float16');
|
|
64
|
+
require('../modules/es.data-view.set-float16');
|
|
63
65
|
require('../modules/es.array-buffer.detached');
|
|
64
66
|
require('../modules/es.array-buffer.transfer');
|
|
65
67
|
require('../modules/es.array-buffer.transfer-to-fixed-length');
|
|
@@ -101,6 +103,7 @@ require('../modules/es.math.clz32');
|
|
|
101
103
|
require('../modules/es.math.cosh');
|
|
102
104
|
require('../modules/es.math.expm1');
|
|
103
105
|
require('../modules/es.math.fround');
|
|
106
|
+
require('../modules/es.math.f16round');
|
|
104
107
|
require('../modules/es.math.hypot');
|
|
105
108
|
require('../modules/es.math.imul');
|
|
106
109
|
require('../modules/es.math.log10');
|
|
@@ -175,6 +178,7 @@ require('../modules/es.reflect.set');
|
|
|
175
178
|
require('../modules/es.reflect.set-prototype-of');
|
|
176
179
|
require('../modules/es.reflect.to-string-tag');
|
|
177
180
|
require('../modules/es.regexp.constructor');
|
|
181
|
+
require('../modules/es.regexp.escape');
|
|
178
182
|
require('../modules/es.regexp.dot-all');
|
|
179
183
|
require('../modules/es.regexp.exec');
|
|
180
184
|
require('../modules/es.regexp.flags');
|
package/stage/1.js
CHANGED
|
@@ -8,6 +8,7 @@ require('../proposals/collection-methods');
|
|
|
8
8
|
require('../proposals/collection-of-from');
|
|
9
9
|
require('../proposals/data-view-get-set-uint8-clamped');
|
|
10
10
|
require('../proposals/keys-composition');
|
|
11
|
+
require('../proposals/math-clamp');
|
|
11
12
|
require('../proposals/math-extensions');
|
|
12
13
|
require('../proposals/math-signbit');
|
|
13
14
|
require('../proposals/number-from-string');
|
package/stage/3.js
CHANGED
|
@@ -5,11 +5,9 @@ require('../proposals/array-buffer-base64');
|
|
|
5
5
|
require('../proposals/array-from-async-stage-2');
|
|
6
6
|
require('../proposals/decorator-metadata-v2');
|
|
7
7
|
require('../proposals/explicit-resource-management');
|
|
8
|
-
require('../proposals/float16');
|
|
9
8
|
require('../proposals/is-error');
|
|
10
9
|
require('../proposals/json-parse-with-source');
|
|
11
10
|
require('../proposals/math-sum');
|
|
12
|
-
require('../proposals/regexp-escaping');
|
|
13
11
|
// TODO: Obsolete versions, remove from `core-js@4`
|
|
14
12
|
require('../proposals/array-grouping-stage-3');
|
|
15
13
|
require('../proposals/array-grouping-stage-3-2');
|
package/stage/4.js
CHANGED
|
@@ -6,12 +6,14 @@ require('../proposals/array-find-from-last');
|
|
|
6
6
|
require('../proposals/array-grouping-v2');
|
|
7
7
|
require('../proposals/change-array-by-copy-stage-4');
|
|
8
8
|
// require('../proposals/error-cause');
|
|
9
|
+
require('../proposals/float16');
|
|
9
10
|
require('../proposals/global-this');
|
|
10
11
|
require('../proposals/iterator-helpers-stage-3-2');
|
|
11
12
|
require('../proposals/promise-all-settled');
|
|
12
13
|
require('../proposals/promise-any');
|
|
13
14
|
require('../proposals/promise-try');
|
|
14
15
|
require('../proposals/promise-with-resolvers');
|
|
16
|
+
require('../proposals/regexp-escaping');
|
|
15
17
|
require('../proposals/relative-indexing-method');
|
|
16
18
|
require('../proposals/set-methods-v2');
|
|
17
19
|
require('../proposals/string-match-all');
|