Sha256: 29286712d14217149a2da50441a650d6a234a175d287e6e91db97a124ab3e1bf

Contents?: true

Size: 1.61 KB

Versions: 15

Compression:

Stored size: 1.61 KB

Contents

'use strict';
var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
var anObject = require('../internals/an-object');
var toLength = require('../internals/to-length');
var requireObjectCoercible = require('../internals/require-object-coercible');
var advanceStringIndex = require('../internals/advance-string-index');
var regExpExec = require('../internals/regexp-exec-abstract');

// @@match logic
fixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
  return [
    // `String.prototype.match` method
    // https://tc39.github.io/ecma262/#sec-string.prototype.match
    function match(regexp) {
      var O = requireObjectCoercible(this);
      var matcher = regexp == undefined ? undefined : regexp[MATCH];
      return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
    },
    // `RegExp.prototype[@@match]` method
    // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
    function (regexp) {
      var res = maybeCallNative(nativeMatch, regexp, this);
      if (res.done) return res.value;

      var rx = anObject(regexp);
      var S = String(this);

      if (!rx.global) return regExpExec(rx, S);

      var fullUnicode = rx.unicode;
      rx.lastIndex = 0;
      var A = [];
      var n = 0;
      var result;
      while ((result = regExpExec(rx, S)) !== null) {
        var matchStr = String(result[0]);
        A[n] = matchStr;
        if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
        n++;
      }
      return n === 0 ? null : A;
    }
  ];
});

Version data entries

15 entries across 15 versions & 6 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/core-js/modules/es.string.match.js
disco_app-0.18.0 test/dummy/node_modules/core-js/modules/es.string.match.js
disco_app-0.18.2 test/dummy/node_modules/core-js/modules/es.string.match.js
tang-0.2.1 spec/tang_app/node_modules/core-js/modules/es.string.match.js
tang-0.2.0 spec/tang_app/node_modules/core-js/modules/es.string.match.js
tang-0.1.0 spec/tang_app/node_modules/core-js/modules/es.string.match.js
tang-0.0.9 spec/tang_app/node_modules/core-js/modules/es.string.match.js
enju_library-0.3.8 spec/dummy/node_modules/core-js/modules/es.string.match.js
jester-data-8.0.0 node_modules/core-js/modules/es.string.match.js
ezii-os-5.2.1 node_modules/core-js/modules/es.string.match.js
ezii-os-2.0.1 node_modules/core-js/modules/es.string.match.js
ezii-os-1.1.0 node_modules/core-js/modules/es.string.match.js
ezii-os-1.0.0 node_modules/core-js/modules/es.string.match.js
ezii-os-0.0.0.1.0 node_modules/core-js/modules/es.string.match.js
ezii-os-0.0.0.0.1 node_modules/core-js/modules/es.string.match.js