es-abstract
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -126,3 +126,3 @@ { | ||
"disallowMultiLineTernary": true, | ||
"disallowMultiLineTernary": false, | ||
@@ -156,5 +156,3 @@ "validateOrderInObjectKeys": false, | ||
"requireCapitalizedConstructorsNew": { | ||
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] | ||
}, | ||
"requireCapitalizedConstructorsNew": false, | ||
@@ -161,0 +159,0 @@ "requireImportAlphabetized": false, |
@@ -0,1 +1,7 @@ | ||
1.12.0 / 2018-05-31 | ||
================= | ||
* [New] add `GetIntrinsic` entry point | ||
* [New] `ES2015`+: add `ObjectCreate` | ||
* [Robustness]: `ES2015+`: ensure `Math.{abs,floor}` and `Function.call` are cached | ||
1.11.0 / 2018-03-21 | ||
@@ -2,0 +8,0 @@ ================= |
260
es2015.js
@@ -6,9 +6,18 @@ 'use strict'; | ||
var toStr = Object.prototype.toString; | ||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; | ||
var SymbolIterator = hasSymbols ? Symbol.iterator : null; | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $SyntaxError = GetIntrinsic('%SyntaxError%'); | ||
var $Array = GetIntrinsic('%Array%'); | ||
var $String = GetIntrinsic('%String%'); | ||
var $Object = GetIntrinsic('%Object%'); | ||
var $Number = GetIntrinsic('%Number%'); | ||
var $Symbol = GetIntrinsic('%Symbol%', true); | ||
var $RegExp = GetIntrinsic('%RegExp%'); | ||
var hasSymbols = !!$Symbol; | ||
var $isNaN = require('./helpers/isNaN'); | ||
var $isFinite = require('./helpers/isFinite'); | ||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; | ||
var MAX_SAFE_INTEGER = $Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; | ||
@@ -21,13 +30,24 @@ var assign = require('./helpers/assign'); | ||
var bind = require('function-bind'); | ||
var arraySlice = bind.call(Function.call, Array.prototype.slice); | ||
var strSlice = bind.call(Function.call, String.prototype.slice); | ||
var isBinary = bind.call(Function.call, RegExp.prototype.test, /^0b[01]+$/i); | ||
var isOctal = bind.call(Function.call, RegExp.prototype.test, /^0o[0-7]+$/i); | ||
var regexExec = bind.call(Function.call, RegExp.prototype.exec); | ||
var arraySlice = bind.call(Function.call, $Array.prototype.slice); | ||
var strSlice = bind.call(Function.call, $String.prototype.slice); | ||
var isBinary = bind.call(Function.call, $RegExp.prototype.test, /^0b[01]+$/i); | ||
var isOctal = bind.call(Function.call, $RegExp.prototype.test, /^0o[0-7]+$/i); | ||
var regexExec = bind.call(Function.call, $RegExp.prototype.exec); | ||
var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); | ||
var nonWSregex = new RegExp('[' + nonWS + ']', 'g'); | ||
var hasNonWS = bind.call(Function.call, RegExp.prototype.test, nonWSregex); | ||
var nonWSregex = new $RegExp('[' + nonWS + ']', 'g'); | ||
var hasNonWS = bind.call(Function.call, $RegExp.prototype.test, nonWSregex); | ||
var invalidHexLiteral = /^[-+]0x[0-9a-f]+$/i; | ||
var isInvalidHexLiteral = bind.call(Function.call, RegExp.prototype.test, invalidHexLiteral); | ||
var isInvalidHexLiteral = bind.call(Function.call, $RegExp.prototype.test, invalidHexLiteral); | ||
var $charCodeAt = bind.call(Function.call, $String.prototype.charCodeAt); | ||
var toStr = bind.call(Function.call, Object.prototype.toString); | ||
var $floor = Math.floor; | ||
var $abs = Math.abs; | ||
var $ObjectCreate = Object.create; | ||
var $gOPD = $Object.getOwnPropertyDescriptor; | ||
var $isExtensible = $Object.isExtensible; | ||
// whitespace from: http://es5.github.io/#x15.5.4.20 | ||
@@ -41,3 +61,3 @@ // implementation from https://github.com/es-shims/es5-shim/blob/v3.4.0/es5-shim.js#L1304-L1324 | ||
var trimRegex = new RegExp('(^[' + ws + ']+)|([' + ws + ']+$)', 'g'); | ||
var replace = bind.call(Function.call, String.prototype.replace); | ||
var replace = bind.call(Function.call, $String.prototype.replace); | ||
var trim = function (value) { | ||
@@ -58,3 +78,3 @@ return replace(value, trimRegex, ''); | ||
if (!this.IsCallable(F)) { | ||
throw new TypeError(F + ' is not a function'); | ||
throw new $TypeError(F + ' is not a function'); | ||
} | ||
@@ -70,7 +90,7 @@ return F.apply(V, args); | ||
// http://www.ecma-international.org/ecma-262/6.0/#sec-tonumber | ||
// https://ecma-international.org/ecma-262/6.0/#sec-tonumber | ||
ToNumber: function ToNumber(argument) { | ||
var value = isPrimitive(argument) ? argument : toPrimitive(argument, Number); | ||
var value = isPrimitive(argument) ? argument : toPrimitive(argument, $Number); | ||
if (typeof value === 'symbol') { | ||
throw new TypeError('Cannot convert a Symbol value to a number'); | ||
throw new $TypeError('Cannot convert a Symbol value to a number'); | ||
} | ||
@@ -91,3 +111,3 @@ if (typeof value === 'string') { | ||
} | ||
return Number(value); | ||
return $Number(value); | ||
}, | ||
@@ -123,3 +143,3 @@ | ||
if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } | ||
var posInt = sign(number) * Math.floor(Math.abs(number)); | ||
var posInt = sign(number) * $floor($abs(number)); | ||
return mod(posInt, 0x100); | ||
@@ -133,3 +153,3 @@ }, | ||
if (number >= 0xFF) { return 0xFF; } | ||
var f = Math.floor(argument); | ||
var f = $floor(argument); | ||
if (f + 0.5 < number) { return f + 1; } | ||
@@ -144,5 +164,5 @@ if (number < f + 0.5) { return f; } | ||
if (typeof argument === 'symbol') { | ||
throw new TypeError('Cannot convert a Symbol value to a string'); | ||
throw new $TypeError('Cannot convert a Symbol value to a string'); | ||
} | ||
return String(argument); | ||
return $String(argument); | ||
}, | ||
@@ -153,3 +173,3 @@ | ||
this.RequireObjectCoercible(value); | ||
return Object(value); | ||
return $Object(value); | ||
}, | ||
@@ -159,3 +179,3 @@ | ||
ToPropertyKey: function ToPropertyKey(argument) { | ||
var key = this.ToPrimitive(argument, String); | ||
var key = this.ToPrimitive(argument, $String); | ||
return typeof key === 'symbol' ? key : this.ToString(key); | ||
@@ -172,6 +192,6 @@ }, | ||
// http://www.ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring | ||
// https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring | ||
CanonicalNumericIndexString: function CanonicalNumericIndexString(argument) { | ||
if (toStr.call(argument) !== '[object String]') { | ||
throw new TypeError('must be a string'); | ||
if (toStr(argument) !== '[object String]') { | ||
throw new $TypeError('must be a string'); | ||
} | ||
@@ -188,4 +208,4 @@ if (argument === '-0') { return -0; } | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray | ||
IsArray: Array.isArray || function IsArray(argument) { | ||
return toStr.call(argument) === '[object Array]'; | ||
IsArray: $Array.isArray || function IsArray(argument) { | ||
return toStr(argument) === '[object Array]'; | ||
}, | ||
@@ -202,9 +222,10 @@ | ||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isextensible-o | ||
IsExtensible: function IsExtensible(obj) { | ||
if (!Object.preventExtensions) { return true; } | ||
if (isPrimitive(obj)) { | ||
return false; | ||
IsExtensible: Object.preventExtensions | ||
? function IsExtensible(obj) { | ||
if (isPrimitive(obj)) { | ||
return false; | ||
} | ||
return $isExtensible(obj); | ||
} | ||
return Object.isExtensible(obj); | ||
}, | ||
: function isExtensible(obj) { return true; }, // eslint-disable-line no-unused-vars | ||
@@ -216,4 +237,4 @@ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isinteger | ||
} | ||
var abs = Math.abs(argument); | ||
return Math.floor(abs) === abs; | ||
var abs = $abs(argument); | ||
return $floor(abs) === abs; | ||
}, | ||
@@ -226,3 +247,3 @@ | ||
// http://www.ecma-international.org/ecma-262/6.0/#sec-isregexp | ||
// https://ecma-international.org/ecma-262/6.0/#sec-isregexp | ||
IsRegExp: function IsRegExp(argument) { | ||
@@ -233,3 +254,3 @@ if (!argument || typeof argument !== 'object') { | ||
if (hasSymbols) { | ||
var isRegExp = argument[Symbol.match]; | ||
var isRegExp = argument[$Symbol.match]; | ||
if (typeof isRegExp !== 'undefined') { | ||
@@ -260,3 +281,3 @@ return ES5.ToBoolean(isRegExp); | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
} | ||
@@ -272,3 +293,3 @@ | ||
/** | ||
* 7.3.9 - http://www.ecma-international.org/ecma-262/6.0/#sec-getmethod | ||
* 7.3.9 - https://ecma-international.org/ecma-262/6.0/#sec-getmethod | ||
* 1. Assert: IsPropertyKey(P) is true. | ||
@@ -284,3 +305,3 @@ * 2. Let func be GetV(O, P). | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
} | ||
@@ -298,3 +319,3 @@ | ||
if (!this.IsCallable(func)) { | ||
throw new TypeError(P + 'is not a function'); | ||
throw new $TypeError(P + 'is not a function'); | ||
} | ||
@@ -307,3 +328,3 @@ | ||
/** | ||
* 7.3.1 Get (O, P) - http://www.ecma-international.org/ecma-262/6.0/#sec-get-o-p | ||
* 7.3.1 Get (O, P) - https://ecma-international.org/ecma-262/6.0/#sec-get-o-p | ||
* 1. Assert: Type(O) is Object. | ||
@@ -316,7 +337,7 @@ * 2. Assert: IsPropertyKey(P) is true. | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(O) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(O) is not Object'); | ||
} | ||
// 7.3.1.2 | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
} | ||
@@ -334,6 +355,6 @@ // 7.3.1.3 | ||
// http://www.ecma-international.org/ecma-262/6.0/#sec-speciesconstructor | ||
// https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor | ||
SpeciesConstructor: function SpeciesConstructor(O, defaultConstructor) { | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(O) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(O) is not Object'); | ||
} | ||
@@ -345,5 +366,5 @@ var C = O.constructor; | ||
if (this.Type(C) !== 'Object') { | ||
throw new TypeError('O.constructor is not an Object'); | ||
throw new $TypeError('O.constructor is not an Object'); | ||
} | ||
var S = hasSymbols && Symbol.species ? C[Symbol.species] : void 0; | ||
var S = hasSymbols && $Symbol.species ? C[$Symbol.species] : void 0; | ||
if (S == null) { | ||
@@ -355,9 +376,9 @@ return defaultConstructor; | ||
} | ||
throw new TypeError('no constructor found'); | ||
throw new $TypeError('no constructor found'); | ||
}, | ||
// http://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor | ||
// https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor | ||
CompletePropertyDescriptor: function CompletePropertyDescriptor(Desc) { | ||
if (!this.IsPropertyDescriptor(Desc)) { | ||
throw new TypeError('Desc must be a Property Descriptor'); | ||
throw new $TypeError('Desc must be a Property Descriptor'); | ||
} | ||
@@ -389,12 +410,12 @@ | ||
// http://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw | ||
// https://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw | ||
Set: function Set(O, P, V, Throw) { | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('O must be an Object'); | ||
throw new $TypeError('O must be an Object'); | ||
} | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('P must be a Property Key'); | ||
throw new $TypeError('P must be a Property Key'); | ||
} | ||
if (this.Type(Throw) !== 'Boolean') { | ||
throw new TypeError('Throw must be a Boolean'); | ||
throw new $TypeError('Throw must be a Boolean'); | ||
} | ||
@@ -413,9 +434,9 @@ if (Throw) { | ||
// http://ecma-international.org/ecma-262/6.0/#sec-hasownproperty | ||
// https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty | ||
HasOwnProperty: function HasOwnProperty(O, P) { | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('O must be an Object'); | ||
throw new $TypeError('O must be an Object'); | ||
} | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('P must be a Property Key'); | ||
throw new $TypeError('P must be a Property Key'); | ||
} | ||
@@ -425,9 +446,9 @@ return has(O, P); | ||
// http://ecma-international.org/ecma-262/6.0/#sec-hasproperty | ||
// https://ecma-international.org/ecma-262/6.0/#sec-hasproperty | ||
HasProperty: function HasProperty(O, P) { | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('O must be an Object'); | ||
throw new $TypeError('O must be an Object'); | ||
} | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('P must be a Property Key'); | ||
throw new $TypeError('P must be a Property Key'); | ||
} | ||
@@ -437,3 +458,3 @@ return P in O; | ||
// http://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable | ||
// https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable | ||
IsConcatSpreadable: function IsConcatSpreadable(O) { | ||
@@ -443,3 +464,3 @@ if (this.Type(O) !== 'Object') { | ||
} | ||
if (hasSymbols && typeof Symbol.isConcatSpreadable === 'symbol') { | ||
if (hasSymbols && typeof $Symbol.isConcatSpreadable === 'symbol') { | ||
var spreadable = this.Get(O, Symbol.isConcatSpreadable); | ||
@@ -453,6 +474,6 @@ if (typeof spreadable !== 'undefined') { | ||
// http://ecma-international.org/ecma-262/6.0/#sec-invoke | ||
// https://ecma-international.org/ecma-262/6.0/#sec-invoke | ||
Invoke: function Invoke(O, P) { | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('P must be a Property Key'); | ||
throw new $TypeError('P must be a Property Key'); | ||
} | ||
@@ -464,3 +485,3 @@ var argumentsList = arraySlice(arguments, 2); | ||
// http://ecma-international.org/ecma-262/6.0/#sec-getiterator | ||
// https://ecma-international.org/ecma-262/6.0/#sec-getiterator | ||
GetIterator: function GetIterator(obj, method) { | ||
@@ -473,7 +494,7 @@ if (!hasSymbols) { | ||
if (arguments.length < 2) { | ||
actualMethod = this.GetMethod(obj, SymbolIterator); | ||
actualMethod = this.GetMethod(obj, $Symbol.iterator); | ||
} | ||
var iterator = this.Call(actualMethod, obj); | ||
if (this.Type(iterator) !== 'Object') { | ||
throw new TypeError('iterator must return an object'); | ||
throw new $TypeError('iterator must return an object'); | ||
} | ||
@@ -484,7 +505,7 @@ | ||
// http://ecma-international.org/ecma-262/6.0/#sec-iteratornext | ||
// https://ecma-international.org/ecma-262/6.0/#sec-iteratornext | ||
IteratorNext: function IteratorNext(iterator, value) { | ||
var result = this.Invoke(iterator, 'next', arguments.length < 2 ? [] : [value]); | ||
if (this.Type(result) !== 'Object') { | ||
throw new TypeError('iterator next must return an object'); | ||
throw new $TypeError('iterator next must return an object'); | ||
} | ||
@@ -494,6 +515,6 @@ return result; | ||
// http://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete | ||
// https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete | ||
IteratorComplete: function IteratorComplete(iterResult) { | ||
if (this.Type(iterResult) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(iterResult) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); | ||
} | ||
@@ -503,6 +524,6 @@ return this.ToBoolean(this.Get(iterResult, 'done')); | ||
// http://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue | ||
// https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue | ||
IteratorValue: function IteratorValue(iterResult) { | ||
if (this.Type(iterResult) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(iterResult) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(iterResult) is not Object'); | ||
} | ||
@@ -512,3 +533,3 @@ return this.Get(iterResult, 'value'); | ||
// http://ecma-international.org/ecma-262/6.0/#sec-iteratorstep | ||
// https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep | ||
IteratorStep: function IteratorStep(iterator) { | ||
@@ -520,9 +541,9 @@ var result = this.IteratorNext(iterator); | ||
// http://ecma-international.org/ecma-262/6.0/#sec-iteratorclose | ||
// https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose | ||
IteratorClose: function IteratorClose(iterator, completion) { | ||
if (this.Type(iterator) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(iterator) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(iterator) is not Object'); | ||
} | ||
if (!this.IsCallable(completion)) { | ||
throw new TypeError('Assertion failed: completion is not a thunk for a Completion Record'); | ||
throw new $TypeError('Assertion failed: completion is not a thunk for a Completion Record'); | ||
} | ||
@@ -554,3 +575,3 @@ var completionThunk = completion; | ||
if (this.Type(innerResult) !== 'Object') { | ||
throw new TypeError('iterator .return must return an object'); | ||
throw new $TypeError('iterator .return must return an object'); | ||
} | ||
@@ -561,6 +582,6 @@ | ||
// http://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject | ||
// https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject | ||
CreateIterResultObject: function CreateIterResultObject(value, done) { | ||
if (this.Type(done) !== 'Boolean') { | ||
throw new TypeError('Assertion failed: Type(done) is not Boolean'); | ||
throw new $TypeError('Assertion failed: Type(done) is not Boolean'); | ||
} | ||
@@ -573,9 +594,9 @@ return { | ||
// http://ecma-international.org/ecma-262/6.0/#sec-regexpexec | ||
// https://ecma-international.org/ecma-262/6.0/#sec-regexpexec | ||
RegExpExec: function RegExpExec(R, S) { | ||
if (this.Type(R) !== 'Object') { | ||
throw new TypeError('R must be an Object'); | ||
throw new $TypeError('R must be an Object'); | ||
} | ||
if (this.Type(S) !== 'String') { | ||
throw new TypeError('S must be a String'); | ||
throw new $TypeError('S must be a String'); | ||
} | ||
@@ -588,3 +609,3 @@ var exec = this.Get(R, 'exec'); | ||
} | ||
throw new TypeError('"exec" method must return `null` or an Object'); | ||
throw new $TypeError('"exec" method must return `null` or an Object'); | ||
} | ||
@@ -594,6 +615,6 @@ return regexExec(R, S); | ||
// http://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate | ||
// https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate | ||
ArraySpeciesCreate: function ArraySpeciesCreate(originalArray, length) { | ||
if (!this.IsInteger(length) || length < 0) { | ||
throw new TypeError('Assertion failed: length must be an integer >= 0'); | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0'); | ||
} | ||
@@ -610,4 +631,4 @@ var len = length === 0 ? 0 : length; | ||
// } | ||
if (this.Type(C) === 'Object' && hasSymbols && Symbol.species) { | ||
C = this.Get(C, Symbol.species); | ||
if (this.Type(C) === 'Object' && hasSymbols && $Symbol.species) { | ||
C = this.Get(C, $Symbol.species); | ||
if (C === null) { | ||
@@ -619,6 +640,6 @@ C = void 0; | ||
if (typeof C === 'undefined') { | ||
return Array(len); | ||
return $Array(len); | ||
} | ||
if (!this.IsConstructor(C)) { | ||
throw new TypeError('C must be a constructor'); | ||
throw new $TypeError('C must be a constructor'); | ||
} | ||
@@ -630,9 +651,9 @@ return new C(len); // this.Construct(C, len); | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(O) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(O) is not Object'); | ||
} | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
} | ||
var oldDesc = Object.getOwnPropertyDescriptor(O, P); | ||
var extensible = oldDesc || (typeof Object.isExtensible !== 'function' || Object.isExtensible(O)); | ||
var oldDesc = $gOPD(O, P); | ||
var extensible = oldDesc || (typeof $isExtensible !== 'function' || $isExtensible(O)); | ||
var immutable = oldDesc && (!oldDesc.writable || !oldDesc.configurable); | ||
@@ -652,13 +673,13 @@ if (immutable || !extensible) { | ||
// http://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow | ||
// https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow | ||
CreateDataPropertyOrThrow: function CreateDataPropertyOrThrow(O, P, V) { | ||
if (this.Type(O) !== 'Object') { | ||
throw new TypeError('Assertion failed: Type(O) is not Object'); | ||
throw new $TypeError('Assertion failed: Type(O) is not Object'); | ||
} | ||
if (!this.IsPropertyKey(P)) { | ||
throw new TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true'); | ||
} | ||
var success = this.CreateDataProperty(O, P, V); | ||
if (!success) { | ||
throw new TypeError('unable to create data property'); | ||
throw new $TypeError('unable to create data property'); | ||
} | ||
@@ -668,15 +689,29 @@ return success; | ||
// http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex | ||
// https://www.ecma-international.org/ecma-262/6.0/#sec-objectcreate | ||
ObjectCreate: function ObjectCreate(proto, internalSlotsList) { | ||
if (proto !== null && this.Type(proto) !== 'Object') { | ||
throw new $TypeError('Assertion failed: proto must be null or an object'); | ||
} | ||
var slots = arguments.length < 2 ? [] : internalSlotsList; | ||
if (slots.length > 0) { | ||
throw new $SyntaxError('es-abstract does not yet support internal slots'); | ||
} | ||
if (proto === null && !$ObjectCreate) { | ||
throw new $SyntaxError('native Object.create support is required to create null objects'); | ||
} | ||
return $ObjectCreate(proto); | ||
}, | ||
// https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex | ||
AdvanceStringIndex: function AdvanceStringIndex(S, index, unicode) { | ||
if (this.Type(S) !== 'String') { | ||
throw new TypeError('Assertion failed: Type(S) is not String'); | ||
throw new $TypeError('S must be a String'); | ||
} | ||
if (!this.IsInteger(index)) { | ||
throw new TypeError('Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)'); | ||
if (!this.IsInteger(index) || index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new $TypeError('Assertion failed: length must be an integer >= 0 and <= 2**53'); | ||
} | ||
if (index < 0 || index > MAX_SAFE_INTEGER) { | ||
throw new RangeError('Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)'); | ||
} | ||
if (this.Type(unicode) !== 'Boolean') { | ||
throw new TypeError('Assertion failed: Type(unicode) is not Boolean'); | ||
throw new $TypeError('Assertion failed: unicode must be a Boolean'); | ||
} | ||
@@ -690,10 +725,13 @@ if (!unicode) { | ||
} | ||
var first = S.charCodeAt(index); | ||
var first = $charCodeAt(S, index); | ||
if (first < 0xD800 || first > 0xDBFF) { | ||
return index + 1; | ||
} | ||
var second = S.charCodeAt(index + 1); | ||
var second = $charCodeAt(S, index + 1); | ||
if (second < 0xDC00 || second > 0xDFFF) { | ||
return index + 1; | ||
} | ||
return index + 2; | ||
@@ -700,0 +738,0 @@ } |
46
es5.js
'use strict'; | ||
var GetIntrinsic = require('./GetIntrinsic'); | ||
var $Object = GetIntrinsic('%Object%'); | ||
var $TypeError = GetIntrinsic('%TypeError%'); | ||
var $String = GetIntrinsic('%String%'); | ||
var $isNaN = require('./helpers/isNaN'); | ||
@@ -22,3 +28,3 @@ var $isFinite = require('./helpers/isFinite'); | ||
ToNumber: function ToNumber(value) { | ||
return Number(value); | ||
return +value; // eslint-disable-line no-implicit-coercion | ||
}, | ||
@@ -44,7 +50,7 @@ ToInteger: function ToInteger(value) { | ||
ToString: function ToString(value) { | ||
return String(value); | ||
return $String(value); | ||
}, | ||
ToObject: function ToObject(value) { | ||
this.CheckObjectCoercible(value); | ||
return Object(value); | ||
return $Object(value); | ||
}, | ||
@@ -54,3 +60,3 @@ CheckObjectCoercible: function CheckObjectCoercible(value, optMessage) { | ||
if (value == null) { | ||
throw new TypeError(optMessage || 'Cannot call method on ' + value); | ||
throw new $TypeError(optMessage || 'Cannot call method on ' + value); | ||
} | ||
@@ -68,3 +74,3 @@ return value; | ||
// http://www.ecma-international.org/ecma-262/5.1/#sec-8 | ||
// https://www.ecma-international.org/ecma-262/5.1/#sec-8 | ||
Type: function Type(x) { | ||
@@ -91,3 +97,3 @@ if (x === null) { | ||
// http://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type | ||
// https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type | ||
IsPropertyDescriptor: function IsPropertyDescriptor(Desc) { | ||
@@ -115,3 +121,3 @@ if (this.Type(Desc) !== 'Object') { | ||
if (isData && IsAccessor) { | ||
throw new TypeError('Property Descriptors may not be both accessor and data descriptors'); | ||
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); | ||
} | ||
@@ -121,3 +127,3 @@ return true; | ||
// http://ecma-international.org/ecma-262/5.1/#sec-8.10.1 | ||
// https://ecma-international.org/ecma-262/5.1/#sec-8.10.1 | ||
IsAccessorDescriptor: function IsAccessorDescriptor(Desc) { | ||
@@ -129,3 +135,3 @@ if (typeof Desc === 'undefined') { | ||
if (!this.IsPropertyDescriptor(Desc)) { | ||
throw new TypeError('Desc must be a Property Descriptor'); | ||
throw new $TypeError('Desc must be a Property Descriptor'); | ||
} | ||
@@ -140,3 +146,3 @@ | ||
// http://ecma-international.org/ecma-262/5.1/#sec-8.10.2 | ||
// https://ecma-international.org/ecma-262/5.1/#sec-8.10.2 | ||
IsDataDescriptor: function IsDataDescriptor(Desc) { | ||
@@ -148,3 +154,3 @@ if (typeof Desc === 'undefined') { | ||
if (!this.IsPropertyDescriptor(Desc)) { | ||
throw new TypeError('Desc must be a Property Descriptor'); | ||
throw new $TypeError('Desc must be a Property Descriptor'); | ||
} | ||
@@ -159,3 +165,3 @@ | ||
// http://ecma-international.org/ecma-262/5.1/#sec-8.10.3 | ||
// https://ecma-international.org/ecma-262/5.1/#sec-8.10.3 | ||
IsGenericDescriptor: function IsGenericDescriptor(Desc) { | ||
@@ -167,3 +173,3 @@ if (typeof Desc === 'undefined') { | ||
if (!this.IsPropertyDescriptor(Desc)) { | ||
throw new TypeError('Desc must be a Property Descriptor'); | ||
throw new $TypeError('Desc must be a Property Descriptor'); | ||
} | ||
@@ -178,3 +184,3 @@ | ||
// http://ecma-international.org/ecma-262/5.1/#sec-8.10.4 | ||
// https://ecma-international.org/ecma-262/5.1/#sec-8.10.4 | ||
FromPropertyDescriptor: function FromPropertyDescriptor(Desc) { | ||
@@ -186,3 +192,3 @@ if (typeof Desc === 'undefined') { | ||
if (!this.IsPropertyDescriptor(Desc)) { | ||
throw new TypeError('Desc must be a Property Descriptor'); | ||
throw new $TypeError('Desc must be a Property Descriptor'); | ||
} | ||
@@ -205,10 +211,10 @@ | ||
} else { | ||
throw new TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor'); | ||
throw new $TypeError('FromPropertyDescriptor must be called with a fully populated Property Descriptor'); | ||
} | ||
}, | ||
// http://ecma-international.org/ecma-262/5.1/#sec-8.10.5 | ||
// https://ecma-international.org/ecma-262/5.1/#sec-8.10.5 | ||
ToPropertyDescriptor: function ToPropertyDescriptor(Obj) { | ||
if (this.Type(Obj) !== 'Object') { | ||
throw new TypeError('ToPropertyDescriptor requires an object'); | ||
throw new $TypeError('ToPropertyDescriptor requires an object'); | ||
} | ||
@@ -239,3 +245,3 @@ | ||
if (typeof setter !== 'undefined' && !this.IsCallable(setter)) { | ||
throw new TypeError('setter must be a function'); | ||
throw new $TypeError('setter must be a function'); | ||
} | ||
@@ -246,3 +252,3 @@ desc['[[Set]]'] = setter; | ||
if ((has(desc, '[[Get]]') || has(desc, '[[Set]]')) && (has(desc, '[[Value]]') || has(desc, '[[Writable]]'))) { | ||
throw new TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); | ||
throw new $TypeError('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute'); | ||
} | ||
@@ -249,0 +255,0 @@ return desc; |
@@ -1,8 +0,13 @@ | ||
var has = Object.prototype.hasOwnProperty; | ||
var bind = require('function-bind'); | ||
var has = bind.call(Function.call, Object.prototype.hasOwnProperty); | ||
var $assign = Object.assign; | ||
module.exports = function assign(target, source) { | ||
if (Object.assign) { | ||
return Object.assign(target, source); | ||
if ($assign) { | ||
return $assign(target, source); | ||
} | ||
for (var key in source) { | ||
if (has.call(source, key)) { | ||
if (has(source, key)) { | ||
target[key] = source[key]; | ||
@@ -9,0 +14,0 @@ } |
'use strict'; | ||
module.exports = { | ||
IsPropertyDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type', | ||
IsAccessorDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'http://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'http://ecma-international.org/ecma-262/6.0/#sec-toprimitive', | ||
ToBoolean: 'http://ecma-international.org/ecma-262/6.0/#sec-toboolean', | ||
ToNumber: 'http://ecma-international.org/ecma-262/6.0/#sec-tonumber', | ||
ToInteger: 'http://ecma-international.org/ecma-262/6.0/#sec-tointeger', | ||
ToInt32: 'http://ecma-international.org/ecma-262/6.0/#sec-toint32', | ||
ToUint32: 'http://ecma-international.org/ecma-262/6.0/#sec-touint32', | ||
ToInt16: 'http://ecma-international.org/ecma-262/6.0/#sec-toint16', | ||
ToUint16: 'http://ecma-international.org/ecma-262/6.0/#sec-touint16', | ||
ToInt8: 'http://ecma-international.org/ecma-262/6.0/#sec-toint8', | ||
ToUint8: 'http://ecma-international.org/ecma-262/6.0/#sec-touint8', | ||
ToUint8Clamp: 'http://ecma-international.org/ecma-262/6.0/#sec-touint8clamp', | ||
ToString: 'http://ecma-international.org/ecma-262/6.0/#sec-tostring', | ||
ToObject: 'http://ecma-international.org/ecma-262/6.0/#sec-toobject', | ||
ToPropertyKey: 'http://ecma-international.org/ecma-262/6.0/#sec-topropertykey', | ||
ToLength: 'http://ecma-international.org/ecma-262/6.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'http://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring', | ||
RequireObjectCoercible: 'http://ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible', | ||
IsArray: 'http://ecma-international.org/ecma-262/6.0/#sec-isarray', | ||
IsCallable: 'http://ecma-international.org/ecma-262/6.0/#sec-iscallable', | ||
IsConstructor: 'http://ecma-international.org/ecma-262/6.0/#sec-isconstructor', | ||
IsExtensible: 'http://ecma-international.org/ecma-262/6.0/#sec-isextensible-o', | ||
IsInteger: 'http://ecma-international.org/ecma-262/6.0/#sec-isinteger', | ||
IsPropertyKey: 'http://ecma-international.org/ecma-262/6.0/#sec-ispropertykey', | ||
IsRegExp: 'http://ecma-international.org/ecma-262/6.0/#sec-isregexp', | ||
SameValue: 'http://ecma-international.org/ecma-262/6.0/#sec-samevalue', | ||
SameValueZero: 'http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero', | ||
Get: 'http://ecma-international.org/ecma-262/6.0/#sec-get-o-p', | ||
GetV: 'http://ecma-international.org/ecma-262/6.0/#sec-getv', | ||
Set: 'http://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'http://ecma-international.org/ecma-262/6.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'http://ecma-international.org/ecma-262/6.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'http://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'http://ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'http://ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'http://ecma-international.org/ecma-262/6.0/#sec-getmethod', | ||
HasProperty: 'http://ecma-international.org/ecma-262/6.0/#sec-hasproperty', | ||
HasOwnProperty: 'http://ecma-international.org/ecma-262/6.0/#sec-hasownproperty', | ||
Call: 'http://ecma-international.org/ecma-262/6.0/#sec-call', | ||
Construct: 'http://ecma-international.org/ecma-262/6.0/#sec-construct', | ||
SetIntegrityLevel: 'http://ecma-international.org/ecma-262/6.0/#sec-setintegritylevel', | ||
TestIntegrityLevel: 'http://ecma-international.org/ecma-262/6.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'http://ecma-international.org/ecma-262/6.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'http://ecma-international.org/ecma-262/6.0/#sec-createlistfromarraylike', | ||
Invoke: 'http://ecma-international.org/ecma-262/6.0/#sec-invoke', | ||
OrdinaryHasInstance: 'http://ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'http://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor', | ||
EnumerableOwnNames: 'http://ecma-international.org/ecma-262/6.0/#sec-enumerableownnames', | ||
GetIterator: 'http://ecma-international.org/ecma-262/6.0/#sec-getiterator', | ||
IteratorNext: 'http://ecma-international.org/ecma-262/6.0/#sec-iteratornext', | ||
IteratorComplete: 'http://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete', | ||
IteratorValue: 'http://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue', | ||
IteratorStep: 'http://ecma-international.org/ecma-262/6.0/#sec-iteratorstep', | ||
IteratorClose: 'http://ecma-international.org/ecma-262/6.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'http://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject', | ||
CreateListIterator: 'http://ecma-international.org/ecma-262/6.0/#sec-createlistiterator', | ||
Type: 'http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types', | ||
thisNumberValue: 'http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-number-prototype-object', | ||
thisTimeValue: 'http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'http://ecma-international.org/ecma-262/6.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'http://ecma-international.org/ecma-262/6.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'http://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable', | ||
IsPromise: 'http://ecma-international.org/ecma-262/6.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate', | ||
AdvanceStringIndex: 'http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex' | ||
IsPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type', | ||
IsAccessorDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'https://ecma-international.org/ecma-262/6.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'https://ecma-international.org/ecma-262/6.0/#sec-toprimitive', | ||
ToBoolean: 'https://ecma-international.org/ecma-262/6.0/#sec-toboolean', | ||
ToNumber: 'https://ecma-international.org/ecma-262/6.0/#sec-tonumber', | ||
ToInteger: 'https://ecma-international.org/ecma-262/6.0/#sec-tointeger', | ||
ToInt32: 'https://ecma-international.org/ecma-262/6.0/#sec-toint32', | ||
ToUint32: 'https://ecma-international.org/ecma-262/6.0/#sec-touint32', | ||
ToInt16: 'https://ecma-international.org/ecma-262/6.0/#sec-toint16', | ||
ToUint16: 'https://ecma-international.org/ecma-262/6.0/#sec-touint16', | ||
ToInt8: 'https://ecma-international.org/ecma-262/6.0/#sec-toint8', | ||
ToUint8: 'https://ecma-international.org/ecma-262/6.0/#sec-touint8', | ||
ToUint8Clamp: 'https://ecma-international.org/ecma-262/6.0/#sec-touint8clamp', | ||
ToString: 'https://ecma-international.org/ecma-262/6.0/#sec-tostring', | ||
ToObject: 'https://ecma-international.org/ecma-262/6.0/#sec-toobject', | ||
ToPropertyKey: 'https://ecma-international.org/ecma-262/6.0/#sec-topropertykey', | ||
ToLength: 'https://ecma-international.org/ecma-262/6.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring', | ||
RequireObjectCoercible: 'https://ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible', | ||
IsArray: 'https://ecma-international.org/ecma-262/6.0/#sec-isarray', | ||
IsCallable: 'https://ecma-international.org/ecma-262/6.0/#sec-iscallable', | ||
IsConstructor: 'https://ecma-international.org/ecma-262/6.0/#sec-isconstructor', | ||
IsExtensible: 'https://ecma-international.org/ecma-262/6.0/#sec-isextensible-o', | ||
IsInteger: 'https://ecma-international.org/ecma-262/6.0/#sec-isinteger', | ||
IsPropertyKey: 'https://ecma-international.org/ecma-262/6.0/#sec-ispropertykey', | ||
IsRegExp: 'https://ecma-international.org/ecma-262/6.0/#sec-isregexp', | ||
SameValue: 'https://ecma-international.org/ecma-262/6.0/#sec-samevalue', | ||
SameValueZero: 'https://ecma-international.org/ecma-262/6.0/#sec-samevaluezero', | ||
Get: 'https://ecma-international.org/ecma-262/6.0/#sec-get-o-p', | ||
GetV: 'https://ecma-international.org/ecma-262/6.0/#sec-getv', | ||
Set: 'https://ecma-international.org/ecma-262/6.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'https://ecma-international.org/ecma-262/6.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'https://ecma-international.org/ecma-262/6.0/#sec-getmethod', | ||
HasProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-hasproperty', | ||
HasOwnProperty: 'https://ecma-international.org/ecma-262/6.0/#sec-hasownproperty', | ||
Call: 'https://ecma-international.org/ecma-262/6.0/#sec-call', | ||
Construct: 'https://ecma-international.org/ecma-262/6.0/#sec-construct', | ||
SetIntegrityLevel: 'https://ecma-international.org/ecma-262/6.0/#sec-setintegritylevel', | ||
TestIntegrityLevel: 'https://ecma-international.org/ecma-262/6.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'https://ecma-international.org/ecma-262/6.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'https://ecma-international.org/ecma-262/6.0/#sec-createlistfromarraylike', | ||
Invoke: 'https://ecma-international.org/ecma-262/6.0/#sec-invoke', | ||
OrdinaryHasInstance: 'https://ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'https://ecma-international.org/ecma-262/6.0/#sec-speciesconstructor', | ||
EnumerableOwnNames: 'https://ecma-international.org/ecma-262/6.0/#sec-enumerableownnames', | ||
GetIterator: 'https://ecma-international.org/ecma-262/6.0/#sec-getiterator', | ||
IteratorNext: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratornext', | ||
IteratorComplete: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete', | ||
IteratorValue: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorvalue', | ||
IteratorStep: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorstep', | ||
IteratorClose: 'https://ecma-international.org/ecma-262/6.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'https://ecma-international.org/ecma-262/6.0/#sec-createiterresultobject', | ||
CreateListIterator: 'https://ecma-international.org/ecma-262/6.0/#sec-createlistiterator', | ||
Type: 'https://ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types', | ||
thisNumberValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-number-prototype-object', | ||
thisTimeValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'https://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable', | ||
IsPromise: 'https://ecma-international.org/ecma-262/6.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-arrayspeciescreate', | ||
ObjectCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-objectcreate', | ||
AdvanceStringIndex: 'https://ecma-international.org/ecma-262/6.0/#sec-advancestringindex', | ||
NormalCompletion: 'https://ecma-international.org/ecma-262/6.0/#sec-normalcompletion' | ||
}; |
'use strict'; | ||
module.exports = { | ||
IsPropertyDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-property-descriptor-specification-type', | ||
IsAccessorDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'http://ecma-international.org/ecma-262/7.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'http://ecma-international.org/ecma-262/7.0/#sec-toprimitive', | ||
ToBoolean: 'http://ecma-international.org/ecma-262/7.0/#sec-toboolean', | ||
ToNumber: 'http://ecma-international.org/ecma-262/7.0/#sec-tonumber', | ||
ToInteger: 'http://ecma-international.org/ecma-262/7.0/#sec-tointeger', | ||
ToInt32: 'http://ecma-international.org/ecma-262/7.0/#sec-toint32', | ||
ToUint32: 'http://ecma-international.org/ecma-262/7.0/#sec-touint32', | ||
ToInt16: 'http://ecma-international.org/ecma-262/7.0/#sec-toint16', | ||
ToUint16: 'http://ecma-international.org/ecma-262/7.0/#sec-touint16', | ||
ToInt8: 'http://ecma-international.org/ecma-262/7.0/#sec-toint8', | ||
ToUint8: 'http://ecma-international.org/ecma-262/7.0/#sec-touint8', | ||
ToUint8Clamp: 'http://ecma-international.org/ecma-262/7.0/#sec-touint8clamp', | ||
ToString: 'http://ecma-international.org/ecma-262/7.0/#sec-tostring', | ||
ToObject: 'http://ecma-international.org/ecma-262/7.0/#sec-toobject', | ||
ToPropertyKey: 'http://ecma-international.org/ecma-262/7.0/#sec-topropertykey', | ||
ToLength: 'http://ecma-international.org/ecma-262/7.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'http://ecma-international.org/ecma-262/7.0/#sec-canonicalnumericindexstring', | ||
RequireObjectCoercible: 'http://ecma-international.org/ecma-262/7.0/#sec-requireobjectcoercible', | ||
IsArray: 'http://ecma-international.org/ecma-262/7.0/#sec-isarray', | ||
IsCallable: 'http://ecma-international.org/ecma-262/7.0/#sec-iscallable', | ||
IsConstructor: 'http://ecma-international.org/ecma-262/7.0/#sec-isconstructor', | ||
IsExtensible: 'http://ecma-international.org/ecma-262/7.0/#sec-isextensible-o', | ||
IsInteger: 'http://ecma-international.org/ecma-262/7.0/#sec-isinteger', | ||
IsPropertyKey: 'http://ecma-international.org/ecma-262/7.0/#sec-ispropertykey', | ||
IsRegExp: 'http://ecma-international.org/ecma-262/7.0/#sec-isregexp', | ||
SameValue: 'http://ecma-international.org/ecma-262/7.0/#sec-samevalue', | ||
SameValueZero: 'http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero', | ||
SameValueNonNumber: 'http://ecma-international.org/ecma-262/7.0/#sec-samevaluenonnumber', | ||
Get: 'http://ecma-international.org/ecma-262/7.0/#sec-get-o-p', | ||
GetV: 'http://ecma-international.org/ecma-262/7.0/#sec-getv', | ||
Set: 'http://ecma-international.org/ecma-262/7.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'http://ecma-international.org/ecma-262/7.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'http://ecma-international.org/ecma-262/7.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'http://ecma-international.org/ecma-262/7.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'http://ecma-international.org/ecma-262/7.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'http://ecma-international.org/ecma-262/7.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'http://ecma-international.org/ecma-262/7.0/#sec-getmethod', | ||
HasProperty: 'http://ecma-international.org/ecma-262/7.0/#sec-hasproperty', | ||
HasOwnProperty: 'http://ecma-international.org/ecma-262/7.0/#sec-hasownproperty', | ||
Call: 'http://ecma-international.org/ecma-262/7.0/#sec-call', | ||
Construct: 'http://ecma-international.org/ecma-262/7.0/#sec-construct', | ||
SetIntegrityLevel: 'http://ecma-international.org/ecma-262/7.0/#sec-setintegritylevel', | ||
TestIntegrityLevel: 'http://ecma-international.org/ecma-262/7.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'http://ecma-international.org/ecma-262/7.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'http://ecma-international.org/ecma-262/7.0/#sec-createlistfromarraylike', | ||
Invoke: 'http://ecma-international.org/ecma-262/7.0/#sec-invoke', | ||
OrdinaryHasInstance: 'http://ecma-international.org/ecma-262/7.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'http://ecma-international.org/ecma-262/7.0/#sec-speciesconstructor', | ||
EnumerableOwnNames: 'http://ecma-international.org/ecma-262/7.0/#sec-enumerableownnames', | ||
GetIterator: 'http://ecma-international.org/ecma-262/7.0/#sec-getiterator', | ||
IteratorNext: 'http://ecma-international.org/ecma-262/7.0/#sec-iteratornext', | ||
IteratorComplete: 'http://ecma-international.org/ecma-262/7.0/#sec-iteratorcomplete', | ||
IteratorValue: 'http://ecma-international.org/ecma-262/7.0/#sec-iteratorvalue', | ||
IteratorStep: 'http://ecma-international.org/ecma-262/7.0/#sec-iteratorstep', | ||
IteratorClose: 'http://ecma-international.org/ecma-262/7.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'http://ecma-international.org/ecma-262/7.0/#sec-createiterresultobject', | ||
CreateListIterator: 'http://ecma-international.org/ecma-262/7.0/#sec-createlistiterator', | ||
Type: 'http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types', | ||
thisNumberValue: 'http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-number-prototype-object', | ||
thisTimeValue: 'http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'http://ecma-international.org/ecma-262/7.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'http://ecma-international.org/ecma-262/7.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'http://ecma-international.org/ecma-262/7.0/#sec-isconcatspreadable', | ||
IsPromise: 'http://ecma-international.org/ecma-262/7.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/7.0/#sec-arrayspeciescreate', | ||
AdvanceStringIndex: 'http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex' | ||
IsPropertyDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-property-descriptor-specification-type', | ||
IsAccessorDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'https://ecma-international.org/ecma-262/7.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'https://ecma-international.org/ecma-262/7.0/#sec-toprimitive', | ||
ToBoolean: 'https://ecma-international.org/ecma-262/7.0/#sec-toboolean', | ||
ToNumber: 'https://ecma-international.org/ecma-262/7.0/#sec-tonumber', | ||
ToInteger: 'https://ecma-international.org/ecma-262/7.0/#sec-tointeger', | ||
ToInt32: 'https://ecma-international.org/ecma-262/7.0/#sec-toint32', | ||
ToUint32: 'https://ecma-international.org/ecma-262/7.0/#sec-touint32', | ||
ToInt16: 'https://ecma-international.org/ecma-262/7.0/#sec-toint16', | ||
ToUint16: 'https://ecma-international.org/ecma-262/7.0/#sec-touint16', | ||
ToInt8: 'https://ecma-international.org/ecma-262/7.0/#sec-toint8', | ||
ToUint8: 'https://ecma-international.org/ecma-262/7.0/#sec-touint8', | ||
ToUint8Clamp: 'https://ecma-international.org/ecma-262/7.0/#sec-touint8clamp', | ||
ToString: 'https://ecma-international.org/ecma-262/7.0/#sec-tostring', | ||
ToObject: 'https://ecma-international.org/ecma-262/7.0/#sec-toobject', | ||
ToPropertyKey: 'https://ecma-international.org/ecma-262/7.0/#sec-topropertykey', | ||
ToLength: 'https://ecma-international.org/ecma-262/7.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'https://ecma-international.org/ecma-262/7.0/#sec-canonicalnumericindexstring', | ||
RequireObjectCoercible: 'https://ecma-international.org/ecma-262/7.0/#sec-requireobjectcoercible', | ||
IsArray: 'https://ecma-international.org/ecma-262/7.0/#sec-isarray', | ||
IsCallable: 'https://ecma-international.org/ecma-262/7.0/#sec-iscallable', | ||
IsConstructor: 'https://ecma-international.org/ecma-262/7.0/#sec-isconstructor', | ||
IsExtensible: 'https://ecma-international.org/ecma-262/7.0/#sec-isextensible-o', | ||
IsInteger: 'https://ecma-international.org/ecma-262/7.0/#sec-isinteger', | ||
IsPropertyKey: 'https://ecma-international.org/ecma-262/7.0/#sec-ispropertykey', | ||
IsRegExp: 'https://ecma-international.org/ecma-262/7.0/#sec-isregexp', | ||
SameValue: 'https://ecma-international.org/ecma-262/7.0/#sec-samevalue', | ||
SameValueZero: 'https://ecma-international.org/ecma-262/7.0/#sec-samevaluezero', | ||
SameValueNonNumber: 'https://ecma-international.org/ecma-262/7.0/#sec-samevaluenonnumber', | ||
Get: 'https://ecma-international.org/ecma-262/7.0/#sec-get-o-p', | ||
GetV: 'https://ecma-international.org/ecma-262/7.0/#sec-getv', | ||
Set: 'https://ecma-international.org/ecma-262/7.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'https://ecma-international.org/ecma-262/7.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'https://ecma-international.org/ecma-262/7.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'https://ecma-international.org/ecma-262/7.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'https://ecma-international.org/ecma-262/7.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'https://ecma-international.org/ecma-262/7.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'https://ecma-international.org/ecma-262/7.0/#sec-getmethod', | ||
HasProperty: 'https://ecma-international.org/ecma-262/7.0/#sec-hasproperty', | ||
HasOwnProperty: 'https://ecma-international.org/ecma-262/7.0/#sec-hasownproperty', | ||
Call: 'https://ecma-international.org/ecma-262/7.0/#sec-call', | ||
Construct: 'https://ecma-international.org/ecma-262/7.0/#sec-construct', | ||
SetIntegrityLevel: 'https://ecma-international.org/ecma-262/7.0/#sec-setintegritylevel', | ||
TestIntegrityLevel: 'https://ecma-international.org/ecma-262/7.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'https://ecma-international.org/ecma-262/7.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'https://ecma-international.org/ecma-262/7.0/#sec-createlistfromarraylike', | ||
Invoke: 'https://ecma-international.org/ecma-262/7.0/#sec-invoke', | ||
OrdinaryHasInstance: 'https://ecma-international.org/ecma-262/7.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'https://ecma-international.org/ecma-262/7.0/#sec-speciesconstructor', | ||
EnumerableOwnNames: 'https://ecma-international.org/ecma-262/7.0/#sec-enumerableownnames', | ||
GetIterator: 'https://ecma-international.org/ecma-262/7.0/#sec-getiterator', | ||
IteratorNext: 'https://ecma-international.org/ecma-262/7.0/#sec-iteratornext', | ||
IteratorComplete: 'https://ecma-international.org/ecma-262/7.0/#sec-iteratorcomplete', | ||
IteratorValue: 'https://ecma-international.org/ecma-262/7.0/#sec-iteratorvalue', | ||
IteratorStep: 'https://ecma-international.org/ecma-262/7.0/#sec-iteratorstep', | ||
IteratorClose: 'https://ecma-international.org/ecma-262/7.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'https://ecma-international.org/ecma-262/7.0/#sec-createiterresultobject', | ||
CreateListIterator: 'https://ecma-international.org/ecma-262/7.0/#sec-createlistiterator', | ||
Type: 'https://ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types', | ||
thisNumberValue: 'https://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-number-prototype-object', | ||
thisTimeValue: 'https://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'https://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'https://ecma-international.org/ecma-262/7.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'https://ecma-international.org/ecma-262/7.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'https://ecma-international.org/ecma-262/7.0/#sec-isconcatspreadable', | ||
IsPromise: 'https://ecma-international.org/ecma-262/7.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'https://ecma-international.org/ecma-262/7.0/#sec-arrayspeciescreate', | ||
ObjectCreate: 'https://ecma-international.org/ecma-262/7.0/#sec-objectcreate', | ||
AdvanceStringIndex: 'https://ecma-international.org/ecma-262/7.0/#sec-advancestringindex', | ||
OrdinarySet: 'https://ecma-international.org/ecma-262/7.0/#sec-ordinaryset', | ||
NormalCompletion: 'https://ecma-international.org/ecma-262/7.0/#sec-normalcompletion' | ||
}; |
'use strict'; | ||
module.exports = { | ||
IsPropertyDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-property-descriptor-specification-type', | ||
IsAccessorDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'http://ecma-international.org/ecma-262/8.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'http://ecma-international.org/ecma-262/8.0/#sec-toprimitive', | ||
ToBoolean: 'http://ecma-international.org/ecma-262/8.0/#sec-toboolean', | ||
ToNumber: 'http://ecma-international.org/ecma-262/8.0/#sec-tonumber', | ||
ToInteger: 'http://ecma-international.org/ecma-262/8.0/#sec-tointeger', | ||
ToInt32: 'http://ecma-international.org/ecma-262/8.0/#sec-toint32', | ||
ToUint32: 'http://ecma-international.org/ecma-262/8.0/#sec-touint32', | ||
ToInt16: 'http://ecma-international.org/ecma-262/8.0/#sec-toint16', | ||
ToUint16: 'http://ecma-international.org/ecma-262/8.0/#sec-touint16', | ||
ToInt8: 'http://ecma-international.org/ecma-262/8.0/#sec-toint8', | ||
ToUint8: 'http://ecma-international.org/ecma-262/8.0/#sec-touint8', | ||
ToUint8Clamp: 'http://ecma-international.org/ecma-262/8.0/#sec-touint8clamp', | ||
ToString: 'http://ecma-international.org/ecma-262/8.0/#sec-tostring', | ||
ToObject: 'http://ecma-international.org/ecma-262/8.0/#sec-toobject', | ||
ToPropertyKey: 'http://ecma-international.org/ecma-262/8.0/#sec-topropertykey', | ||
ToLength: 'http://ecma-international.org/ecma-262/8.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'http://ecma-international.org/ecma-262/8.0/#sec-canonicalnumericindexstring', | ||
ToIndex: 'http://ecma-international.org/ecma-262/8.0/#sec-toindex', | ||
RequireObjectCoercible: 'http://ecma-international.org/ecma-262/8.0/#sec-requireobjectcoercible', | ||
IsArray: 'http://ecma-international.org/ecma-262/8.0/#sec-isarray', | ||
IsCallable: 'http://ecma-international.org/ecma-262/8.0/#sec-iscallable', | ||
IsConstructor: 'http://ecma-international.org/ecma-262/8.0/#sec-isconstructor', | ||
IsExtensible: 'http://ecma-international.org/ecma-262/8.0/#sec-isextensible-o', | ||
IsInteger: 'http://ecma-international.org/ecma-262/8.0/#sec-isinteger', | ||
IsPropertyKey: 'http://ecma-international.org/ecma-262/8.0/#sec-ispropertykey', | ||
IsRegExp: 'http://ecma-international.org/ecma-262/8.0/#sec-isregexp', | ||
SameValue: 'http://ecma-international.org/ecma-262/8.0/#sec-samevalue', | ||
SameValueZero: 'http://ecma-international.org/ecma-262/8.0/#sec-samevaluezero', | ||
SameValueNonNumber: 'http://ecma-international.org/ecma-262/8.0/#sec-samevaluenonnumber', | ||
Get: 'http://ecma-international.org/ecma-262/8.0/#sec-get-o-p', | ||
GetV: 'http://ecma-international.org/ecma-262/8.0/#sec-getv', | ||
Set: 'http://ecma-international.org/ecma-262/8.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'http://ecma-international.org/ecma-262/8.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'http://ecma-international.org/ecma-262/8.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'http://ecma-international.org/ecma-262/8.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'http://ecma-international.org/ecma-262/8.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'http://ecma-international.org/ecma-262/8.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'http://ecma-international.org/ecma-262/8.0/#sec-getmethod', | ||
HasProperty: 'http://ecma-international.org/ecma-262/8.0/#sec-hasproperty', | ||
HasOwnProperty: 'http://ecma-international.org/ecma-262/8.0/#sec-hasownproperty', | ||
Call: 'http://ecma-international.org/ecma-262/8.0/#sec-call', | ||
Construct: 'http://ecma-international.org/ecma-262/8.0/#sec-construct', | ||
SetIntegrityLevel: 'http://ecma-international.org/ecma-262/8.0/#sec-setintegritylevel', | ||
TestIntegrityLevel: 'http://ecma-international.org/ecma-262/8.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'http://ecma-international.org/ecma-262/8.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'http://ecma-international.org/ecma-262/8.0/#sec-createlistfromarraylike', | ||
Invoke: 'http://ecma-international.org/ecma-262/8.0/#sec-invoke', | ||
OrdinaryHasInstance: 'http://ecma-international.org/ecma-262/8.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'http://ecma-international.org/ecma-262/8.0/#sec-speciesconstructor', | ||
EnumerableOwnProperties: 'http://ecma-international.org/ecma-262/8.0/#sec-enumerableownproperties', | ||
GetIterator: 'http://ecma-international.org/ecma-262/8.0/#sec-getiterator', | ||
IteratorNext: 'http://ecma-international.org/ecma-262/8.0/#sec-iteratornext', | ||
IteratorComplete: 'http://ecma-international.org/ecma-262/8.0/#sec-iteratorcomplete', | ||
IteratorValue: 'http://ecma-international.org/ecma-262/8.0/#sec-iteratorvalue', | ||
IteratorStep: 'http://ecma-international.org/ecma-262/8.0/#sec-iteratorstep', | ||
IteratorClose: 'http://ecma-international.org/ecma-262/8.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'http://ecma-international.org/ecma-262/8.0/#sec-createiterresultobject', | ||
CreateListIterator: 'http://ecma-international.org/ecma-262/8.0/#sec-createlistiterator', | ||
Type: 'http://ecma-international.org/ecma-262/8.0/#sec-ecmascript-language-types', | ||
thisNumberValue: 'http://ecma-international.org/ecma-262/8.0/#sec-properties-of-the-number-prototype-object', | ||
thisTimeValue: 'http://ecma-international.org/ecma-262/8.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'http://ecma-international.org/ecma-262/8.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'http://ecma-international.org/ecma-262/8.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'http://ecma-international.org/ecma-262/8.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'http://ecma-international.org/ecma-262/8.0/#sec-isconcatspreadable', | ||
IsPromise: 'http://ecma-international.org/ecma-262/8.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'http://ecma-international.org/ecma-262/8.0/#sec-arrayspeciescreate', | ||
AdvanceStringIndex: 'http://ecma-international.org/ecma-262/6.0/#sec-advancestringindex' | ||
IsPropertyDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-property-descriptor-specification-type', | ||
IsAccessorDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-isaccessordescriptor', | ||
IsDataDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-isdatadescriptor', | ||
IsGenericDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-isgenericdescriptor', | ||
FromPropertyDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-frompropertydescriptor', | ||
ToPropertyDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-topropertydescriptor', | ||
CompletePropertyDescriptor: 'https://ecma-international.org/ecma-262/8.0/#sec-completepropertydescriptor', | ||
ToPrimitive: 'https://ecma-international.org/ecma-262/8.0/#sec-toprimitive', | ||
ToBoolean: 'https://ecma-international.org/ecma-262/8.0/#sec-toboolean', | ||
ToNumber: 'https://ecma-international.org/ecma-262/8.0/#sec-tonumber', | ||
ToInteger: 'https://ecma-international.org/ecma-262/8.0/#sec-tointeger', | ||
ToInt32: 'https://ecma-international.org/ecma-262/8.0/#sec-toint32', | ||
ToUint32: 'https://ecma-international.org/ecma-262/8.0/#sec-touint32', | ||
ToInt16: 'https://ecma-international.org/ecma-262/8.0/#sec-toint16', | ||
ToUint16: 'https://ecma-international.org/ecma-262/8.0/#sec-touint16', | ||
ToInt8: 'https://ecma-international.org/ecma-262/8.0/#sec-toint8', | ||
ToUint8: 'https://ecma-international.org/ecma-262/8.0/#sec-touint8', | ||
ToUint8Clamp: 'https://ecma-international.org/ecma-262/8.0/#sec-touint8clamp', | ||
ToString: 'https://ecma-international.org/ecma-262/8.0/#sec-tostring', | ||
ToObject: 'https://ecma-international.org/ecma-262/8.0/#sec-toobject', | ||
ToPropertyKey: 'https://ecma-international.org/ecma-262/8.0/#sec-topropertykey', | ||
ToLength: 'https://ecma-international.org/ecma-262/8.0/#sec-tolength', | ||
CanonicalNumericIndexString: 'https://ecma-international.org/ecma-262/8.0/#sec-canonicalnumericindexstring', | ||
ToIndex: 'https://ecma-international.org/ecma-262/8.0/#sec-toindex', | ||
RequireObjectCoercible: 'https://ecma-international.org/ecma-262/8.0/#sec-requireobjectcoercible', | ||
IsArray: 'https://ecma-international.org/ecma-262/8.0/#sec-isarray', | ||
IsCallable: 'https://ecma-international.org/ecma-262/8.0/#sec-iscallable', | ||
IsConstructor: 'https://ecma-international.org/ecma-262/8.0/#sec-isconstructor', | ||
IsExtensible: 'https://ecma-international.org/ecma-262/8.0/#sec-isextensible-o', | ||
IsInteger: 'https://ecma-international.org/ecma-262/8.0/#sec-isinteger', | ||
IsPropertyKey: 'https://ecma-international.org/ecma-262/8.0/#sec-ispropertykey', | ||
IsRegExp: 'https://ecma-international.org/ecma-262/8.0/#sec-isregexp', | ||
SameValue: 'https://ecma-international.org/ecma-262/8.0/#sec-samevalue', | ||
SameValueZero: 'https://ecma-international.org/ecma-262/8.0/#sec-samevaluezero', | ||
SameValueNonNumber: 'https://ecma-international.org/ecma-262/8.0/#sec-samevaluenonnumber', | ||
Get: 'https://ecma-international.org/ecma-262/8.0/#sec-get-o-p', | ||
GetV: 'https://ecma-international.org/ecma-262/8.0/#sec-getv', | ||
Set: 'https://ecma-international.org/ecma-262/8.0/#sec-set-o-p-v-throw', | ||
CreateDataProperty: 'https://ecma-international.org/ecma-262/8.0/#sec-createdataproperty', | ||
CreateMethodProperty: 'https://ecma-international.org/ecma-262/8.0/#sec-createmethodproperty', | ||
CreateDataPropertyOrThrow: 'https://ecma-international.org/ecma-262/8.0/#sec-createdatapropertyorthrow', | ||
DefinePropertyOrThrow: 'https://ecma-international.org/ecma-262/8.0/#sec-definepropertyorthrow', | ||
DeletePropertyOrThrow: 'https://ecma-international.org/ecma-262/8.0/#sec-deletepropertyorthrow', | ||
GetMethod: 'https://ecma-international.org/ecma-262/8.0/#sec-getmethod', | ||
HasProperty: 'https://ecma-international.org/ecma-262/8.0/#sec-hasproperty', | ||
HasOwnProperty: 'https://ecma-international.org/ecma-262/8.0/#sec-hasownproperty', | ||
Call: 'https://ecma-international.org/ecma-262/8.0/#sec-call', | ||
Construct: 'https://ecma-international.org/ecma-262/8.0/#sec-construct', | ||
SetIntegrityLevel: 'https://ecma-international.org/ecma-262/8.0/#sec-setintegritylevel', | ||
TestIntegrityLevel: 'https://ecma-international.org/ecma-262/8.0/#sec-testintegritylevel', | ||
CreateArrayFromList: 'https://ecma-international.org/ecma-262/8.0/#sec-createarrayfromlist', | ||
CreateListFromArrayLike: 'https://ecma-international.org/ecma-262/8.0/#sec-createlistfromarraylike', | ||
Invoke: 'https://ecma-international.org/ecma-262/8.0/#sec-invoke', | ||
OrdinaryHasInstance: 'https://ecma-international.org/ecma-262/8.0/#sec-ordinaryhasinstance', | ||
SpeciesConstructor: 'https://ecma-international.org/ecma-262/8.0/#sec-speciesconstructor', | ||
EnumerableOwnProperties: 'https://ecma-international.org/ecma-262/8.0/#sec-enumerableownproperties', | ||
GetIterator: 'https://ecma-international.org/ecma-262/8.0/#sec-getiterator', | ||
IteratorNext: 'https://ecma-international.org/ecma-262/8.0/#sec-iteratornext', | ||
IteratorComplete: 'https://ecma-international.org/ecma-262/8.0/#sec-iteratorcomplete', | ||
IteratorValue: 'https://ecma-international.org/ecma-262/8.0/#sec-iteratorvalue', | ||
IteratorStep: 'https://ecma-international.org/ecma-262/8.0/#sec-iteratorstep', | ||
IteratorClose: 'https://ecma-international.org/ecma-262/8.0/#sec-iteratorclose', | ||
CreateIterResultObject: 'https://ecma-international.org/ecma-262/8.0/#sec-createiterresultobject', | ||
CreateListIterator: 'https://ecma-international.org/ecma-262/8.0/#sec-createlistiterator', | ||
Type: 'https://ecma-international.org/ecma-262/8.0/#sec-ecmascript-language-types', | ||
thisNumberValue: 'https://ecma-international.org/ecma-262/8.0/#sec-properties-of-the-number-prototype-object', | ||
thisTimeValue: 'https://ecma-international.org/ecma-262/8.0/#sec-properties-of-the-date-prototype-object', | ||
thisStringValue: 'https://ecma-international.org/ecma-262/8.0/#sec-properties-of-the-string-prototype-object', | ||
RegExpExec: 'https://ecma-international.org/ecma-262/8.0/#sec-regexpexec', | ||
RegExpBuiltinExec: 'https://ecma-international.org/ecma-262/8.0/#sec-regexpbuiltinexec', | ||
IsConcatSpreadable: 'https://ecma-international.org/ecma-262/8.0/#sec-isconcatspreadable', | ||
IsPromise: 'https://ecma-international.org/ecma-262/8.0/#sec-ispromise', | ||
ArraySpeciesCreate: 'https://ecma-international.org/ecma-262/8.0/#sec-arrayspeciescreate', | ||
ObjectCreate: 'https://ecma-international.org/ecma-262/8.0/#sec-objectcreate', | ||
AdvanceStringIndex: 'https://ecma-international.org/ecma-262/8.0/#sec-advancestringindex', | ||
OrdinarySet: 'https://ecma-international.org/ecma-262/8.0/#sec-ordinaryset', | ||
NormalCompletion: 'https://ecma-international.org/ecma-262/8.0/#sec-normalcompletion', | ||
IsSharedArrayBuffer: 'https://ecma-international.org/ecma-262/8.0/#sec-issharedarraybuffer', | ||
}; |
'use strict'; | ||
module.exports = { | ||
IsPropertyDescriptor: 'http://ecma-international.org/ecma-262/5.1/#sec-8.10', | ||
IsAccessorDescriptor: 'http://ecma-international.org/ecma-262/5.1/#sec-8.10.1', | ||
IsDataDescriptor: 'http://ecma-international.org/ecma-262/5.1/#sec-8.10.2', | ||
IsGenericDescriptor: 'http://ecma-international.org/ecma-262/5.1/#sec-8.10.3', | ||
FromPropertyDescriptor: 'http://ecma-international.org/ecma-262/5.1/#sec-8.10.4', | ||
ToPropertyDescriptor: 'http://ecma-international.org/ecma-262/5.1/#sec-8.10.5' | ||
IsPropertyDescriptor: 'https://ecma-international.org/ecma-262/5.1/#sec-8.10', | ||
IsAccessorDescriptor: 'https://ecma-international.org/ecma-262/5.1/#sec-8.10.1', | ||
IsDataDescriptor: 'https://ecma-international.org/ecma-262/5.1/#sec-8.10.2', | ||
IsGenericDescriptor: 'https://ecma-international.org/ecma-262/5.1/#sec-8.10.3', | ||
FromPropertyDescriptor: 'https://ecma-international.org/ecma-262/5.1/#sec-8.10.4', | ||
ToPropertyDescriptor: 'https://ecma-international.org/ecma-262/5.1/#sec-8.10.5' | ||
}; |
{ | ||
"name": "es-abstract", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"author": { | ||
@@ -25,3 +25,3 @@ "name": "Jordan Harband", | ||
"tests-only": "node test", | ||
"coverage": "nyc npm run --silent tests-only >/dev/null 2>&1", | ||
"coverage": "nyc npm run --silent tests-only >/dev/null", | ||
"postcoverage": "nyc report", | ||
@@ -59,3 +59,3 @@ "lint": "npm run --silent jscs && npm run --silent eslint", | ||
"editorconfig-tools": "^0.1.1", | ||
"eslint": "^4.19.0", | ||
"eslint": "^4.19.1", | ||
"foreach": "^2.0.5", | ||
@@ -65,5 +65,6 @@ "jscs": "^3.0.7", | ||
"nyc": "^10.3.2", | ||
"object-inspect": "^1.6.0", | ||
"object-is": "^1.0.1", | ||
"object.assign": "^4.1.0", | ||
"replace": "^0.3.0", | ||
"replace": "^1.0.0", | ||
"safe-publish-latest": "^1.1.1", | ||
@@ -93,3 +94,9 @@ "semver": "^5.5.0", | ||
"node": ">= 0.4" | ||
}, | ||
"greenkeeper": { | ||
"//": "nyc is ignored because it requires node 4+, and we support older than that", | ||
"ignore": [ | ||
"nyc" | ||
] | ||
} | ||
} |
@@ -41,5 +41,5 @@ # es-abstract <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
[npm-badge-png]: https://nodei.co/npm/es-abstract.png?downloads=true&stars=true | ||
[license-image]: http://img.shields.io/npm/l/es-abstract.svg | ||
[license-image]: https://img.shields.io/npm/l/es-abstract.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/es-abstract.svg | ||
[downloads-url]: http://npm-stat.com/charts.html?package=es-abstract | ||
[downloads-image]: https://img.shields.io/npm/dm/es-abstract.svg | ||
[downloads-url]: https://npm-stat.com/charts.html?package=es-abstract |
@@ -6,3 +6,3 @@ 'use strict'; | ||
module.exports = function diffOperations(actual, expected) { | ||
module.exports = function diffOperations(actual, expected, expectedMissing) { | ||
var actualKeys = keys(actual); | ||
@@ -19,3 +19,3 @@ var expectedKeys = keys(expected); | ||
forEach(expectedKeys, function (op) { | ||
if (!(op in actual)) { | ||
if (!(op in actual) && expectedMissing.indexOf(op) === -1) { | ||
missing.push(op); | ||
@@ -22,0 +22,0 @@ } |
@@ -8,5 +8,5 @@ 'use strict'; | ||
// jscs:disable | ||
var expectedMissing = ['CreateMethodProperty', 'DefinePropertyOrThrow', 'DeletePropertyOrThrow', 'Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'EnumerableOwnNames', 'CreateListIterator', 'thisNumberValue', 'thisTimeValue', 'thisStringValue', 'RegExpBuiltinExec', 'IsPromise']; | ||
var expectedMissing = ['CreateMethodProperty', 'DefinePropertyOrThrow', 'DeletePropertyOrThrow', 'Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'EnumerableOwnNames', 'GetIterator', 'IteratorNext', 'IteratorComplete', 'IteratorValue', 'IteratorStep', 'IteratorClose', 'CreateListIterator', 'thisNumberValue', 'thisTimeValue', 'thisStringValue', 'RegExpBuiltinExec', 'IsPromise', 'NormalCompletion']; | ||
// jscs:enable | ||
require('./tests').es2015(ES, ops, expectedMissing); |
@@ -8,5 +8,5 @@ 'use strict'; | ||
// jscs:disable | ||
var expectedMissing = ['CreateMethodProperty', 'DefinePropertyOrThrow', 'DeletePropertyOrThrow', 'Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'EnumerableOwnNames', 'CreateListIterator', 'thisNumberValue', 'thisTimeValue', 'thisStringValue', 'RegExpBuiltinExec', 'IsPromise']; | ||
var expectedMissing = ['CreateMethodProperty', 'DefinePropertyOrThrow', 'DeletePropertyOrThrow', 'Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'EnumerableOwnNames', 'GetIterator', 'IteratorNext', 'IteratorComplete', 'IteratorValue', 'IteratorStep', 'IteratorClose', 'CreateListIterator', 'thisNumberValue', 'thisTimeValue', 'thisStringValue', 'RegExpBuiltinExec', 'IsPromise', 'OrdinarySet', 'NormalCompletion']; | ||
// jscs:enable | ||
require('./tests').es2016(ES, ops, expectedMissing); |
@@ -8,5 +8,5 @@ 'use strict'; | ||
// jscs:disable | ||
var expectedMissing = ['CreateMethodProperty', 'DefinePropertyOrThrow', 'DeletePropertyOrThrow', 'Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'EnumerableOwnProperties', 'CreateListIterator', 'thisNumberValue', 'thisTimeValue', 'thisStringValue', 'RegExpBuiltinExec', 'IsPromise']; | ||
var expectedMissing = ['CreateMethodProperty', 'DefinePropertyOrThrow', 'DeletePropertyOrThrow', 'Construct', 'SetIntegrityLevel', 'TestIntegrityLevel', 'CreateArrayFromList', 'CreateListFromArrayLike', 'OrdinaryHasInstance', 'EnumerableOwnProperties', 'GetIterator', 'IteratorNext', 'IteratorComplete', 'IteratorValue', 'IteratorStep', 'IteratorClose', 'CreateListIterator', 'thisNumberValue', 'thisTimeValue', 'thisStringValue', 'RegExpBuiltinExec', 'IsPromise', 'OrdinarySet', 'NormalCompletion', 'IsSharedArrayBuffer']; | ||
// jscs:enable | ||
require('./tests').es2017(ES, ops, expectedMissing); |
@@ -21,2 +21,4 @@ 'use strict'; | ||
require('./GetIntrinsic'); | ||
require('./es5'); | ||
@@ -23,0 +25,0 @@ require('./es6'); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var is = require('object-is'); | ||
var debug = require('util').format; | ||
var debug = require('object-inspect'); | ||
var assign = require('object.assign'); | ||
@@ -32,9 +32,14 @@ | ||
var hasGroups = 'groups' in (/a/).exec('a'); | ||
var groups = function groups(matchObject) { | ||
return hasGroups ? assign(matchObject, { groups: matchObject.groups }) : matchObject; | ||
}; | ||
var es2015 = function ES2015(ES, ops, expectedMissing) { | ||
test('has expected operations', function (t) { | ||
var diff = diffOps(ES, ops); | ||
var diff = diffOps(ES, ops, expectedMissing); | ||
t.deepEqual(diff.extra, [], 'no extra ops'); | ||
t.deepEqual(diff.missing, expectedMissing, 'no unexpected missing ops'); | ||
t.deepEqual(diff.missing, [], 'no unexpected missing ops'); | ||
@@ -1175,4 +1180,4 @@ t.end(); | ||
var match3 = ES.RegExpExec(R, S); | ||
st.deepEqual(match1, assign(['a'], { index: 0, input: S }), 'match object 1 is as expected'); | ||
st.deepEqual(match2, assign(['a'], { index: 1, input: S }), 'match object 2 is as expected'); | ||
st.deepEqual(match1, assign(['a'], groups({ index: 0, input: S })), 'match object 1 is as expected'); | ||
st.deepEqual(match2, assign(['a'], groups({ index: 1, input: S })), 'match object 2 is as expected'); | ||
st.equal(match3, null, 'match 3 is null as expected'); | ||
@@ -1189,4 +1194,4 @@ st.end(); | ||
var match3 = ES.RegExpExec(R, S); | ||
st.deepEqual(match1, assign(['a'], { index: 0, input: S }), 'match object 1 is as expected'); | ||
st.deepEqual(match2, assign(['a'], { index: 1, input: S }), 'match object 2 is as expected'); | ||
st.deepEqual(match1, assign(['a'], groups({ index: 0, input: S })), 'match object 1 is as expected'); | ||
st.deepEqual(match2, assign(['a'], groups({ index: 1, input: S })), 'match object 2 is as expected'); | ||
st.equal(match3, null, 'match 3 is null as expected'); | ||
@@ -1437,2 +1442,53 @@ st.end(); | ||
test('ObjectCreate', function (t) { | ||
forEach(v.nonNullPrimitives, function (value) { | ||
t['throws']( | ||
function () { ES.ObjectCreate(value); }, | ||
TypeError, | ||
debug(value) + ' is not null, or an object' | ||
); | ||
}); | ||
t.test('proto arg', function (st) { | ||
var Parent = function Parent() {}; | ||
Parent.prototype.foo = {}; | ||
var child = ES.ObjectCreate(Parent.prototype); | ||
st.equal(child instanceof Parent, true, 'child is instanceof Parent'); | ||
st.equal(child.foo, Parent.prototype.foo, 'child inherits properties from Parent.prototype'); | ||
st.end(); | ||
}); | ||
t.test('internal slots arg', function (st) { | ||
st.doesNotThrow(function () { ES.ObjectCreate(null, []); }, 'an empty slot list is valid'); | ||
st['throws']( | ||
function () { ES.ObjectCreate(null, ['a']); }, | ||
SyntaxError, | ||
'internal slots are not supported' | ||
); | ||
st.end(); | ||
}); | ||
t.test('null proto', { skip: !Object.create }, function (st) { | ||
st.equal('toString' in ({}), true, 'normal objects have toString'); | ||
st.equal('toString' in ES.ObjectCreate(null), false, 'makes a null object'); | ||
st.end(); | ||
}); | ||
t.test('null proto when no native Object.create', { skip: Object.create }, function (st) { | ||
st['throws']( | ||
function () { ES.ObjectCreate(null); }, | ||
SyntaxError, | ||
'without a native Object.create, can not create null objects' | ||
); | ||
st.end(); | ||
}); | ||
t.end(); | ||
}); | ||
test('AdvanceStringIndex', function (t) { | ||
@@ -1447,42 +1503,28 @@ forEach(v.nonStrings, function (nonString) { | ||
forEach(v.nonIntegerNumbers, function (nonInteger) { | ||
var notInts = v.nonNumbers.concat( | ||
v.nonIntegerNumbers, | ||
[Infinity, -Infinity, NaN, [], new Date(), Math.pow(2, 53), -1] | ||
); | ||
forEach(notInts, function (nonInt) { | ||
t['throws']( | ||
function () { ES.AdvanceStringIndex('', nonInteger, false); }, | ||
function () { ES.AdvanceStringIndex('abc', nonInt); }, | ||
TypeError, | ||
'"index" argument must be an integer; ' + debug(nonInteger) + ' is not' | ||
'"index" argument must be an integer, ' + debug(nonInt) + ' is not.' | ||
); | ||
}); | ||
forEach([-1, -42], function (negative) { | ||
t['throws']( | ||
function () { ES.AdvanceStringIndex('', negative, false); }, | ||
RangeError, | ||
'"index" argument must be a non-negative integer; ' + debug(negative) + ' is not' | ||
); | ||
}); | ||
t['throws']( | ||
function () { ES.AdvanceStringIndex('', MAX_SAFE_INTEGER + 1, false); }, | ||
RangeError, | ||
'too large integers throw' | ||
); | ||
forEach(v.nonBooleans, function (nonBoolean) { | ||
t['throws']( | ||
function () { ES.AdvanceStringIndex('', 0, nonBoolean); }, | ||
function () { ES.AdvanceStringIndex('abc', 0, nonBoolean); }, | ||
TypeError, | ||
'"unicode" argument must be a Boolean; ' + debug(nonBoolean) + ' is not' | ||
debug(nonBoolean) + ' is not a Boolean' | ||
); | ||
}); | ||
t.test('when unicode is false', function (st) { | ||
st.equal(ES.AdvanceStringIndex('', 0, false), 1, 'index is incremented by 1'); | ||
st.equal(ES.AdvanceStringIndex('abc', 0, false), 1, 'index is incremented by 1'); | ||
st.equal(ES.AdvanceStringIndex('', 3, false), 4, 'index is incremented by 1'); | ||
st.equal(ES.AdvanceStringIndex('abc', 3, false), 4, 'index is incremented by 1'); | ||
var str = 'a\uD83D\uDCA9c'; | ||
st.test('when the index is within the string', function (s2t) { | ||
s2t.equal(ES.AdvanceStringIndex('abc', 0, false), 1, '0 -> 1'); | ||
s2t.equal(ES.AdvanceStringIndex('abc', 1, false), 2, '1 -> 2'); | ||
s2t.equal(ES.AdvanceStringIndex('abc', 2, false), 3, '2 -> 3'); | ||
s2t.end(); | ||
}); | ||
t.test('non-unicode mode', function (st) { | ||
for (var i = 0; i < str.length + 2; i += 1) { | ||
st.equal(ES.AdvanceStringIndex(str, i, false), i + 1, i + ' advances to ' + (i + 1)); | ||
} | ||
@@ -1492,30 +1534,35 @@ st.end(); | ||
t.test('when unicode is true', function (st) { | ||
st.test('when index + 1 >= length', function (s2t) { | ||
t.equal(ES.AdvanceStringIndex('', 0, true), 1, 'index is incremented by 1'); | ||
t.equal(ES.AdvanceStringIndex('a', 0, true), 1, 'index is incremented by 1'); | ||
t.equal(ES.AdvanceStringIndex('a', 5, true), 6, 'index is incremented by 1'); | ||
s2t.end(); | ||
}); | ||
t.test('unicode mode', function (st) { | ||
st.equal(ES.AdvanceStringIndex(str, 0, true), 1, '0 advances to 1'); | ||
st.equal(ES.AdvanceStringIndex(str, 1, true), 3, '1 advances to 3'); | ||
st.equal(ES.AdvanceStringIndex(str, 2, true), 3, '2 advances to 3'); | ||
st.equal(ES.AdvanceStringIndex(str, 3, true), 4, '3 advances to 4'); | ||
st.equal(ES.AdvanceStringIndex(str, 4, true), 5, '4 advances to 5'); | ||
st.test('when the index is within the string', function (s2t) { | ||
s2t.equal(ES.AdvanceStringIndex('abc', 0, true), 1, '0 -> 1'); | ||
s2t.equal(ES.AdvanceStringIndex('abc', 1, true), 2, '1 -> 2'); | ||
s2t.equal(ES.AdvanceStringIndex('abc', 2, true), 3, '2 -> 3'); | ||
s2t.end(); | ||
}); | ||
st.end(); | ||
}); | ||
st.test('surrogate pairs', function (s2t) { | ||
var lowestPair = String.fromCharCode('0xD800') + String.fromCharCode('0xDC00'); | ||
var highestPair = String.fromCharCode('0xDBFF') + String.fromCharCode('0xDFFF'); | ||
var poop = String.fromCharCode('0xD83D') + String.fromCharCode('0xDCA9'); | ||
s2t.equal(ES.AdvanceStringIndex(lowestPair, 0, true), 2, 'lowest surrogate pair, 0 -> 2'); | ||
s2t.equal(ES.AdvanceStringIndex(highestPair, 0, true), 2, 'highest surrogate pair, 0 -> 2'); | ||
s2t.equal(ES.AdvanceStringIndex(poop, 0, true), 2, 'poop, 0 -> 2'); | ||
s2t.end(); | ||
}); | ||
t.test('lone surrogates', function (st) { | ||
var halfPoo = 'a\uD83Dc'; | ||
st.equal(ES.AdvanceStringIndex(halfPoo, 0, true), 1, '0 advances to 1'); | ||
st.equal(ES.AdvanceStringIndex(halfPoo, 1, true), 2, '1 advances to 2'); | ||
st.equal(ES.AdvanceStringIndex(halfPoo, 2, true), 3, '2 advances to 3'); | ||
st.equal(ES.AdvanceStringIndex(halfPoo, 3, true), 4, '3 advances to 4'); | ||
st.end(); | ||
}); | ||
t.test('surrogate pairs', function (st) { | ||
var lowestPair = String.fromCharCode('0xD800') + String.fromCharCode('0xDC00'); | ||
var highestPair = String.fromCharCode('0xDBFF') + String.fromCharCode('0xDFFF'); | ||
var poop = String.fromCharCode('0xD83D') + String.fromCharCode('0xDCA9'); | ||
st.equal(ES.AdvanceStringIndex(lowestPair, 0, true), 2, 'lowest surrogate pair, 0 -> 2'); | ||
st.equal(ES.AdvanceStringIndex(highestPair, 0, true), 2, 'highest surrogate pair, 0 -> 2'); | ||
st.equal(ES.AdvanceStringIndex(poop, 0, true), 2, 'poop, 0 -> 2'); | ||
st.end(); | ||
}); | ||
t.end(); | ||
@@ -1522,0 +1569,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166038
40
3308
14