From 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Wed, 18 Nov 2020 23:26:45 +0100 Subject: rm node_modules --- node_modules/es-abstract/2017/GetSubstitution.js | 104 ----------------------- 1 file changed, 104 deletions(-) delete mode 100644 node_modules/es-abstract/2017/GetSubstitution.js (limited to 'node_modules/es-abstract/2017/GetSubstitution.js') diff --git a/node_modules/es-abstract/2017/GetSubstitution.js b/node_modules/es-abstract/2017/GetSubstitution.js deleted file mode 100644 index de41b01..0000000 --- a/node_modules/es-abstract/2017/GetSubstitution.js +++ /dev/null @@ -1,104 +0,0 @@ - -'use strict'; - -var GetIntrinsic = require('../GetIntrinsic'); - -var $TypeError = GetIntrinsic('%TypeError%'); -var $parseInt = GetIntrinsic('%parseInt%'); - -var inspect = require('object-inspect'); - -var regexTester = require('../helpers/regexTester'); -var callBound = require('../helpers/callBound'); -var every = require('../helpers/every'); - -var isDigit = regexTester(/^[0-9]$/); - -var $charAt = callBound('String.prototype.charAt'); -var $strSlice = callBound('String.prototype.slice'); - -var IsArray = require('./IsArray'); -var IsInteger = require('./IsInteger'); -var Type = require('./Type'); - -var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false - -var isStringOrHole = function (capture, index, arr) { - return Type(capture) === 'String' || (canDistinguishSparseFromUndefined ? !(index in arr) : Type(capture) === 'Undefined'); -}; - -// https://www.ecma-international.org/ecma-262/6.0/#sec-getsubstitution - -// eslint-disable-next-line max-statements, max-params, max-lines-per-function -module.exports = function GetSubstitution(matched, str, position, captures, replacement) { - if (Type(matched) !== 'String') { - throw new $TypeError('Assertion failed: `matched` must be a String'); - } - var matchLength = matched.length; - - if (Type(str) !== 'String') { - throw new $TypeError('Assertion failed: `str` must be a String'); - } - var stringLength = str.length; - - if (!IsInteger(position) || position < 0 || position > stringLength) { - throw new $TypeError('Assertion failed: `position` must be a nonnegative integer, and less than or equal to the length of `string`, got ' + inspect(position)); - } - - if (!IsArray(captures) || !every(captures, isStringOrHole)) { - throw new $TypeError('Assertion failed: `captures` must be a List of Strings, got ' + inspect(captures)); - } - - if (Type(replacement) !== 'String') { - throw new $TypeError('Assertion failed: `replacement` must be a String'); - } - - var tailPos = position + matchLength; - var m = captures.length; - - var result = ''; - for (var i = 0; i < replacement.length; i += 1) { - // if this is a $, and it's not the end of the replacement - var current = $charAt(replacement, i); - var isLast = (i + 1) >= replacement.length; - var nextIsLast = (i + 2) >= replacement.length; - if (current === '$' && !isLast) { - var next = $charAt(replacement, i + 1); - if (next === '$') { - result += '$'; - i += 1; - } else if (next === '&') { - result += matched; - i += 1; - } else if (next === '`') { - result += position === 0 ? '' : $strSlice(str, 0, position - 1); - i += 1; - } else if (next === "'") { - result += tailPos >= stringLength ? '' : $strSlice(str, tailPos); - i += 1; - } else { - var nextNext = nextIsLast ? null : $charAt(replacement, i + 2); - if (isDigit(next) && next !== '0' && (nextIsLast || !isDigit(nextNext))) { - // $1 through $9, and not followed by a digit - var n = $parseInt(next, 10); - // if (n > m, impl-defined) - result += (n <= m && Type(captures[n - 1]) === 'Undefined') ? '' : captures[n - 1]; - i += 1; - } else if (isDigit(next) && (nextIsLast || isDigit(nextNext))) { - // $00 through $99 - var nn = next + nextNext; - var nnI = $parseInt(nn, 10) - 1; - // if nn === '00' or nn > m, impl-defined - result += (nn <= m && Type(captures[nnI]) === 'Undefined') ? '' : captures[nnI]; - i += 2; - } else { - result += '$'; - } - } - } else { - // the final $, or else not a $ - result += $charAt(replacement, i); - } - } - return result; -}; -- cgit v1.2.3