core-js 2.5.4 → 2.6.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +62 -62
  3. package/bower.json +1 -1
  4. package/build/config.js +1 -0
  5. package/client/core.js +1392 -961
  6. package/client/core.min.js +4 -4
  7. package/client/core.min.js.map +1 -1
  8. package/client/library.js +342 -316
  9. package/client/library.min.js +4 -4
  10. package/client/library.min.js.map +1 -1
  11. package/client/shim.js +1240 -911
  12. package/client/shim.min.js +4 -4
  13. package/client/shim.min.js.map +1 -1
  14. package/es6/index.js +1 -0
  15. package/es6/regexp.js +1 -0
  16. package/fn/regexp/index.js +1 -0
  17. package/library/es6/index.js +1 -0
  18. package/library/es6/regexp.js +1 -0
  19. package/library/fn/regexp/index.js +1 -0
  20. package/library/modules/_advance-string-index.js +8 -0
  21. package/library/modules/_core.js +1 -1
  22. package/library/modules/_fix-re-wks.js +74 -6
  23. package/library/modules/_microtask.js +2 -1
  24. package/library/modules/_regexp-exec-abstract.js +1 -0
  25. package/library/modules/_regexp-exec.js +1 -0
  26. package/library/modules/_shared.js +9 -3
  27. package/library/modules/es6.promise.js +10 -1
  28. package/library/modules/es6.reflect.set.js +5 -3
  29. package/library/modules/es6.regexp.exec.js +1 -0
  30. package/library/modules/es6.typed.array-buffer.js +3 -3
  31. package/library/shim.js +1 -0
  32. package/modules/_advance-string-index.js +8 -0
  33. package/modules/_core.js +1 -1
  34. package/modules/_fix-re-wks.js +74 -6
  35. package/modules/_microtask.js +2 -1
  36. package/modules/_regexp-exec-abstract.js +21 -0
  37. package/modules/_regexp-exec.js +58 -0
  38. package/modules/_shared.js +9 -3
  39. package/modules/es6.promise.js +10 -1
  40. package/modules/es6.reflect.set.js +5 -3
  41. package/modules/es6.regexp.exec.js +9 -0
  42. package/modules/es6.regexp.match.js +38 -8
  43. package/modules/es6.regexp.replace.js +116 -10
  44. package/modules/es6.regexp.search.js +29 -8
  45. package/modules/es6.regexp.split.js +89 -30
  46. package/modules/es6.typed.array-buffer.js +3 -3
  47. package/modules/library/_regexp-exec-abstract.js +1 -0
  48. package/modules/library/_regexp-exec.js +1 -0
  49. package/modules/library/es6.regexp.exec.js +1 -0
  50. package/package.json +3 -3
  51. package/shim.js +1 -0
package/es6/index.js CHANGED
@@ -99,6 +99,7 @@ require('../modules/es6.array.find-index');
99
99
  require('../modules/es6.array.species');
100
100
  require('../modules/es6.array.iterator');
101
101
  require('../modules/es6.regexp.constructor');
102
+ require('../modules/es6.regexp.exec');
102
103
  require('../modules/es6.regexp.to-string');
103
104
  require('../modules/es6.regexp.flags');
104
105
  require('../modules/es6.regexp.match');
package/es6/regexp.js CHANGED
@@ -1,4 +1,5 @@
1
1
  require('../modules/es6.regexp.constructor');
2
+ require('../modules/es6.regexp.exec');
2
3
  require('../modules/es6.regexp.to-string');
3
4
  require('../modules/es6.regexp.flags');
4
5
  require('../modules/es6.regexp.match');
@@ -1,4 +1,5 @@
1
1
  require('../../modules/es6.regexp.constructor');
2
+ require('../../modules/es6.regexp.exec');
2
3
  require('../../modules/es6.regexp.to-string');
3
4
  require('../../modules/es6.regexp.flags');
4
5
  require('../../modules/es6.regexp.match');
@@ -99,6 +99,7 @@ require('../modules/es6.array.find-index');
99
99
  require('../modules/es6.array.species');
100
100
  require('../modules/es6.array.iterator');
101
101
  require('../modules/es6.regexp.constructor');
102
+ require('../modules/es6.regexp.exec');
102
103
  require('../modules/es6.regexp.to-string');
