core-js 3.14.0 → 3.15.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/es/date/get-year.js +4 -0
- package/es/date/index.js +4 -1
- package/es/date/set-year.js +4 -0
- package/es/date/to-gmt-string.js +4 -0
- package/es/escape.js +4 -0
- package/es/index.js +7 -0
- package/es/regexp/dot-all.js +7 -0
- package/es/regexp/index.js +1 -0
- package/es/regexp/sticky.js +2 -0
- package/es/string/index.js +1 -0
- package/es/string/substr.js +4 -0
- package/es/string/virtual/index.js +1 -0
- package/es/string/virtual/substr.js +4 -0
- package/es/unescape.js +4 -0
- package/features/date/get-year.js +3 -0
- package/features/date/set-year.js +3 -0
- package/features/date/to-gmt-string.js +3 -0
- package/features/escape.js +3 -0
- package/features/index.js +7 -0
- package/features/regexp/dot-all.js +3 -0
- package/features/string/substr.js +3 -0
- package/features/string/virtual/substr.js +3 -0
- package/features/unescape.js +3 -0
- package/internals/fix-regexp-well-known-symbol-logic.js +5 -62
- package/internals/regexp-exec.js +29 -5
- package/internals/regexp-sticky-helpers.js +3 -7
- package/internals/regexp-unsupported-dot-all.js +7 -0
- package/internals/regexp-unsupported-ncg.js +8 -0
- package/internals/shared.js +1 -1
- package/modules/es.date.get-year.js +12 -0
- package/modules/es.date.set-year.js +18 -0
- package/modules/es.date.to-gmt-string.js +7 -0
- package/modules/es.escape.js +35 -0
- package/modules/es.regexp.constructor.js +121 -15
- package/modules/es.regexp.dot-all.js +22 -0
- package/modules/es.regexp.flags.js +10 -8
- package/modules/es.regexp.sticky.js +1 -1
- package/modules/es.string.match.js +5 -5
- package/modules/es.string.replace.js +37 -10
- package/modules/es.string.search.js +5 -5
- package/modules/es.string.split.js +18 -6
- package/modules/es.string.substr.js +25 -0
- package/modules/es.unescape.js +39 -0
- package/modules/web.url.js +3 -3
- package/package.json +2 -2
- package/stable/date/get-year.js +3 -0
- package/stable/date/set-year.js +3 -0
- package/stable/date/to-gmt-string.js +3 -0
- package/stable/escape.js +3 -0
- package/stable/index.js +7 -0
- package/stable/regexp/dot-all.js +3 -0
- package/stable/string/substr.js +3 -0
- package/stable/string/virtual/substr.js +3 -0
- package/stable/unescape.js +3 -0
package/es/date/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
require('../../modules/es.date.get-year');
|
|
1
2
|
require('../../modules/es.date.now');
|
|
2
|
-
require('../../modules/es.date.
|
|
3
|
+
require('../../modules/es.date.set-year');
|
|
4
|
+
require('../../modules/es.date.to-gmt-string');
|
|
3
5
|
require('../../modules/es.date.to-iso-string');
|
|
6
|
+
require('../../modules/es.date.to-json');
|
|
4
7
|
require('../../modules/es.date.to-string');
|
|
5
8
|
require('../../modules/es.date.to-primitive');
|
|
6
9
|
var path = require('../../internals/path');
|
package/es/escape.js
ADDED
package/es/index.js
CHANGED
|
@@ -47,11 +47,15 @@ require('../modules/es.array-buffer.constructor');
|
|
|
47
47
|
require('../modules/es.array-buffer.is-view');
|
|
48
48
|
require('../modules/es.array-buffer.slice');
|
|
49
49
|
require('../modules/es.data-view');
|
|
50
|
+
require('../modules/es.date.get-year');
|
|
50
51
|
require('../modules/es.date.now');
|
|
52
|
+
require('../modules/es.date.set-year');
|
|
53
|
+
require('../modules/es.date.to-gmt-string');
|
|
51
54
|
require('../modules/es.date.to-iso-string');
|
|
52
55
|
require('../modules/es.date.to-json');
|
|
53
56
|
require('../modules/es.date.to-primitive');
|
|
54
57
|
require('../modules/es.date.to-string');
|
|
58
|
+
require('../modules/es.escape');
|
|
55
59
|
require('../modules/es.function.bind');
|
|
56
60
|
require('../modules/es.function.has-instance');
|
|
57
61
|
require('../modules/es.function.name');
|
|
@@ -135,6 +139,7 @@ require('../modules/es.reflect.set');
|
|
|
135
139
|
require('../modules/es.reflect.set-prototype-of');
|
|
136
140
|
require('../modules/es.reflect.to-string-tag');
|
|
137
141
|
require('../modules/es.regexp.constructor');
|
|
142
|
+
require('../modules/es.regexp.dot-all');
|
|
138
143
|
require('../modules/es.regexp.exec');
|
|
139
144
|
require('../modules/es.regexp.flags');
|
|
140
145
|
require('../modules/es.regexp.sticky');
|
|
@@ -157,6 +162,7 @@ require('../modules/es.string.replace-all');
|
|
|
157
162
|
require('../modules/es.string.search');
|
|
158
163
|
require('../modules/es.string.split');
|
|
159
164
|
require('../modules/es.string.starts-with');
|
|
165
|
+
require('../modules/es.string.substr');
|
|
160
166
|
require('../modules/es.string.trim');
|
|
161
167
|
require('../modules/es.string.trim-end');
|
|
162
168
|
require('../modules/es.string.trim-start');
|
|
@@ -207,6 +213,7 @@ require('../modules/es.typed-array.sort');
|
|
|
207
213
|
require('../modules/es.typed-array.subarray');
|
|
208
214
|
require('../modules/es.typed-array.to-locale-string');
|
|
209
215
|
require('../modules/es.typed-array.to-string');
|
|
216
|
+
require('../modules/es.unescape');
|
|
210
217
|
require('../modules/es.weak-map');
|
|
211
218
|
require('../modules/es.weak-set');
|
|
212
219
|
|
package/es/regexp/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require('../../modules/es.regexp.constructor');
|
|
2
2
|
require('../../modules/es.regexp.to-string');
|
|
3
|
+
require('../../modules/es.regexp.dot-all');
|
|
3
4
|
require('../../modules/es.regexp.exec');
|
|
4
5
|
require('../../modules/es.regexp.flags');
|
|
5
6
|
require('../../modules/es.regexp.sticky');
|
package/es/regexp/sticky.js
CHANGED
package/es/string/index.js
CHANGED
|
@@ -14,6 +14,7 @@ require('../../modules/es.string.replace-all');
|
|
|
14
14
|
require('../../modules/es.string.search');
|
|
15
15
|
require('../../modules/es.string.split');
|
|
16
16
|
require('../../modules/es.string.starts-with');
|
|
17
|
+
require('../../modules/es.string.substr');
|
|
17
18
|
require('../../modules/es.string.trim');
|
|
18
19
|
require('../../modules/es.string.trim-start');
|
|
19
20
|
require('../../modules/es.string.trim-end');
|
|
@@ -11,6 +11,7 @@ require('../../../modules/es.string.replace-all');
|
|
|
11
11
|
require('../../../modules/es.string.search');
|
|
12
12
|
require('../../../modules/es.string.split');
|
|
13
13
|
require('../../../modules/es.string.starts-with');
|
|
14
|
+
require('../../../modules/es.string.substr');
|
|
14
15
|
require('../../../modules/es.string.trim');
|
|
15
16
|
require('../../../modules/es.string.trim-start');
|
|
16
17
|
require('../../../modules/es.string.trim-end');
|
package/es/unescape.js
ADDED
package/features/index.js
CHANGED
|
@@ -47,11 +47,15 @@ require('../modules/es.array-buffer.constructor');
|
|
|
47
47
|
require('../modules/es.array-buffer.is-view');
|
|
48
48
|
require('../modules/es.array-buffer.slice');
|
|
49
49
|
require('../modules/es.data-view');
|
|
50
|
+
require('../modules/es.date.get-year');
|
|
50
51
|
require('../modules/es.date.now');
|
|
52
|
+
require('../modules/es.date.set-year');
|
|
53
|
+
require('../modules/es.date.to-gmt-string');
|
|
51
54
|
require('../modules/es.date.to-iso-string');
|
|
52
55
|
require('../modules/es.date.to-json');
|
|
53
56
|
require('../modules/es.date.to-primitive');
|
|
54
57
|
require('../modules/es.date.to-string');
|
|
58
|
+
require('../modules/es.escape');
|
|
55
59
|
require('../modules/es.function.bind');
|
|
56
60
|
require('../modules/es.function.has-instance');
|
|
57
61
|
require('../modules/es.function.name');
|
|
@@ -135,6 +139,7 @@ require('../modules/es.reflect.set');
|
|
|
135
139
|
require('../modules/es.reflect.set-prototype-of');
|
|
136
140
|
require('../modules/es.reflect.to-string-tag');
|
|
137
141
|
require('../modules/es.regexp.constructor');
|
|
142
|
+
require('../modules/es.regexp.dot-all');
|
|
138
143
|
require('../modules/es.regexp.exec');
|
|
139
144
|
require('../modules/es.regexp.flags');
|
|
140
145
|
require('../modules/es.regexp.sticky');
|
|
@@ -157,6 +162,7 @@ require('../modules/es.string.replace-all');
|
|
|
157
162
|
require('../modules/es.string.search');
|
|
158
163
|
require('../modules/es.string.split');
|
|
159
164
|
require('../modules/es.string.starts-with');
|
|
165
|
+
require('../modules/es.string.substr');
|
|
160
166
|
require('../modules/es.string.trim');
|
|
161
167
|
require('../modules/es.string.trim-end');
|
|
162
168
|
require('../modules/es.string.trim-start');
|
|
@@ -207,6 +213,7 @@ require('../modules/es.typed-array.sort');
|
|
|
207
213
|
require('../modules/es.typed-array.subarray');
|
|
208
214
|
require('../modules/es.typed-array.to-locale-string');
|
|
209
215
|
require('../modules/es.typed-array.to-string');
|
|
216
|
+
require('../modules/es.unescape');
|
|
210
217
|
require('../modules/es.weak-map');
|
|
211
218
|
require('../modules/es.weak-set');
|
|
212
219
|
require('../modules/esnext.aggregate-error');
|
|
@@ -10,47 +10,7 @@ var createNonEnumerableProperty = require('../internals/create-non-enumerable-pr
|
|
|
10
10
|
var SPECIES = wellKnownSymbol('species');
|
|
11
11
|
var RegExpPrototype = RegExp.prototype;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
// #replace needs built-in support for named groups.
|
|
15
|
-
// #match works fine because it just return the exec results, even if it has
|
|
16
|
-
// a "grops" property.
|
|
17
|
-
var re = /./;
|
|
18
|
-
re.exec = function () {
|
|
19
|
-
var result = [];
|
|
20
|
-
result.groups = { a: '7' };
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
return ''.replace(re, '$<a>') !== '7';
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// IE <= 11 replaces $0 with the whole match, as if it was $&
|
|
27
|
-
// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
|
|
28
|
-
var REPLACE_KEEPS_$0 = (function () {
|
|
29
|
-
// eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
|
|
30
|
-
return 'a'.replace(/./, '$0') === '$0';
|
|
31
|
-
})();
|
|
32
|
-
|
|
33
|
-
var REPLACE = wellKnownSymbol('replace');
|
|
34
|
-
// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
|
|
35
|
-
var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
|
|
36
|
-
if (/./[REPLACE]) {
|
|
37
|
-
return /./[REPLACE]('a', '$0') === '';
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
})();
|
|
41
|
-
|
|
42
|
-
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
|
|
43
|
-
// Weex JS has frozen built-in prototypes, so use try / catch wrapper
|
|
44
|
-
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
|
|
45
|
-
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
46
|
-
var re = /(?:)/;
|
|
47
|
-
var originalExec = re.exec;
|
|
48
|
-
re.exec = function () { return originalExec.apply(this, arguments); };
|
|
49
|
-
var result = 'ab'.split(re);
|
|
50
|
-
return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
module.exports = function (KEY, length, exec, sham) {
|
|
13
|
+
module.exports = function (KEY, exec, FORCED, SHAM) {
|
|
54
14
|
var SYMBOL = wellKnownSymbol(KEY);
|
|
55
15
|
|
|
56
16
|
var DELEGATES_TO_SYMBOL = !fails(function () {
|
|
@@ -87,12 +47,7 @@ module.exports = function (KEY, length, exec, sham) {
|
|
|
87
47
|
if (
|
|
88
48
|
!DELEGATES_TO_SYMBOL ||
|
|
89
49
|
!DELEGATES_TO_EXEC ||
|
|
90
|
-
|
|
91
|
-
REPLACE_SUPPORTS_NAMED_GROUPS &&
|
|
92
|
-
REPLACE_KEEPS_$0 &&
|
|
93
|
-
!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
|
|
94
|
-
)) ||
|
|
95
|
-
(KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
|
|
50
|
+
FORCED
|
|
96
51
|
) {
|
|
97
52
|
var nativeRegExpMethod = /./[SYMBOL];
|
|
98
53
|
var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
|
|
@@ -107,23 +62,11 @@ module.exports = function (KEY, length, exec, sham) {
|
|
|
107
62
|
return { done: true, value: nativeMethod.call(str, regexp, arg2) };
|
|
108
63
|
}
|
|
109
64
|
return { done: false };
|
|
110
|
-
}, {
|
|
111
|
-
REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,
|
|
112
|
-
REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
|
|
113
65
|
});
|
|
114
|
-
var stringMethod = methods[0];
|
|
115
|
-
var regexMethod = methods[1];
|
|
116
66
|
|
|
117
|
-
redefine(String.prototype, KEY,
|
|
118
|
-
redefine(RegExpPrototype, SYMBOL,
|
|
119
|
-
// 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
|
|
120
|
-
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
|
|
121
|
-
? function (string, arg) { return regexMethod.call(string, this, arg); }
|
|
122
|
-
// 21.2.5.6 RegExp.prototype[@@match](string)
|
|
123
|
-
// 21.2.5.9 RegExp.prototype[@@search](string)
|
|
124
|
-
: function (string) { return regexMethod.call(string, this); }
|
|
125
|
-
);
|
|
67
|
+
redefine(String.prototype, KEY, methods[0]);
|
|
68
|
+
redefine(RegExpPrototype, SYMBOL, methods[1]);
|
|
126
69
|
}
|
|
127
70
|
|
|
128
|
-
if (
|
|
71
|
+
if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
|
|
129
72
|
};
|
package/internals/regexp-exec.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* eslint-disable regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
|
|
3
3
|
/* eslint-disable regexp/no-useless-quantifier -- testing */
|
|
4
|
-
var regexpFlags = require('
|
|
5
|
-
var stickyHelpers = require('
|
|
6
|
-
var shared = require('
|
|
4
|
+
var regexpFlags = require('../internals/regexp-flags');
|
|
5
|
+
var stickyHelpers = require('../internals/regexp-sticky-helpers');
|
|
6
|
+
var shared = require('../internals/shared');
|
|
7
|
+
var create = require('../internals/object-create');
|
|
8
|
+
var getInternalState = require('../internals/internal-state').get;
|
|
9
|
+
var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all');
|
|
10
|
+
var UNSUPPORTED_NCG = require('../internals/regexp-unsupported-ncg');
|
|
7
11
|
|
|
8
12
|
var nativeExec = RegExp.prototype.exec;
|
|
9
13
|
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
@@ -23,12 +27,24 @@ var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
|
|
|
23
27
|
// nonparticipating capturing group, copied from es5-shim's String#split patch.
|
|
24
28
|
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
|
25
29
|
|
|
26
|
-
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;
|
|
30
|
+
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
|
|
27
31
|
|
|
28
32
|
if (PATCH) {
|
|
33
|
+
// eslint-disable-next-line max-statements -- TODO
|
|
29
34
|
patchedExec = function exec(str) {
|
|
30
35
|
var re = this;
|
|
31
|
-
var
|
|
36
|
+
var state = getInternalState(re);
|
|
37
|
+
var raw = state.raw;
|
|
38
|
+
var result, reCopy, lastIndex, match, i, object, group;
|
|
39
|
+
|
|
40
|
+
if (raw) {
|
|
41
|
+
raw.lastIndex = re.lastIndex;
|
|
42
|
+
result = patchedExec.call(raw, str);
|
|
43
|
+
re.lastIndex = raw.lastIndex;
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var groups = state.groups;
|
|
32
48
|
var sticky = UNSUPPORTED_Y && re.sticky;
|
|
33
49
|
var flags = regexpFlags.call(re);
|
|
34
50
|
var source = re.source;
|
|
@@ -80,6 +96,14 @@ if (PATCH) {
|
|
|
80
96
|
});
|
|
81
97
|
}
|
|
82
98
|
|
|
99
|
+
if (match && groups) {
|
|
100
|
+
match.groups = object = create(null);
|
|
101
|
+
for (i = 0; i < groups.length; i++) {
|
|
102
|
+
group = groups[i];
|
|
103
|
+
object[group[0]] = match[group[1]];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
83
107
|
return match;
|
|
84
108
|
};
|
|
85
109
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var fails = require('./fails');
|
|
1
|
+
var fails = require('../internals/fails');
|
|
4
2
|
|
|
5
3
|
// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
|
|
6
|
-
|
|
7
|
-
function RE(s, f) {
|
|
4
|
+
var RE = function (s, f) {
|
|
8
5
|
return RegExp(s, f);
|
|
9
|
-
}
|
|
6
|
+
};
|
|
10
7
|
|
|
11
8
|
exports.UNSUPPORTED_Y = fails(function () {
|
|
12
|
-
// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
|
|
13
9
|
var re = RE('a', 'y');
|
|
14
10
|
re.lastIndex = 2;
|
|
15
11
|
return re.exec('abcd') != null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var fails = require('./fails');
|
|
2
|
+
|
|
3
|
+
module.exports = fails(function () {
|
|
4
|
+
// babel-minify transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError
|
|
5
|
+
var re = RegExp('(?<a>b)', (typeof '').charAt(5));
|
|
6
|
+
return re.exec('b').groups.a !== 'b' ||
|
|
7
|
+
'b'.replace(re, '$<a>c') !== 'bc';
|
|
8
|
+
});
|
package/internals/shared.js
CHANGED
|
@@ -4,7 +4,7 @@ var store = require('../internals/shared-store');
|
|
|
4
4
|
(module.exports = function (key, value) {
|
|
5
5
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
6
6
|
})('versions', []).push({
|
|
7
|
-
version: '3.
|
|
7
|
+
version: '3.15.0',
|
|
8
8
|
mode: IS_PURE ? 'pure' : 'global',
|
|
9
9
|
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
|
|
10
10
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
|
|
4
|
+
var getFullYear = Date.prototype.getFullYear;
|
|
5
|
+
|
|
6
|
+
// `Date.prototype.getYear` method
|
|
7
|
+
// https://tc39.es/ecma262/#sec-date.prototype.getyear
|
|
8
|
+
$({ target: 'Date', proto: true }, {
|
|
9
|
+
getYear: function getYear() {
|
|
10
|
+
return getFullYear.call(this) - 1900;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var toInteger = require('../internals/to-integer');
|
|
4
|
+
|
|
5
|
+
var getTime = Date.prototype.getTime;
|
|
6
|
+
var setFullYear = Date.prototype.setFullYear;
|
|
7
|
+
|
|
8
|
+
// `Date.prototype.setYear` method
|
|
9
|
+
// https://tc39.es/ecma262/#sec-date.prototype.setyear
|
|
10
|
+
$({ target: 'Date', proto: true }, {
|
|
11
|
+
setYear: function setYear(year) {
|
|
12
|
+
// validate
|
|
13
|
+
getTime.call(this);
|
|
14
|
+
var yi = toInteger(year);
|
|
15
|
+
var yyyy = 0 <= yi && yi <= 99 ? yi + 1900 : yi;
|
|
16
|
+
return setFullYear.call(this, yyyy);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
|
|
4
|
+
var raw = /[\w*+\-./@]/;
|
|
5
|
+
|
|
6
|
+
var hex = function (code, length) {
|
|
7
|
+
var result = code.toString(16);
|
|
8
|
+
while (result.length < length) result = '0' + result;
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// `escape` method
|
|
13
|
+
// https://tc39.es/ecma262/#sec-escape-string
|
|
14
|
+
$({ global: true }, {
|
|
15
|
+
escape: function escape(string) {
|
|
16
|
+
var str = String(string);
|
|
17
|
+
var result = '';
|
|
18
|
+
var length = str.length;
|
|
19
|
+
var index = 0;
|
|
20
|
+
var chr, code;
|
|
21
|
+
while (index < length) {
|
|
22
|
+
chr = str.charAt(index++);
|
|
23
|
+
if (raw.test(chr)) {
|
|
24
|
+
result += chr;
|
|
25
|
+
} else {
|
|
26
|
+
code = chr.charCodeAt(0);
|
|
27
|
+
if (code < 256) {
|
|
28
|
+
result += '%' + hex(code, 2);
|
|
29
|
+
} else {
|
|
30
|
+
result += '%u' + hex(code, 4).toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} return result;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -2,6 +2,7 @@ var DESCRIPTORS = require('../internals/descriptors');
|
|
|
2
2
|
var global = require('../internals/global');
|
|
3
3
|
var isForced = require('../internals/is-forced');
|
|
4
4
|
var inheritIfRequired = require('../internals/inherit-if-required');
|
|
5
|
+
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
|
5
6
|
var defineProperty = require('../internals/object-define-property').f;
|
|
6
7
|
var getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
|
|
7
8
|
var isRegExp = require('../internals/is-regexp');
|
|
@@ -9,13 +10,18 @@ var getFlags = require('../internals/regexp-flags');
|
|
|
9
10
|
var stickyHelpers = require('../internals/regexp-sticky-helpers');
|
|
10
11
|
var redefine = require('../internals/redefine');
|
|
11
12
|
var fails = require('../internals/fails');
|
|
13
|
+
var has = require('../internals/has');
|
|
12
14
|
var enforceInternalState = require('../internals/internal-state').enforce;
|
|
13
15
|
var setSpecies = require('../internals/set-species');
|
|
14
16
|
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
17
|
+
var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all');
|
|
18
|
+
var UNSUPPORTED_NCG = require('../internals/regexp-unsupported-ncg');
|
|
15
19
|
|
|
16
20
|
var MATCH = wellKnownSymbol('match');
|
|
17
21
|
var NativeRegExp = global.RegExp;
|
|
18
22
|
var RegExpPrototype = NativeRegExp.prototype;
|
|
23
|
+
// TODO: Use only propper RegExpIdentifierName
|
|
24
|
+
var IS_NCG = /^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/;
|
|
19
25
|
var re1 = /a/g;
|
|
20
26
|
var re2 = /a/g;
|
|
21
27
|
|
|
@@ -24,20 +30,90 @@ var CORRECT_NEW = new NativeRegExp(re1) !== re1;
|
|
|
24
30
|
|
|
25
31
|
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
|
|
26
32
|
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
var BASE_FORCED = DESCRIPTORS &&
|
|
34
|
+
(!CORRECT_NEW || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails(function () {
|
|
35
|
+
re2[MATCH] = false;
|
|
36
|
+
// RegExp constructor can alter flags and IsRegExp works correct with @@match
|
|
37
|
+
return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
var handleDotAll = function (string) {
|
|
41
|
+
var length = string.length;
|
|
42
|
+
var index = 0;
|
|
43
|
+
var result = '';
|
|
44
|
+
var brackets = false;
|
|
45
|
+
var chr;
|
|
46
|
+
for (; index <= length; index++) {
|
|
47
|
+
chr = string.charAt(index);
|
|
48
|
+
if (chr === '\\') {
|
|
49
|
+
result += chr + string.charAt(++index);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (!brackets && chr === '.') {
|
|
53
|
+
result += '[\\s\\S]';
|
|
54
|
+
} else {
|
|
55
|
+
if (chr === '[') {
|
|
56
|
+
brackets = true;
|
|
57
|
+
} else if (chr === ']') {
|
|
58
|
+
brackets = false;
|
|
59
|
+
} result += chr;
|
|
60
|
+
}
|
|
61
|
+
} return result;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var handleNCG = function (string) {
|
|
65
|
+
var length = string.length;
|
|
66
|
+
var index = 0;
|
|
67
|
+
var result = '';
|
|
68
|
+
var named = [];
|
|
69
|
+
var names = {};
|
|
70
|
+
var brackets = false;
|
|
71
|
+
var ncg = false;
|
|
72
|
+
var groupid = 0;
|
|
73
|
+
var groupname = '';
|
|
74
|
+
var chr;
|
|
75
|
+
for (; index <= length; index++) {
|
|
76
|
+
chr = string.charAt(index);
|
|
77
|
+
if (chr === '\\') {
|
|
78
|
+
chr = chr + string.charAt(++index);
|
|
79
|
+
} else if (chr === ']') {
|
|
80
|
+
brackets = false;
|
|
81
|
+
} else if (!brackets) switch (true) {
|
|
82
|
+
case chr === '[':
|
|
83
|
+
brackets = true;
|
|
84
|
+
break;
|
|
85
|
+
case chr === '(':
|
|
86
|
+
if (IS_NCG.test(string.slice(index + 1))) {
|
|
87
|
+
index += 2;
|
|
88
|
+
ncg = true;
|
|
89
|
+
}
|
|
90
|
+
result += chr;
|
|
91
|
+
groupid++;
|
|
92
|
+
continue;
|
|
93
|
+
case chr === '>' && ncg:
|
|
94
|
+
if (groupname === '' || has(names, groupname)) {
|
|
95
|
+
throw new SyntaxError('Invalid capture group name');
|
|
96
|
+
}
|
|
97
|
+
names[groupname] = true;
|
|
98
|
+
named.push([groupname, groupid]);
|
|
99
|
+
ncg = false;
|
|
100
|
+
groupname = '';
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (ncg) groupname += chr;
|
|
104
|
+
else result += chr;
|
|
105
|
+
} return [result, named];
|
|
106
|
+
};
|
|
32
107
|
|
|
33
108
|
// `RegExp` constructor
|
|
34
109
|
// https://tc39.es/ecma262/#sec-regexp-constructor
|
|
35
|
-
if (
|
|
110
|
+
if (isForced('RegExp', BASE_FORCED)) {
|
|
36
111
|
var RegExpWrapper = function RegExp(pattern, flags) {
|
|
37
112
|
var thisIsRegExp = this instanceof RegExpWrapper;
|
|
38
113
|
var patternIsRegExp = isRegExp(pattern);
|
|
39
114
|
var flagsAreUndefined = flags === undefined;
|
|
40
|
-
var
|
|
115
|
+
var groups = [];
|
|
116
|
+
var rawPattern, rawFlags, dotAll, sticky, handled, result, state;
|
|
41
117
|
|
|
42
118
|
if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
|
|
43
119
|
return pattern;
|
|
@@ -50,24 +126,52 @@ if (FORCED) {
|
|
|
50
126
|
pattern = pattern.source;
|
|
51
127
|
}
|
|
52
128
|
|
|
53
|
-
|
|
129
|
+
pattern = pattern === undefined ? '' : String(pattern);
|
|
130
|
+
flags = flags === undefined ? '' : String(flags);
|
|
131
|
+
rawPattern = pattern;
|
|
132
|
+
|
|
133
|
+
if (UNSUPPORTED_DOT_ALL && 'dotAll' in re1) {
|
|
134
|
+
dotAll = !!flags && flags.indexOf('s') > -1;
|
|
135
|
+
if (dotAll) flags = flags.replace(/s/g, '');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
rawFlags = flags;
|
|
139
|
+
|
|
140
|
+
if (UNSUPPORTED_Y && 'sticky' in re1) {
|
|
54
141
|
sticky = !!flags && flags.indexOf('y') > -1;
|
|
55
142
|
if (sticky) flags = flags.replace(/y/g, '');
|
|
56
143
|
}
|
|
57
144
|
|
|
58
|
-
|
|
145
|
+
if (UNSUPPORTED_NCG) {
|
|
146
|
+
handled = handleNCG(pattern);
|
|
147
|
+
pattern = handled[0];
|
|
148
|
+
groups = handled[1];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
result = inheritIfRequired(
|
|
59
152
|
CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),
|
|
60
153
|
thisIsRegExp ? this : RegExpPrototype,
|
|
61
154
|
RegExpWrapper
|
|
62
155
|
);
|
|
63
156
|
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
157
|
+
if (dotAll || sticky || groups.length) {
|
|
158
|
+
state = enforceInternalState(result);
|
|
159
|
+
if (dotAll) {
|
|
160
|
+
state.dotAll = true;
|
|
161
|
+
state.raw = RegExpWrapper(handleDotAll(pattern), rawFlags);
|
|
162
|
+
}
|
|
163
|
+
if (sticky) state.sticky = true;
|
|
164
|
+
if (groups.length) state.groups = groups;
|
|
67
165
|
}
|
|
68
166
|
|
|
167
|
+
if (pattern !== rawPattern) try {
|
|
168
|
+
// fails in old engines, but we have no alternatives for unsupported regex syntax
|
|
169
|
+
createNonEnumerableProperty(result, 'source', rawPattern === '' ? '(?:)' : rawPattern);
|
|
170
|
+
} catch (error) { /* empty */ }
|
|
171
|
+
|
|
69
172
|
return result;
|
|
70
173
|
};
|
|
174
|
+
|
|
71
175
|
var proxy = function (key) {
|
|
72
176
|
key in RegExpWrapper || defineProperty(RegExpWrapper, key, {
|
|
73
177
|
configurable: true,
|
|
@@ -75,9 +179,11 @@ if (FORCED) {
|
|
|
75
179
|
set: function (it) { NativeRegExp[key] = it; }
|
|
76
180
|
});
|
|
77
181
|
};
|
|
78
|
-
|
|
79
|
-
var index = 0;
|
|
80
|
-
|
|
182
|
+
|
|
183
|
+
for (var keys = getOwnPropertyNames(NativeRegExp), index = 0; keys.length > index;) {
|
|
184
|
+
proxy(keys[index++]);
|
|
185
|
+
}
|
|
186
|
+
|
|
81
187
|
RegExpPrototype.constructor = RegExpWrapper;
|
|
82
188
|
RegExpWrapper.prototype = RegExpPrototype;
|
|
83
189
|
redefine(global, 'RegExp', RegExpWrapper);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var DESCRIPTORS = require('../internals/descriptors');
|
|
2
|
+
var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all');
|
|
3
|
+
var defineProperty = require('../internals/object-define-property').f;
|
|
4
|
+
var getInternalState = require('../internals/internal-state').get;
|
|
5
|
+
var RegExpPrototype = RegExp.prototype;
|
|
6
|
+
|
|
7
|
+
// `RegExp.prototype.dotAll` getter
|
|
8
|
+
// https://tc39.es/ecma262/#sec-get-regexp.prototype.dotall
|
|
9
|
+
if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) {
|
|
10
|
+
defineProperty(RegExpPrototype, 'dotAll', {
|
|
11
|
+
configurable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
if (this === RegExpPrototype) return undefined;
|
|
14
|
+
// We can't use InternalStateModule.getterFor because
|
|
15
|
+
// we don't add metadata for regexps created by a literal.
|
|
16
|
+
if (this instanceof RegExp) {
|
|
17
|
+
return !!getInternalState(this).dotAll;
|
|
18
|
+
}
|
|
19
|
+
throw TypeError('Incompatible receiver, RegExp required');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
var DESCRIPTORS = require('../internals/descriptors');
|
|
2
2
|
var objectDefinePropertyModule = require('../internals/object-define-property');
|
|
3
3
|
var regExpFlags = require('../internals/regexp-flags');
|
|
4
|
-
var
|
|
4
|
+
var fails = require('../internals/fails');
|
|
5
|
+
|
|
6
|
+
var FORCED = DESCRIPTORS && fails(function () {
|
|
7
|
+
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
8
|
+
return Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get.call({ dotAll: true, sticky: true }) !== 'sy';
|
|
9
|
+
});
|
|
5
10
|
|
|
6
11
|
// `RegExp.prototype.flags` getter
|
|
7
12
|
// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get: regExpFlags
|
|
13
|
-
});
|
|
14
|
-
}
|
|
13
|
+
if (FORCED) objectDefinePropertyModule.f(RegExp.prototype, 'flags', {
|
|
14
|
+
configurable: true,
|
|
15
|
+
get: regExpFlags
|
|
16
|
+
});
|
|
@@ -7,7 +7,7 @@ var RegExpPrototype = RegExp.prototype;
|
|
|
7
7
|
// `RegExp.prototype.sticky` getter
|
|
8
8
|
// https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky
|
|
9
9
|
if (DESCRIPTORS && UNSUPPORTED_Y) {
|
|
10
|
-
defineProperty(
|
|
10
|
+
defineProperty(RegExpPrototype, 'sticky', {
|
|
11
11
|
configurable: true,
|
|
12
12
|
get: function () {
|
|
13
13
|
if (this === RegExpPrototype) return undefined;
|
|
@@ -7,7 +7,7 @@ var advanceStringIndex = require('../internals/advance-string-index');
|
|
|
7
7
|
var regExpExec = require('../internals/regexp-exec-abstract');
|
|
8
8
|
|
|
9
9
|
// @@match logic
|
|
10
|
-
fixRegExpWellKnownSymbolLogic('match',
|
|
10
|
+
fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
|
|
11
11
|
return [
|
|
12
12
|
// `String.prototype.match` method
|
|
13
13
|
// https://tc39.es/ecma262/#sec-string.prototype.match
|
|
@@ -18,12 +18,12 @@ fixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCal
|
|
|
18
18
|
},
|
|
19
19
|
// `RegExp.prototype[@@match]` method
|
|
20
20
|
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
|
|
21
|
-
function (
|
|
22
|
-
var res = maybeCallNative(nativeMatch,
|
|
21
|
+
function (string) {
|
|
22
|
+
var res = maybeCallNative(nativeMatch, this, string);
|
|
23
23
|
if (res.done) return res.value;
|
|
24
24
|
|
|
25
|
-
var rx = anObject(
|
|
26
|
-
var S = String(
|
|
25
|
+
var rx = anObject(this);
|
|
26
|
+
var S = String(string);
|
|
27
27
|
|
|
28
28
|
if (!rx.global) return regExpExec(rx, S);
|
|
29
29
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
|
|
3
|
+
var fails = require('../internals/fails');
|
|
3
4
|
var anObject = require('../internals/an-object');
|
|
4
5
|
var toLength = require('../internals/to-length');
|
|
5
6
|
var toInteger = require('../internals/to-integer');
|
|
@@ -7,7 +8,9 @@ var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
|
7
8
|
var advanceStringIndex = require('../internals/advance-string-index');
|
|
8
9
|
var getSubstitution = require('../internals/get-substitution');
|
|
9
10
|
var regExpExec = require('../internals/regexp-exec-abstract');
|
|
11
|
+
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
10
12
|
|
|
13
|
+
var REPLACE = wellKnownSymbol('replace');
|
|
11
14
|
var max = Math.max;
|
|
12
15
|
var min = Math.min;
|
|
13
16
|
|
|
@@ -15,10 +18,33 @@ var maybeToString = function (it) {
|
|
|
15
18
|
return it === undefined ? it : String(it);
|
|
16
19
|
};
|
|
17
20
|
|
|
21
|
+
// IE <= 11 replaces $0 with the whole match, as if it was $&
|
|
22
|
+
// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
|
|
23
|
+
var REPLACE_KEEPS_$0 = (function () {
|
|
24
|
+
// eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
|
|
25
|
+
return 'a'.replace(/./, '$0') === '$0';
|
|
26
|
+
})();
|
|
27
|
+
|
|
28
|
+
// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
|
|
29
|
+
var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
|
|
30
|
+
if (/./[REPLACE]) {
|
|
31
|
+
return /./[REPLACE]('a', '$0') === '';
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
|
|
37
|
+
var re = /./;
|
|
38
|
+
re.exec = function () {
|
|
39
|
+
var result = [];
|
|
40
|
+
result.groups = { a: '7' };
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
return ''.replace(re, '$<a>') !== '7';
|
|
44
|
+
});
|
|
45
|
+
|
|
18
46
|
// @@replace logic
|
|
19
|
-
fixRegExpWellKnownSymbolLogic('replace',
|
|
20
|
-
var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;
|
|
21
|
-
var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;
|
|
47
|
+
fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
|
|
22
48
|
var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
|
|
23
49
|
|
|
24
50
|
return [
|
|
@@ -33,17 +59,18 @@ fixRegExpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, ma
|
|
|
33
59
|
},
|
|
34
60
|
// `RegExp.prototype[@@replace]` method
|
|
35
61
|
// https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
|
|
36
|
-
function (
|
|
62
|
+
function (string, replaceValue) {
|
|
37
63
|
if (
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
typeof replaceValue === 'string' &&
|
|
65
|
+
replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 &&
|
|
66
|
+
replaceValue.indexOf('$<') === -1
|
|
40
67
|
) {
|
|
41
|
-
var res = maybeCallNative(nativeReplace,
|
|
68
|
+
var res = maybeCallNative(nativeReplace, this, string, replaceValue);
|
|
42
69
|
if (res.done) return res.value;
|
|
43
70
|
}
|
|
44
71
|
|
|
45
|
-
var rx = anObject(
|
|
46
|
-
var S = String(
|
|
72
|
+
var rx = anObject(this);
|
|
73
|
+
var S = String(string);
|
|
47
74
|
|
|
48
75
|
var functionalReplace = typeof replaceValue === 'function';
|
|
49
76
|
if (!functionalReplace) replaceValue = String(replaceValue);
|
|
@@ -95,4 +122,4 @@ fixRegExpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, ma
|
|
|
95
122
|
return accumulatedResult + S.slice(nextSourcePosition);
|
|
96
123
|
}
|
|
97
124
|
];
|
|
98
|
-
});
|
|
125
|
+
}, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
|
|
@@ -6,7 +6,7 @@ var sameValue = require('../internals/same-value');
|
|
|
6
6
|
var regExpExec = require('../internals/regexp-exec-abstract');
|
|
7
7
|
|
|
8
8
|
// @@search logic
|
|
9
|
-
fixRegExpWellKnownSymbolLogic('search',
|
|
9
|
+
fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCallNative) {
|
|
10
10
|
return [
|
|
11
11
|
// `String.prototype.search` method
|
|
12
12
|
// https://tc39.es/ecma262/#sec-string.prototype.search
|
|
@@ -17,12 +17,12 @@ fixRegExpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybe
|
|
|
17
17
|
},
|
|
18
18
|
// `RegExp.prototype[@@search]` method
|
|
19
19
|
// https://tc39.es/ecma262/#sec-regexp.prototype-@@search
|
|
20
|
-
function (
|
|
21
|
-
var res = maybeCallNative(nativeSearch,
|
|
20
|
+
function (string) {
|
|
21
|
+
var res = maybeCallNative(nativeSearch, this, string);
|
|
22
22
|
if (res.done) return res.value;
|
|
23
23
|
|
|
24
|
-
var rx = anObject(
|
|
25
|
-
var S = String(
|
|
24
|
+
var rx = anObject(this);
|
|
25
|
+
var S = String(string);
|
|
26
26
|
|
|
27
27
|
var previousLastIndex = rx.lastIndex;
|
|
28
28
|
if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
|
|
@@ -9,14 +9,26 @@ var toLength = require('../internals/to-length');
|
|
|
9
9
|
var callRegExpExec = require('../internals/regexp-exec-abstract');
|
|
10
10
|
var regexpExec = require('../internals/regexp-exec');
|
|
11
11
|
var stickyHelpers = require('../internals/regexp-sticky-helpers');
|
|
12
|
+
var fails = require('../internals/fails');
|
|
12
13
|
|
|
13
14
|
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
|
|
14
15
|
var arrayPush = [].push;
|
|
15
16
|
var min = Math.min;
|
|
16
17
|
var MAX_UINT32 = 0xFFFFFFFF;
|
|
17
18
|
|
|
19
|
+
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
|
|
20
|
+
// Weex JS has frozen built-in prototypes, so use try / catch wrapper
|
|
21
|
+
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
|
|
22
|
+
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
23
|
+
var re = /(?:)/;
|
|
24
|
+
var originalExec = re.exec;
|
|
25
|
+
re.exec = function () { return originalExec.apply(this, arguments); };
|
|
26
|
+
var result = 'ab'.split(re);
|
|
27
|
+
return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
|
|
28
|
+
});
|
|
29
|
+
|
|
18
30
|
// @@split logic
|
|
19
|
-
fixRegExpWellKnownSymbolLogic('split',
|
|
31
|
+
fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
|
|
20
32
|
var internalSplit;
|
|
21
33
|
if (
|
|
22
34
|
'abbc'.split(/(b)*/)[1] == 'c' ||
|
|
@@ -85,12 +97,12 @@ fixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCal
|
|
|
85
97
|
//
|
|
86
98
|
// NOTE: This cannot be properly polyfilled in engines that don't support
|
|
87
99
|
// the 'y' flag.
|
|
88
|
-
function (
|
|
89
|
-
var res = maybeCallNative(internalSplit,
|
|
100
|
+
function (string, limit) {
|
|
101
|
+
var res = maybeCallNative(internalSplit, this, string, limit, internalSplit !== nativeSplit);
|
|
90
102
|
if (res.done) return res.value;
|
|
91
103
|
|
|
92
|
-
var rx = anObject(
|
|
93
|
-
var S = String(
|
|
104
|
+
var rx = anObject(this);
|
|
105
|
+
var S = String(string);
|
|
94
106
|
var C = speciesConstructor(rx, RegExp);
|
|
95
107
|
|
|
96
108
|
var unicodeMatching = rx.unicode;
|
|
@@ -131,4 +143,4 @@ fixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCal
|
|
|
131
143
|
return A;
|
|
132
144
|
}
|
|
133
145
|
];
|
|
134
|
-
}, UNSUPPORTED_Y);
|
|
146
|
+
}, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
4
|
+
var toInteger = require('../internals/to-integer');
|
|
5
|
+
|
|
6
|
+
var slice = ''.slice;
|
|
7
|
+
var max = Math.max;
|
|
8
|
+
var min = Math.min;
|
|
9
|
+
|
|
10
|
+
// `String.prototype.substr` method
|
|
11
|
+
// https://tc39.es/ecma262/#sec-string.prototype.substr
|
|
12
|
+
$({ target: 'String', proto: true }, {
|
|
13
|
+
substr: function substr(start, length) {
|
|
14
|
+
var that = String(requireObjectCoercible(this));
|
|
15
|
+
var size = that.length;
|
|
16
|
+
var intStart = toInteger(start);
|
|
17
|
+
var intLength, intEnd;
|
|
18
|
+
if (intStart === Infinity) intStart = 0;
|
|
19
|
+
if (intStart < 0) intStart = max(size + intStart, 0);
|
|
20
|
+
intLength = length === undefined ? size : toInteger(length);
|
|
21
|
+
if (intLength <= 0 || intLength === Infinity) return '';
|
|
22
|
+
intEnd = min(intStart + intLength, size);
|
|
23
|
+
return intStart >= intEnd ? '' : slice.call(that, intStart, intEnd);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
|
|
4
|
+
var fromCharCode = String.fromCharCode;
|
|
5
|
+
var hex2 = /^[\da-f]{2}$/i;
|
|
6
|
+
var hex4 = /^[\da-f]{4}$/i;
|
|
7
|
+
|
|
8
|
+
// `unescape` method
|
|
9
|
+
// https://tc39.es/ecma262/#sec-unescape-string
|
|
10
|
+
$({ global: true }, {
|
|
11
|
+
unescape: function unescape(string) {
|
|
12
|
+
var str = String(string);
|
|
13
|
+
var result = '';
|
|
14
|
+
var length = str.length;
|
|
15
|
+
var index = 0;
|
|
16
|
+
var chr, slice;
|
|
17
|
+
while (index < length) {
|
|
18
|
+
chr = str.charAt(index++);
|
|
19
|
+
if (chr === '%') {
|
|
20
|
+
if (str.charAt(index) === 'u') {
|
|
21
|
+
slice = str.slice(index + 1, index + 5);
|
|
22
|
+
if (hex4.test(slice)) {
|
|
23
|
+
result += fromCharCode(parseInt(slice, 16));
|
|
24
|
+
index += 5;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
slice = str.slice(index, index + 2);
|
|
29
|
+
if (hex2.test(slice)) {
|
|
30
|
+
result += fromCharCode(parseInt(slice, 16));
|
|
31
|
+
index += 2;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
result += chr;
|
|
37
|
+
} return result;
|
|
38
|
+
}
|
|
39
|
+
});
|
package/modules/web.url.js
CHANGED
|
@@ -34,13 +34,13 @@ var ALPHA = /[A-Za-z]/;
|
|
|
34
34
|
// eslint-disable-next-line regexp/no-obscure-range -- safe
|
|
35
35
|
var ALPHANUMERIC = /[\d+-.A-Za-z]/;
|
|
36
36
|
var DIGIT = /\d/;
|
|
37
|
-
var HEX_START = /^
|
|
37
|
+
var HEX_START = /^0x/i;
|
|
38
38
|
var OCT = /^[0-7]+$/;
|
|
39
39
|
var DEC = /^\d+$/;
|
|
40
40
|
var HEX = /^[\dA-Fa-f]+$/;
|
|
41
41
|
/* eslint-disable no-control-regex -- safe */
|
|
42
|
-
var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r
|
|
43
|
-
var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r
|
|
42
|
+
var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
|
|
43
|
+
var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
|
|
44
44
|
var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g;
|
|
45
45
|
var TAB_AND_NEW_LINE = /[\t\n\r]/g;
|
|
46
46
|
/* eslint-enable no-control-regex -- safe */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-js",
|
|
3
3
|
"description": "Standard library",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.15.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/zloirock/core-js.git",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"scripts": {
|
|
56
56
|
"postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "4f7f304e7472127efc4749323c56819312fb327f"
|
|
59
59
|
}
|
package/stable/escape.js
ADDED
package/stable/index.js
CHANGED
|
@@ -47,11 +47,15 @@ require('../modules/es.array-buffer.constructor');
|
|
|
47
47
|
require('../modules/es.array-buffer.is-view');
|
|
48
48
|
require('../modules/es.array-buffer.slice');
|
|
49
49
|
require('../modules/es.data-view');
|
|
50
|
+
require('../modules/es.date.get-year');
|
|
50
51
|
require('../modules/es.date.now');
|
|
52
|
+
require('../modules/es.date.set-year');
|
|
53
|
+
require('../modules/es.date.to-gmt-string');
|
|
51
54
|
require('../modules/es.date.to-iso-string');
|
|
52
55
|
require('../modules/es.date.to-json');
|
|
53
56
|
require('../modules/es.date.to-primitive');
|
|
54
57
|
require('../modules/es.date.to-string');
|
|
58
|
+
require('../modules/es.escape');
|
|
55
59
|
require('../modules/es.function.bind');
|
|
56
60
|
require('../modules/es.function.has-instance');
|
|
57
61
|
require('../modules/es.function.name');
|
|
@@ -135,6 +139,7 @@ require('../modules/es.reflect.set');
|
|
|
135
139
|
require('../modules/es.reflect.set-prototype-of');
|
|
136
140
|
require('../modules/es.reflect.to-string-tag');
|
|
137
141
|
require('../modules/es.regexp.constructor');
|
|
142
|
+
require('../modules/es.regexp.dot-all');
|
|
138
143
|
require('../modules/es.regexp.exec');
|
|
139
144
|
require('../modules/es.regexp.flags');
|
|
140
145
|
require('../modules/es.regexp.sticky');
|
|
@@ -157,6 +162,7 @@ require('../modules/es.string.replace-all');
|
|
|
157
162
|
require('../modules/es.string.search');
|
|
158
163
|
require('../modules/es.string.split');
|
|
159
164
|
require('../modules/es.string.starts-with');
|
|
165
|
+
require('../modules/es.string.substr');
|
|
160
166
|
require('../modules/es.string.trim');
|
|
161
167
|
require('../modules/es.string.trim-end');
|
|
162
168
|
require('../modules/es.string.trim-start');
|
|
@@ -207,6 +213,7 @@ require('../modules/es.typed-array.sort');
|
|
|
207
213
|
require('../modules/es.typed-array.subarray');
|
|
208
214
|
require('../modules/es.typed-array.to-locale-string');
|
|
209
215
|
require('../modules/es.typed-array.to-string');
|
|
216
|
+
require('../modules/es.unescape');
|
|
210
217
|
require('../modules/es.weak-map');
|
|
211
218
|
require('../modules/es.weak-set');
|
|
212
219
|
require('../modules/web.dom-collections.for-each');
|