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

1696081050485

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