forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Array.prototype.find and Array.prototype.findIndex in JS
Summary: Implement `Array.prototype.find` and `Array.prototype.findIndex` in JS Reviewed By: dulinriley Differential Revision: D17637660 fbshipit-source-id: 0e5ae8e5dd847e19acd6d8f76b83ed55637f6e9e
- Loading branch information
1 parent
cf68f40
commit 4663431
Showing
5 changed files
with
244 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var USE_THISARG = false; | ||
|
||
var numIter = 4000; | ||
var len = 10000; | ||
var thisArg; | ||
var a = Array(len); | ||
for (var i = 0; i < len; i++) { | ||
a[i] = i; | ||
} | ||
|
||
if (USE_THISARG) thisArg = a; | ||
|
||
function nonFail(val) { | ||
return val > 0; | ||
} | ||
|
||
function allFail(val) { | ||
return val < 0; | ||
} | ||
|
||
function halfFail(val) { | ||
return val >= 5000; | ||
} | ||
|
||
for (var i = 0; i < numIter; i++) { | ||
a.find(nonFail, thisArg); | ||
a.find(allFail, thisArg); | ||
a.find(halfFail, thisArg); | ||
} | ||
|
||
print('done'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var USE_THISARG = false; | ||
|
||
var numIter = 4000; | ||
var len = 10000; | ||
var thisArg; | ||
var a = Array(len); | ||
for (var i = 0; i < len; i++) { | ||
a[i] = i; | ||
} | ||
|
||
if (USE_THISARG) thisArg = a; | ||
|
||
function nonFail(val) { | ||
return val > 0; | ||
} | ||
|
||
function allFail(val) { | ||
return val < 0; | ||
} | ||
|
||
function halfFail(val) { | ||
return val >= 5000; | ||
} | ||
|
||
for (var i = 0; i < numIter; i++) { | ||
a.findIndex(nonFail, thisArg); | ||
a.findIndex(allFail, thisArg); | ||
a.findIndex(halfFail, thisArg); | ||
} | ||
|
||
print('done'); |