103
104
  require('../modules/es6.regexp.flags');
104
105
  require('../modules/es6.regexp.match');
@@ -1,4 +1,5 @@
1
1
  require('../modules/es6.regexp.constructor');
2
+ require('../modules/es6.regexp.exec');
2
3
  require('../modules/es6.regexp.to-string');
3
4
  require('../modules/es6.regexp.flags');
4
5
  require('../modules/es6.regexp.match');
@@ -1,4 +1,5 @@
1
1
  require('../../modules/es6.regexp.constructor');
2
+ require('../../modules/es6.regexp.exec');
2
3
  require('../../modules/es6.regexp.to-string');
3
4
  require('../../modules/es6.regexp.flags');
4
5
  require('../../modules/es6.regexp.match');
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var at = require('./_string-at')(true);
3
+
4
+ // `AdvanceStringIndex` abstract operation
5
+ // https://tc39.github.io/ecma262/#sec-advancestringindex
6
+ module.exports = function (S, index, unicode) {
7
+ return index + (unicode ? at(S, index).length : 1);
8
+ };
@@ -1,2 +1,2 @@
1
- var core = module.exports = { version: '2.5.4' };
1
+ var core = module.exports = { version: '2.6.0' };
2
2
  if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
@@ -1,20 +1,88 @@
1
1
  'use strict';
2
- var hide = require('./_hide');
2
+ require('./es6.regexp.exec');
3
3
  var redefine = require('./_redefine');
4
+ var hide = require('./_hide');
4
5
  var fails = require('./_fails');
5
6
  var defined = require('./_defined');
6
7
  var wks = require('./_wks');
8
+ var regexpExec = require('./_regexp-exec');
9
+
10
+ var SPECIES = wks('species');
11
+
12
+ var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
13
+ // #replace needs built-in support for named groups.
14
+ // #match works fine because it just return the exec results, even if it has
15
+ // a "grops" property.
16
+ var re = /./;
17
+ re.exec = function () {
18
+ var result = [];
19
+ result.groups = { a: '7' };
20
+ return result;
21
+ };
22
+ return ''.replace(re, '$<a>') !== '7';
23
+ });
24
+
25
+ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () {
26
+ // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
27
+ var re = /(?:)/;
28
+ var originalExec = re.exec;
29
+ re.exec = function () { return originalExec.apply(this, arguments); };
30
+ var result = 'ab'.split(re);
31
+ return result.length === 2 && result[0] === 'a' && result[1] === 'b';
32
+ })();
7
33
 
