提交 6db20958 编写于 作者: MengZian's avatar MengZian

1696081050485

上级 c45db217
/*!
arrayLikeMethods.js
date 1693145244301 [Sun Aug 27 2023 22:07:24 GMT+0800 (China Standard Time)]
date 1696081050485 [Sat Sep 30 2023 21:37:30 GMT+0800 (China Standard Time)]
(c) 2023 Bright_Leader
Licensed under the Apache-2.0.
*/
......@@ -433,8 +433,16 @@ const enumerateObjectOwnProperties=function(callbackFn,callbackFnThisArg){
return self;
};
const Object_valueOf=Object_prototype.valueOf; /* http://262.ecma-international.org/5.1/#sec-15.2.4.4 */
const toObject=function(value){
return returnOrThrowObjectType(
Function_call[call_key](Object_valueOf,value)
);
};
const arrayLikeIndexOf=function(searchElement,fromIndex){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.14 */
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
if(len===0)return -1;
const n_var=isNullish(fromIndex)?0:forceToInteger(fromIndex);
......@@ -455,7 +463,7 @@ const arrayLikeIndexOf=function(searchElement,fromIndex){ /* http://262.ecma-int
};
const arrayLikeLastIndexOf=function(searchElement,fromIndex){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.15 */
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
if(len===0)return -1;
const n_var=isNullish(fromIndex)?len:forceToInteger(fromIndex);
......@@ -472,7 +480,7 @@ const arrayLikeLastIndexOf=function(searchElement,fromIndex){ /* http://262.ecma
const arrayLikeEvery=function(callbackFn,callbackFnThisArg){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.16 */
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
let k_var,v_var;
......@@ -490,7 +498,7 @@ const arrayLikeEvery=function(callbackFn,callbackFnThisArg){ /* http://262.ecma-
const arrayLikeSome=function(callbackFn,callbackFnThisArg){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.17 */
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
let key,value;
......@@ -511,7 +519,7 @@ Note that this function is different from
"Array.prototype.forEach" defined in ECMAScript 5 or above.
*/
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
let key,value;
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
const len=toUint32(self[length_key]);
......@@ -547,7 +555,7 @@ const definePropertyIsFunction=isFunction(defineProperty);
const arrayLikeMap=function(callbackFn,callbackFnThisArg){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.19 */
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const newArray=new Array_constructor(len);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
......@@ -572,7 +580,7 @@ const arrayLikeMap=function(callbackFn,callbackFnThisArg){ /* http://262.ecma-in
const arrayLikeFilter=function(callbackFn,callbackFnThisArg){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.20 */
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const callbackFnThisArgIsNullish=isNullish(callbackFnThisArg);
const len=toUint32(self[length_key]);
let k_var,t_var,v_var;
......@@ -601,7 +609,7 @@ const reduceError="Reduce of empty array with no initial value!";
const arrayLikeReduce=function(callbackFn,initialValue){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.21 */
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const initialValueIsPresent=1 in arguments;
if(
......@@ -628,7 +636,7 @@ const arrayLikeReduce=function(callbackFn,initialValue){ /* http://262.ecma-inte
const arrayLikeReduceRight=function(callbackFn,initialValue){ /* http://262.ecma-international.org/5.1/#sec-15.4.4.22 */
returnOrThrowFunction(callbackFn);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toUint32(self[length_key]);
const initialValueIsPresent=1 in arguments;
if(
......@@ -664,7 +672,7 @@ const toLength=function(num){ /* http://262.ecma-international.org/6.0/#sec-tole
const arrayLikeFindIndex=function(predicate,predicateThisArg){ /* http://262.ecma-international.org/6.0/#sec-array.prototype.findindex */
returnOrThrowFunction(predicate);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toLength(self[length_key]);
const predicateThisArgIsNullish=isNullish(predicateThisArg);
let key,value;
......@@ -682,7 +690,7 @@ const undef=void null;
const arrayLikeFind=function(predicate,predicateThisArg){ /* http://262.ecma-international.org/6.0/#sec-array.prototype.find */
returnOrThrowFunction(predicate);
const self=new Object_constructor(this);
const self=toObject(this);
const len=toLength(self[length_key]);
const predicateThisArgIsNullish=isNullish(predicateThisArg);
let key,value;
......@@ -697,7 +705,7 @@ const arrayLikeFind=function(predicate,predicateThisArg){ /* http://262.ecma-int
};
const arrayLikeCopyWithin=function(target,start,end){ /* http://262.ecma-international.org/6.0/#sec-array.prototype.copywithin */
const self=new Object_constructor(this);
const self=toObject(this);
const len=toLength(self[length_key]);
const relativeTarget=forceToInteger(target);
const relativeStart=forceToInteger(start);
......@@ -728,7 +736,7 @@ const arrayLikeCopyWithin=function(target,start,end){ /* http://262.ecma-interna
};
const arrayLikeFill=function(value,start,end){ /* http://262.ecma-international.org/6.0/#sec-array.prototype.fill */
const self=new Object_constructor(this);
const self=toObject(this);
const len=toLength(self[length_key]);
const relativeStart=forceToInteger(start);
const relativeEnd=end===undef?len:forceToInteger(end);
......@@ -759,7 +767,7 @@ const sameValueZero=function(valueA,valueB){ /* http://262.ecma-international.or
};
const arrayLikeIncludes=function(searchElement,fromIndex){ /* http://262.ecma-international.org/7.0/#sec-array.prototype.includes */
const self=new Object_constructor(this);
const self=toObject(this);
const len=toLength(self[length_key]);
if(len===0)return False;
const n_var=fromIndex===undef?0:forceToInteger(fromIndex);
......@@ -864,14 +872,7 @@ const iterator_wellKnownSymbol=retrieveWellKnownSymbol(iterator_key),
isConcatSpreadable_wellKnownSymbol=retrieveWellKnownSymbol(isConcatSpreadable_key), /* http://262.ecma-international.org/6.0/#sec-symbol.isconcatspreadable */
unscopables_wellKnownSymbol=retrieveWellKnownSymbol(unscopables_key); /* http://262.ecma-international.org/6.0/#sec-symbol.unscopables */
function returnThis_makeFunction(){
return function(){
return this;
};
}
const IterableIterator=function(){ /* http://262.ecma-international.org/6.0/#sec-iterator-interface */
/* http://262.ecma-international.org/6.0/#sec-iterable-interface */
const next_key="next";
......@@ -925,7 +926,7 @@ tryES5DefineProperty(
constructorFn_prototype,
iterator_wellKnownSymbol,
returnThis_makeFunction(), /* http://262.ecma-international.org/6.0/#sec-%iteratorprototype%-@@iterator */
Object_valueOf, /* http://262.ecma-international.org/6.0/#sec-%iteratorprototype%-@@iterator */
False,False,False
);
......@@ -951,7 +952,9 @@ const IteratedObject_internalSlot=createUniqueSymbol(IteratedObject_doubleBracke
const ArrayIterator=function(){
const constructorFn=returnThis_makeFunction();
const constructorFn=function(){
return returnOrThrowObjectType(this);
};
const ArrayIteratorPrototype=new IterableIterator( /* http://262.ecma-international.org/6.0/#sec-%arrayiteratorprototype%-object */
function(){ /* http://262.ecma-international.org/6.0/#sec-%arrayiteratorprototype%.next */
......@@ -1089,7 +1092,7 @@ const createArrayIterator=function(array,kind){ /* http://262.ecma-international
const arrayLike_entries_keys_values_maker=function(iterationKind){
return function(){
return createArrayIterator(
new Object_constructor(this),
toObject(this),
iterationKind
);
};
......@@ -1518,7 +1521,7 @@ mergeObject(
);
(temp0=tryES5CreateNullPrototypeObject()).author="Bright_Leader";
temp0.date=1693145244301;
temp0.date=1696081050485;
mergeObject(
objectToExport,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册