forked from daren.hsu/line_push
update
This commit is contained in:
+21
-11
@@ -1,19 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var hasPropertyDescriptors = require('has-property-descriptors');
|
||||
|
||||
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
if ($defineProperty) {
|
||||
try {
|
||||
$defineProperty({}, 'a', { value: 1 });
|
||||
} catch (e) {
|
||||
// IE 8 has a broken defineProperty
|
||||
$defineProperty = null;
|
||||
}
|
||||
}
|
||||
var $defineProperty = hasPropertyDescriptors() && GetIntrinsic('%Object.defineProperty%', true);
|
||||
|
||||
var callBound = require('../helpers/callBound');
|
||||
var hasArrayLengthDefineBug = hasPropertyDescriptors.hasArrayLengthDefineBug();
|
||||
|
||||
// eslint-disable-next-line global-require
|
||||
var isArray = hasArrayLengthDefineBug && require('../helpers/IsArray');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
||||
|
||||
@@ -40,6 +38,18 @@ module.exports = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPro
|
||||
O[P] = V; // will use [[Define]]
|
||||
return SameValue(O[P], V);
|
||||
}
|
||||
if (
|
||||
hasArrayLengthDefineBug
|
||||
&& P === 'length'
|
||||
&& '[[Value]]' in desc
|
||||
&& isArray(O)
|
||||
&& O.length !== desc['[[Value]]']
|
||||
) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
O.length = desc['[[Value]]'];
|
||||
return O.length === desc['[[Value]]'];
|
||||
}
|
||||
|
||||
$defineProperty(O, P, FromPropertyDescriptor(desc));
|
||||
return true;
|
||||
};
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Array = GetIntrinsic('%Array%');
|
||||
|
||||
// eslint-disable-next-line global-require
|
||||
var toStr = !$Array.isArray && require('call-bind/callBound')('Object.prototype.toString');
|
||||
|
||||
module.exports = $Array.isArray || function IsArray(argument) {
|
||||
return toStr(argument) === '[object Array]';
|
||||
};
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var callBind = require('./callBind');
|
||||
var callBound = require('./callBound');
|
||||
var callBind = require('call-bind');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $ownKeys = GetIntrinsic('%Reflect.ownKeys%', true);
|
||||
var $pushApply = callBind.apply(GetIntrinsic('%Array.prototype.push%'));
|
||||
|
||||
+9
-8
@@ -1,18 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
|
||||
var has = require('has');
|
||||
|
||||
var isMatchRecord = require('./isMatchRecord');
|
||||
|
||||
var predicates = {
|
||||
// https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
|
||||
'Property Descriptor': function isPropertyDescriptor(Type, Desc) {
|
||||
if (Type(Desc) !== 'Object') {
|
||||
return false;
|
||||
}
|
||||
// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type
|
||||
'Property Descriptor': function isPropertyDescriptor(Desc) {
|
||||
var allowed = {
|
||||
'[[Configurable]]': true,
|
||||
'[[Enumerable]]': true,
|
||||
@@ -34,7 +33,9 @@ var predicates = {
|
||||
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
// https://262.ecma-international.org/13.0/#sec-match-records
|
||||
'Match Record': isMatchRecord
|
||||
};
|
||||
|
||||
module.exports = function assertRecord(Type, recordType, argumentName, value) {
|
||||
@@ -42,7 +43,7 @@ module.exports = function assertRecord(Type, recordType, argumentName, value) {
|
||||
if (typeof predicate !== 'function') {
|
||||
throw new $SyntaxError('unknown record type: ' + recordType);
|
||||
}
|
||||
if (!predicate(Type, value)) {
|
||||
if (Type(value) !== 'Object' || !predicate(value)) {
|
||||
throw new $TypeError(argumentName + ' must be a ' + recordType);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var has = require('has');
|
||||
|
||||
|
||||
+2
-14
@@ -1,17 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var bind = require('function-bind');
|
||||
// TODO; semver-major: remove
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
|
||||
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
||||
var $call = GetIntrinsic('%Function.prototype.call%');
|
||||
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
||||
|
||||
module.exports = function callBind() {
|
||||
return $reflectApply(bind, $call, arguments);
|
||||
};
|
||||
|
||||
module.exports.apply = function applyBind() {
|
||||
return $reflectApply(bind, $apply, arguments);
|
||||
};
|
||||
module.exports = require('call-bind');
|
||||
|
||||
+2
-12
@@ -1,15 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
// TODO; semver-major: remove
|
||||
|
||||
var callBind = require('./callBind');
|
||||
|
||||
var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
||||
|
||||
module.exports = function callBoundIntrinsic(name, allowMissing) {
|
||||
var intrinsic = GetIntrinsic(name, !!allowMissing);
|
||||
if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.')) {
|
||||
return callBind(intrinsic);
|
||||
}
|
||||
return intrinsic;
|
||||
};
|
||||
module.exports = require('call-bind/callBound');
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function fromPropertyDescriptor(Desc) {
|
||||
if (typeof Desc === 'undefined') {
|
||||
return Desc;
|
||||
}
|
||||
var obj = {};
|
||||
if ('[[Value]]' in Desc) {
|
||||
obj.value = Desc['[[Value]]'];
|
||||
}
|
||||
if ('[[Writable]]' in Desc) {
|
||||
obj.writable = !!Desc['[[Writable]]'];
|
||||
}
|
||||
if ('[[Get]]' in Desc) {
|
||||
obj.get = Desc['[[Get]]'];
|
||||
}
|
||||
if ('[[Set]]' in Desc) {
|
||||
obj.set = Desc['[[Set]]'];
|
||||
}
|
||||
if ('[[Enumerable]]' in Desc) {
|
||||
obj.enumerable = !!Desc['[[Enumerable]]'];
|
||||
}
|
||||
if ('[[Configurable]]' in Desc) {
|
||||
obj.configurable = !!Desc['[[Configurable]]'];
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
+2
-8
@@ -1,10 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var getInferredName;
|
||||
try {
|
||||
// eslint-disable-next-line no-new-func
|
||||
getInferredName = Function('s', 'return { [s]() {} }[s].name;');
|
||||
} catch (e) {}
|
||||
|
||||
var inferred = function () {};
|
||||
module.exports = getInferredName && inferred.name === 'inferred' ? getInferredName : null;
|
||||
// TODO: remove, semver-major
|
||||
module.exports = require('get-symbol-description/getInferredName');
|
||||
|
||||
+6
-4
@@ -1,11 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var hasSymbols = require('has-symbols')();
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var callBound = require('./callBound');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
var isString = require('is-string');
|
||||
|
||||
var $iterator = GetIntrinsic('%Symbol.iterator%', true);
|
||||
var $stringSlice = callBound('String.prototype.slice');
|
||||
var $String = GetIntrinsic('%String%', true);
|
||||
|
||||
module.exports = function getIteratorMethod(ES, iterable) {
|
||||
var usingIterator;
|
||||
@@ -25,12 +27,12 @@ module.exports = function getIteratorMethod(ES, iterable) {
|
||||
}
|
||||
};
|
||||
};
|
||||
} else if (ES.Type(iterable) === 'String') {
|
||||
} else if (isString(iterable)) {
|
||||
usingIterator = function () {
|
||||
var i = 0;
|
||||
return {
|
||||
next: function () {
|
||||
var nextIndex = ES.AdvanceStringIndex(iterable, i, true);
|
||||
var nextIndex = ES.AdvanceStringIndex($String(iterable), i, true);
|
||||
var value = $stringSlice(iterable, i, nextIndex);
|
||||
i = nextIndex;
|
||||
return {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%');
|
||||
var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
||||
if ($gOPD) {
|
||||
try {
|
||||
$gOPD([], 'length');
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var originalGetProto = GetIntrinsic('%Object.getPrototypeOf%', true);
|
||||
var $ArrayProto = GetIntrinsic('%Array.prototype%');
|
||||
|
||||
+2
-39
@@ -1,41 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
|
||||
var callBound = require('./callBound');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var getGlobalSymbolDescription = GetIntrinsic('%Symbol.keyFor%', true);
|
||||
var thisSymbolValue = callBound('%Symbol.prototype.valueOf%', true);
|
||||
var symToStr = callBound('Symbol.prototype.toString', true);
|
||||
|
||||
var getInferredName = require('./getInferredName');
|
||||
|
||||
/* eslint-disable consistent-return */
|
||||
module.exports = callBound('%Symbol.prototype.description%', true) || function getSymbolDescription(symbol) {
|
||||
if (!thisSymbolValue) {
|
||||
throw new $SyntaxError('Symbols are not supported in this environment');
|
||||
}
|
||||
|
||||
// will throw if not a symbol primitive or wrapper object
|
||||
var sym = thisSymbolValue(symbol);
|
||||
|
||||
if (getInferredName) {
|
||||
var name = getInferredName(sym);
|
||||
if (name === '') { return; }
|
||||
return name.slice(1, -1); // name.slice('['.length, -']'.length);
|
||||
}
|
||||
|
||||
var desc;
|
||||
if (getGlobalSymbolDescription) {
|
||||
desc = getGlobalSymbolDescription(sym);
|
||||
if (typeof desc === 'string') {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
desc = symToStr(sym).slice(7, -1); // str.slice('Symbol('.length, -')'.length);
|
||||
if (desc) {
|
||||
return desc;
|
||||
}
|
||||
};
|
||||
// TODO: remove, semver-major
|
||||
module.exports = require('get-symbol-description');
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var functionName = require('function.prototype.name');
|
||||
|
||||
var anon = functionName(function () {});
|
||||
|
||||
module.exports = function isAbstractClosure(x) {
|
||||
return typeof x === 'function' && (!x.prototype || functionName(x) === anon);
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function isByteValue(value) {
|
||||
return typeof value === 'number' && value >= 0 && value <= 255 && (value | 0) === value;
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function isCodePoint(cp) {
|
||||
return typeof cp === 'number' && cp >= 0 && cp <= 0x10FFFF && (cp | 0) === cp;
|
||||
};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function isFullyPopulatedPropertyDescriptor(ES, Desc) {
|
||||
return '[[Enumerable]]' in Desc
|
||||
&& '[[Configurable]]' in Desc
|
||||
&& (ES.IsAccessorDescriptor(Desc) || ES.IsDataDescriptor(Desc));
|
||||
};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function isLeadingSurrogate(charCode) {
|
||||
return typeof charCode === 'number' && charCode >= 0xD800 && charCode <= 0xDBFF;
|
||||
};
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
var has = require('has');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-match-records
|
||||
|
||||
module.exports = function isMatchRecord(record) {
|
||||
return (
|
||||
has(record, '[[StartIndex]]')
|
||||
&& has(record, '[[EndIndex]]')
|
||||
&& record['[[StartIndex]]'] >= 0
|
||||
&& record['[[EndIndex]]'] >= record['[[StartIndex]]']
|
||||
&& String(parseInt(record['[[StartIndex]]'], 10)) === String(record['[[StartIndex]]'])
|
||||
&& String(parseInt(record['[[EndIndex]]'], 10)) === String(record['[[EndIndex]]'])
|
||||
);
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var $strSlice = require('../helpers/callBound')('String.prototype.slice');
|
||||
var $strSlice = require('call-bind/callBound')('String.prototype.slice');
|
||||
|
||||
module.exports = function isPrefixOf(prefix, string) {
|
||||
if (prefix === string) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var has = require('has');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function isTrailingSurrogate(charCode) {
|
||||
return typeof charCode === 'number' && charCode >= 0xDC00 && charCode <= 0xDFFF;
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $Math = GetIntrinsic('%Math%');
|
||||
var $Number = GetIntrinsic('%Number%');
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function bigIntMod(BigIntRemainder, bigint, modulo) {
|
||||
var remain = BigIntRemainder(bigint, modulo);
|
||||
return remain >= 0 ? remain : remain + modulo;
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var callBound = require('../helpers/callBound');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $strSlice = callBound('String.prototype.slice');
|
||||
|
||||
|
||||
+3
-5
@@ -1,11 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var callBound = require('call-bind/callBound');
|
||||
|
||||
var $test = GetIntrinsic('RegExp.prototype.test');
|
||||
|
||||
var callBind = require('./callBind');
|
||||
var $exec = callBound('RegExp.prototype.exec');
|
||||
|
||||
module.exports = function regexTester(regex) {
|
||||
return callBind($test, regex);
|
||||
return function test(s) { return $exec(regex, s) !== null; };
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('../GetIntrinsic');
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var originalSetProto = GetIntrinsic('%Object.setPrototypeOf%', true);
|
||||
var $ArrayProto = GetIntrinsic('%Array.prototype%');
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function some(array, predicate) {
|
||||
for (var i = 0; i < array.length; i += 1) {
|
||||
if (predicate(array[i], i, array)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user