8
34
  module.exports = function (KEY, length, exec) {
9
35
  var SYMBOL = wks(KEY);
10
- var fns = exec(defined, SYMBOL, ''[KEY]);
11
- var strfn = fns[0];
12
- var rxfn = fns[1];
13
- if (fails(function () {
36
+
37
+ var DELEGATES_TO_SYMBOL = !fails(function () {
38
+ // String methods call symbol-named RegEp methods
14
39
  var O = {};
15
40
  O[SYMBOL] = function () { return 7; };
16
41
  return ''[KEY](O) != 7;
17
- })) {
42
+ });
43
+
44
+ var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !fails(function () {
45
+ // Symbol-named RegExp methods call .exec
46
+ var execCalled = false;
47
+ var re = /a/;
48
+ re.exec = function () { execCalled = true; return null; };
49
+ if (KEY === 'split') {
50
+ // RegExp[@@split] doesn't call the regex's exec method, but first creates
51
+ // a new one. We need to return the patched regex when creating the new one.
52
+ re.constructor = {};
53
+ re.constructor[SPECIES] = function () { return re; };
54
+ }
55
+ re[SYMBOL]('');
56
+ return !execCalled;
57
+ }) : undefined;
58
+
59
+ if (
60
+ !DELEGATES_TO_SYMBOL ||
61
+ !DELEGATES_TO_EXEC ||
62
+ (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
63
+ (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
64
+ ) {
65
+ var nativeRegExpMethod = /./[SYMBOL];
66
+ var fns = exec(
67
+ defined,
68
+ SYMBOL,
69
+ ''[KEY],
70
+ function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
71
+ if (regexp.exec === regexpExec) {
72
+ if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
73
+ // The native String method already delegates to @@method (this
74
+ // polyfilled function), leasing to infinite recursion.
75
+ // We avoid it by directly calling the native @@method method.
76
+ return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
77
+ }
78
+ return { done: true, value: nativeMethod.call(str, regexp, arg2) };
79
+ }
80
+ return { done: false };
81
+ }
82
+ );
83
+ var strfn = fns[0];
84
+ var rxfn = fns[1];
85
+
18
86
  redefine(String.prototype, KEY, strfn);
19
87
  hide(RegExp.prototype, SYMBOL, length == 2
20
88
  // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
@@ -40,7 +40,8 @@ module.exports = function () {
40
40
  };
41
41
  // environments with maybe non-completely correct, but existent Promise
42
42
  } else if (Promise && Promise.resolve) {
43
- var promise = Promise.resolve();
43
+ // Promise.resolve without an argument throws an error in LG WebOS 2
44
+ var promise = Promise.resolve(undefined);
44
45
  notify = function () {
45
46
  promise.then(flush);
46
47
  };
@@ -0,0 +1 @@
1
+ // empty
@@ -0,0 +1 @@
1
+ // empty
@@ -1,6 +1,12 @@
1
+ var core = require('./_core');
1
2
  var global = require('./_global');
2
3
  var SHARED = '__core-js_shared__';
3
4
  var store = global[SHARED] || (global[SHARED] = {});
4
- module.exports = function (key) {
5
- return store[key] || (store[key] = {});
6
- };
5
+
6
+ (module.exports = function (key, value) {
7
+ return store[key] || (store[key] = value !== undefined ? value : {});
8
+ })('versions', []).push({
9
+ version: core.version,
10
+ mode: require('./_library') ? 'pure' : 'global',
11
+ copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
12
+ });
@@ -13,10 +13,13 @@ var task = require('./_task').set;
13
13
  var microtask = require('./_microtask')();
14
14
  var newPromiseCapabilityModule = require('./_new-promise-capability');
15
15
  var perform = require('./_perform');
16
+ var userAgent = require('./_user-agent');
16
17
  var promiseResolve = require('./_promise-resolve');
17
18
  var PROMISE = 'Promise';
18
19
  var TypeError = global.TypeError;
19
20
  var process = global.process;
21
+ var versions = process && process.versions;
22
+ var v8 = versions && versions.v8 || '';
20
23
  var $Promise = global[PROMISE];
21
24
  var isNode = classof(process) == 'process';
22
25
  var empty = function () { /* empty */ };
@@ -31,7 +34,13 @@ var USE_NATIVE = !!function () {
31
34
  exec(empty, empty);
32
35
  };
33
36
  // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
34
- return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
37
+ return (isNode || typeof PromiseRejectionEvent == 'function')
38
+ && promise.then(empty) instanceof FakePromise
39
+ // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
40
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
41
+ // we can't detect it synchronously, so just check versions
42
+ && v8.indexOf('6.6') !== 0
43
+ && userAgent.indexOf('Chrome/66') === -1;
35
44
  } catch (e) { /* empty */ }
36
45
  }();
37
46
 
@@ -20,9 +20,11 @@ function set(target, propertyKey, V /* , receiver */) {
20
20
  }
21
21
  if (has(ownDesc, 'value')) {
22
22
  if (ownDesc.writable === false || !isObject(receiver)) return false;
23
- existingDescriptor = gOPD.f(receiver, propertyKey) || createDesc(0);
24
- existingDescriptor.value = V;
25
- dP.f(receiver, propertyKey, existingDescriptor);
23
+ if (existingDescriptor = gOPD.f(receiver, propertyKey)) {
24
+ if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
25
+ existingDescriptor.value = V;
26
+ dP.f(receiver, propertyKey, existingDescriptor);
27
+ } else dP.f(receiver, propertyKey, createDesc(0, V));
26
28
  return true;
27
29
  }
28
30
  return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
@@ -0,0 +1 @@
1
+ // empty
@@ -32,12 +32,12 @@ $export($export.P + $export.U + $export.F * require('./_fails')(function () {
32
32
  if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix
33
33
  var len = anObject(this).byteLength;
34
34
  var first = toAbsoluteIndex(start, len);
35
- var final = toAbsoluteIndex(end === undefined ? len : end, len);
36
- var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(final - first));
35
+ var fin = toAbsoluteIndex(end === undefined ? len : end, len);
36
+ var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(fin - first));
37
37
  var viewS = new $DataView(this);
38
38
  var viewT = new $DataView(result);
39
39
  var index = 0;
40
- while (first < final) {
40
+ while (first < fin) {
41
41
  viewT.setUint8(index++, viewS.getUint8(first++));
42
42
  } return result;
43
43
  }
package/library/shim.js CHANGED
@@ -99,6 +99,7 @@ require('./modules/es6.array.find-index');
99
99
  require('./modules/es6.array.species');
100
100
  require('./modules/es6.array.iterator');
101
101
  require('./modules/es6.regexp.constructor');
102
+ require('./modules/es6.regexp.exec');
102
103
  require('./modules/es6.regexp.to-string');
103
104
  require('./modules/es6.regexp.flags');
104
105
  require('./modules/es6.regexp.match');
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var at = require('./_string-at')(true);
3
+
4
+ // `AdvanceStringIndex` abstract operation
5
+ // https://tc39.github.io/ecma262/#sec-advancestringindex
6
+ module.exports = function (S, index, unicode) {
7
+ return index + (unicode ? at(S, index).length : 1);
8
+ };
package/modules/_core.js CHANGED
@@ -1,2 +1,2 @@
1
- var core = module.exports = { version: '2.5.4' };
1
+ var core = module.exports = { version: '2.6.0' };
2
2
  if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
@@ -1,20 +1,88 @@
1
1
  'use strict';
2
- var hide = require('./_hide');
2
+ require('./es6.regexp.exec');
3
3
  var redefine = require('./_redefine');
4
+ var hide = require('./_hide');
4
5
  var fails = require('./_fails');
5
6
  var defined = require('./_defined');
6
7
  var wks = require('./_wks');
8
+ var regexpExec = require('./_regexp-exec');
9
+
10
+ var SPECIES = wks('species');
11
+
12
+ var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
13
+ // #replace needs built-in support for named groups.
14
+ // #match works fine because it just return the exec results, even if it has
15
+ // a "grops" property.
16
+ var re = /./;
17
+ re.exec = function () {
18
+ var result = [];
19
+ result.groups = { a: '7' };
20
+ return result;
21
+ };
22
+ return ''.replace(re, '$<a>') !== '7';
23
+ });
24
+
25
+ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () {
26
+ // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
27
+ var re = /(?:)/;
28
+ var originalExec = re.exec;
29
+ re.exec = function () { return originalExec.apply(this, arguments); };
30
+ var result = 'ab'.split(re);
31
+ return result.length === 2 && result[0] === 'a' && result[1] === 'b';
32
+ })();
7
33
 
8
34
  module.exports = function (KEY, length, exec) {
9
35
  var SYMBOL = wks(KEY);
10
- var fns = exec(defined, SYMBOL, ''[KEY]);
11
- var strfn = fns[0];
12
- var rxfn = fns[1];
13
- if (fails(function () {
36
+
37
+ var DELEGATES_TO_SYMBOL = !fails(function () {
38
+ // String methods call symbol-named RegEp methods
14
39
  var O = {};
15
40
  O[SYMBOL] = function () { return 7; };
16
41
  return ''[KEY](O) != 7;
17
- })) {
42
+ });
43
+
44
+ var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !fails(function () {
45
+ // Symbol-named RegExp methods call .exec
46
+ var execCalled = false;
47
+ var re = /a/;
48
+ re.exec = function () { execCalled = true; return null; };
49
+ if (KEY === 'split') {
50
+ // RegExp[@@split] doesn't call the regex's exec method, but first creates
51
+ // a new one. We need to return the patched regex when creating the new one.
52
+ re.constructor = {};
53
+ re.constructor[SPECIES] = function () { return re; };
54
+ }
55
+ re[SYMBOL]('');
56
+ return !execCalled;
57
+ }) : undefined;
58
+
59
+ if (
60
+ !DELEGATES_TO_SYMBOL ||
61
+ !DELEGATES_TO_EXEC ||
62
+ (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
63
+ (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
64
+ ) {
65
+ var nativeRegExpMethod = /./[SYMBOL];
66
+ var fns = exec(
67
+ defined,
68
+ SYMBOL,
69
+ ''[KEY],
70
+ function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
71
+ if (regexp.exec === regexpExec) {
72
+ if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
73
+ // The native String method already delegates to @@method (this
74
+ // polyfilled function), leasing to infinite recursion.
75
+ // We avoid it by directly calling the native @@method method.
76
+ return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
77
+ }
78
+ return { done: true, value: nativeMethod.call(str, regexp, arg2) };
79
+ }
80
+ return { done: false };
81
+ }
82
+ );
83
+ var strfn = fns[0];
84
+ var rxfn = fns[1];
85
+
18
86
  redefine(String.prototype, KEY, strfn);
19
87
  hide(RegExp.prototype, SYMBOL, length == 2
20
88
  // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
@@ -40,7 +40,8 @@ module.exports = function () {
40
40
  };
41
41
  // environments with maybe non-completely correct, but existent Promise
42
42
  } else if (Promise && Promise.resolve) {
43
- var promise = Promise.resolve();
43
+ // Promise.resolve without an argument throws an error in LG WebOS 2
44
+ var promise = Promise.resolve(undefined);
44
45
  notify = function () {
45
46
  promise.then(flush);
46
47
  };
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var classof = require('./_classof');
4
+ var builtinExec = RegExp.prototype.exec;
5
+
6
+ // `RegExpExec` abstract operation
7
+ // https://tc39.github.io/ecma262/#sec-regexpexec
8
+ module.exports = function (R, S) {
9
+ var exec = R.exec;
10
+ if (typeof exec === 'function') {
11
+ var result = exec.call(R, S);
12
+ if (typeof result !== 'object') {
13
+ throw new TypeError('RegExp exec method returned something other than an Object or null');
14
+ }
15
+ return result;
16
+ }
17
+ if (classof(R) !== 'RegExp') {
18
+ throw new TypeError('RegExp#exec called on incompatible receiver');
19
+ }
20
+ return builtinExec.call(R, S);
21
+ };
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var regexpFlags = require('./_flags');
4
+
5
+ var nativeExec = RegExp.prototype.exec;
6
+ // This always refers to the native implementation, because the
7
+ // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
8
+ // which loads this file before patching the method.
9
+ var nativeReplace = String.prototype.replace;
10
+
11
+ var patchedExec = nativeExec;
12
+
13
+ var LAST_INDEX = 'lastIndex';
14
+
15
+ var UPDATES_LAST_INDEX_WRONG = (function () {
16
+ var re1 = /a/,
17
+ re2 = /b*/g;
18
+ nativeExec.call(re1, 'a');
19
+ nativeExec.call(re2, 'a');
20
+ return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
21
+ })();
22
+
23
+ // nonparticipating capturing group, copied from es5-shim's String#split patch.
24
+ var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
25
+
26
+ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
27
+
28
+ if (PATCH) {
29
+ patchedExec = function exec(str) {
30
+ var re = this;
31
+ var lastIndex, reCopy, match, i;
32
+
33
+ if (NPCG_INCLUDED) {
34
+ reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
35
+ }
36
+ if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
37
+
38
+ match = nativeExec.call(re, str);
39
+
40
+ if (UPDATES_LAST_INDEX_WRONG && match) {
41
+ re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
42
+ }
43
+ if (NPCG_INCLUDED && match && match.length > 1) {
44
+ // Fix browsers whose `exec` methods don't consistently return `undefined`
45
+ // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
46
+ // eslint-disable-next-line no-loop-func
47
+ nativeReplace.call(match[0], reCopy, function () {
48
+ for (i = 1; i < arguments.length - 2; i++) {
49
+ if (arguments[i] === undefined) match[i] = undefined;
50
+ }
51
+ });
52
+ }
53
+
54
+ return match;
55
+ };
56
+ }
57
+
58
+ module.exports = patchedExec;
@@ -1,6 +1,12 @@
1
+ var core = require('./_core');
1
2
  var global = require('./_global');
2
3
  var SHARED = '__core-js_shared__';
3
4
  var store = global[SHARED] || (global[SHARED] = {});
4
- module.exports = function (key) {
5
- return store[key] || (store[key] = {});
6
- };
5
+
6
+ (module.exports = function (key, value) {
7
+ return store[key] || (store[key] = value !== undefined ? value : {});
8
+ })('versions', []).push({
9
+ version: core.version,
10
+ mode: require('./_library') ? 'pure' : 'global',
11
+ copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
12
+ });
@@ -13,10 +13,13 @@ var task = require('./_task').set;
13
13
  var microtask = require('./_microtask')();
14
14
  var newPromiseCapabilityModule = require('./_new-promise-capability');
15
15
  var perform = require('./_perform');
16
+ var userAgent = require('./_user-agent');
16
17
  var promiseResolve = require('./_promise-resolve');
17
18
  var PROMISE = 'Promise';
18
19
  var TypeError = global.TypeError;
19
20
  var process = global.process;
21
+ var versions = process && process.versions;
22
+ var v8 = versions && versions.v8 || '';
20
23
  var $Promise = global[PROMISE];
21
24
  var isNode = classof(process) == 'process';
22
25
  var empty = function () { /* empty */ };
@@ -31,7 +34,13 @@ var USE_NATIVE = !!function () {
31
34
  exec(empty, empty);
32
35
  };
33
36
  // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
34
- return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
37
+ return (isNode || typeof PromiseRejectionEvent == 'function')
38
+ && promise.then(empty) instanceof FakePromise
39
+ // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
40
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
41
+ // we can't detect it synchronously, so just check versions
42
+ && v8.indexOf('6.6') !== 0
43
+ && userAgent.indexOf('Chrome/66') === -1;
35
44
  } catch (e) { /* empty */ }
36
45
  }();
37
46
 
@@ -20,9 +20,11 @@ function set(target, propertyKey, V /* , receiver */) {
20
20
  }
21
21
  if (has(ownDesc, 'value')) {
22
22
  if (ownDesc.writable === false || !isObject(receiver)) return false;
23
- existingDescriptor = gOPD.f(receiver, propertyKey) || createDesc(0);
24
- existingDescriptor.value = V;
25
- dP.f(receiver, propertyKey, existingDescriptor);
23
+ if (existingDescriptor = gOPD.f(receiver, propertyKey)) {
24
+ if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
25
+ existingDescriptor.value = V;
26
+ dP.f(receiver, propertyKey, existingDescriptor);
27
+ } else dP.f(receiver, propertyKey, createDesc(0, V));
26
28
  return true;
27
29
  }
28
30
  return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+ var regexpExec = require('./_regexp-exec');
3
+ require('./_export')({
4
+ target: 'RegExp',
5
+ proto: true,
6
+ forced: regexpExec !== /./.exec
7
+ }, {
8
+ exec: regexpExec
9
+ });
@@ -1,10 +1,40 @@
1
+ 'use strict';
2
+
3
+ var anObject = require('./_an-object');
4
+ var toLength = require('./_to-length');
5
+ var advanceStringIndex = require('./_advance-string-index');
6
+ var regExpExec = require('./_regexp-exec-abstract');
7
+
1
8
  // @@match logic
2
- require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match) {
3
- // 21.1.3.11 String.prototype.match(regexp)
4
- return [function match(regexp) {
5
- 'use strict';
6
- var O = defined(this);
7
- var fn = regexp == undefined ? undefined : regexp[MATCH];
8
- return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
9
- }, $match];
9
+ require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCallNative) {
10
+ return [
11
+ // `String.prototype.match` method
12
+ // https://tc39.github.io/ecma262/#sec-string.prototype.match
13
+ function match(regexp) {
14
+ var O = defined(this);
15
+ var fn = regexp == undefined ? undefined : regexp[MATCH];
16
+ return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
17
+ },
18
+ // `RegExp.prototype[@@match]` method
19
+ // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
20
+ function (regexp) {
21
+ var res = maybeCallNative($match, regexp, this);
22
+ if (res.done) return res.value;
23
+ var rx = anObject(regexp);
24
+ var S = String(this);
25
+ if (!rx.global) return regExpExec(rx, S);
26
+ var fullUnicode = rx.unicode;
27
+ rx.lastIndex = 0;
28
+ var A = [];
29
+ var n = 0;
30
+ var result;
31
+ while ((result = regExpExec(rx, S)) !== null) {
32
+ var matchStr = String(result[0]);
33
+ A[n] = matchStr;
34
+ if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
35
+ n++;
36
+ }
37
+ return n === 0 ? null : A;
38
+ }
39
+ ];
10
40
  });