├── .appveyor.yml ├── .editorconfig ├── .gitignore ├── .travis.yml ├── benchmarks ├── code │ ├── every.js │ ├── filter.js │ ├── find.js │ ├── findIndex.js │ ├── flatten.js │ ├── forEach.js │ ├── includes.js │ ├── map.js │ ├── reduce.js │ ├── reduceRight.js │ ├── reverse.js │ ├── some.js │ └── unique.js ├── fixtures │ ├── index.js │ └── random.js ├── fn.js ├── index.js ├── package.json ├── readme.md └── results │ ├── node-10.md │ ├── node-12.md │ ├── node-4.md │ ├── node-6.md │ ├── node-7.md │ └── node-8.md ├── lerna.json ├── license ├── package.json ├── packages ├── every │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── filter.mutate │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── filter │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── find │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── findIndex │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── flatten │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── forEach.spec │ ├── module.js │ └── package.json ├── forEach │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── includes │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── map.spec │ ├── module.js │ └── package.json ├── map │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── reduce │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── reduceRight │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── reverse │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── some │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md └── unique │ ├── module.d.ts │ ├── module.js │ ├── package.json │ └── readme.md ├── readme.md ├── taskfile.js └── tests ├── every.js ├── filter.js ├── filter.mutate.js ├── find.js ├── findIndex.js ├── flatten.js ├── forEach.js ├── includes.js ├── map.js ├── reduce.js ├── reduceRight.js ├── reverse.js ├── some.js └── unique.js /.appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - nodejs_version: "6" 4 | - nodejs_version: "4" 5 | 6 | max_jobs: 4 7 | clone_depth: 1 8 | branches: 9 | only: 10 | - master 11 | 12 | version: "{build}" 13 | 14 | install: 15 | - ps: Install-Product node $env:nodejs_version 16 | - npm -g install npm@latest 17 | - set PATH=%APPDATA%\npm;%PATH% 18 | - npm install 19 | 20 | platform: 21 | - x86 22 | - x64 23 | 24 | matrix: 25 | fast_finish: true 26 | 27 | build: off 28 | 29 | test_script: 30 | - node --version 31 | - npm --version 32 | - npm test 33 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = tab 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.{json,yml,md}] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | coverage 4 | *.lock 5 | *.log 6 | 7 | # auto-built 8 | packages/*/index.js 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 6 5 | - 4 6 | 7 | git: 8 | depth: 1 9 | 10 | branches: 11 | only: 12 | - master 13 | -------------------------------------------------------------------------------- /benchmarks/code/every.js: -------------------------------------------------------------------------------- 1 | const every = require('array-every'); 2 | const lodash = require('lodash.every'); 3 | const fastjs = require('fast.js').every; 4 | const curr = require('../../packages/every'); 5 | 6 | const cb = () => true; 7 | 8 | exports['native'] = arr => arr.every(cb); 9 | exports['@arr/every'] = arr => curr(arr, cb); 10 | exports['array-every'] = arr => every(arr, cb); 11 | exports['lodash.every'] = arr => lodash(arr, cb); 12 | exports['fastjs.every'] = arr => fastjs(arr, cb); 13 | -------------------------------------------------------------------------------- /benchmarks/code/filter.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').filter; 2 | const arrFilter = require('arr-filter'); 3 | const arrayFilter = require('array-filter'); 4 | const fastjs = require('fast.js').filter; 5 | const lodash = require('lodash.filter'); 6 | const fn1 = require('../../packages/filter'); 7 | const fn2 = require('../../packages/filter.mutate'); 8 | 9 | const cb = () => true; 10 | 11 | exports['native'] = arr => arr.filter(cb); 12 | exports['@arr/filter'] = arr => fn1(arr, cb); 13 | exports['@arr/filter.mutate'] = arr => fn2(arr, cb); 14 | exports['arr-filter'] = arr => arrFilter(arr, cb); 15 | exports['array-filter'] = arr => arrayFilter(arr, cb); 16 | exports['lodash.filter'] = arr => lodash(arr, cb); 17 | exports['fastjs.filter'] = arr => fastjs(arr, cb); 18 | exports['ramda.filter'] = arr => ramda(cb, arr); 19 | -------------------------------------------------------------------------------- /benchmarks/code/find.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').find; 2 | const lodash = require('lodash.find'); 3 | const curr = require('../../packages/find'); 4 | 5 | const cb = val => val.length > 6; 6 | 7 | exports['native'] = arr => arr.find(cb); 8 | exports['@arr/find'] = arr => curr(arr, cb); 9 | exports['lodash.find'] = arr => lodash(arr, cb); 10 | exports['ramda.find'] = arr => ramda(cb)(arr); 11 | -------------------------------------------------------------------------------- /benchmarks/code/findIndex.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').findIndex; 2 | const lodash = require('lodash.findindex'); 3 | const curr = require('../../packages/findIndex'); 4 | 5 | const cb = val => val.length > 6; 6 | 7 | exports['native'] = arr => arr.findIndex(cb); 8 | exports['@arr/findIndex'] = arr => curr(arr, cb); 9 | exports['lodash.findindex'] = arr => lodash(arr, cb); 10 | exports['ramda.findIndex'] = arr => ramda(cb)(arr); 11 | -------------------------------------------------------------------------------- /benchmarks/code/flatten.js: -------------------------------------------------------------------------------- 1 | const flatten = require('flatten'); 2 | const arrFlat = require('arr-flatten'); 3 | const ramda = require('ramda').flatten; 4 | const flatArray = require('flatten-array'); 5 | const arrayFlat = require('array-flatten'); 6 | const lodash = require('lodash.flattendeep'); 7 | const curr = require('../../packages/flatten'); 8 | 9 | exports['native'] = arr => arr.flat(Infinity); 10 | exports['@arr/flatten'] = arr => curr(arr); 11 | exports['arr-flatten'] = arr => arrFlat(arr); 12 | exports['array-flatten'] = arr => arrayFlat(arr); 13 | exports['flatten'] = arr => flatten(arr); 14 | exports['flatten-array'] = arr => flatArray(arr); 15 | exports['lodash.flattendeep'] = arr => lodash(arr); 16 | exports['ramda.flatten'] = arr => ramda(arr); 17 | -------------------------------------------------------------------------------- /benchmarks/code/forEach.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').forEach; 2 | const lodash = require('lodash.foreach'); 3 | const fastjs = require('fast.js').forEach; 4 | const curr = require('../../packages/forEach'); 5 | const spec = require('../../packages/forEach.spec'); 6 | 7 | const cb = x => x; 8 | 9 | exports['native'] = arr => arr.forEach(cb); 10 | exports['@arr/forEach'] = arr => curr(arr, cb); 11 | exports['@arr/forEach.spec'] = arr => spec(arr, cb); 12 | exports['fastjs.forEach'] = arr => fastjs(arr, cb); 13 | exports['lodash.foreach'] = arr => lodash(arr, cb); 14 | exports['ramda.forEach'] = arr => ramda(cb, arr); 15 | -------------------------------------------------------------------------------- /benchmarks/code/includes.js: -------------------------------------------------------------------------------- 1 | const curr = require('../../packages/includes'); 2 | 3 | const val = 'foobar'; 4 | 5 | exports['native'] = arr => arr.includes(val); 6 | exports['@arr/includes'] = arr => curr(arr, val); 7 | -------------------------------------------------------------------------------- /benchmarks/code/map.js: -------------------------------------------------------------------------------- 1 | const arrMap = require('arr-map'); 2 | const ramda = require('ramda').map; 3 | const arrayMap = require('array-map'); 4 | const lodash = require('lodash.map'); 5 | const fastjs = require('fast.js').map; 6 | const curr = require('../../packages/map'); 7 | const spec = require('../../packages/map.spec'); 8 | 9 | const cb = x => x; 10 | 11 | exports['native'] = arr => arr.map(cb); 12 | exports['@arr/map'] = arr => curr(arr, cb); 13 | exports['@arr/map.spec'] = arr => spec(arr, cb); 14 | exports['arr-map'] = arr => arrMap(arr, cb); 15 | exports['array-map'] = arr => arrayMap(arr, cb); 16 | exports['fastjs.map'] = arr => fastjs(arr, cb); 17 | exports['lodash.map'] = arr => lodash(arr, cb); 18 | exports['ramda.map'] = arr => ramda(cb, arr); 19 | -------------------------------------------------------------------------------- /benchmarks/code/reduce.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').reduce; 2 | const arrReduce = require('arr-reduce'); 3 | const lodash = require('lodash.reduce'); 4 | const fastjs = require('fast.js').reduce; 5 | const curr = require('../../packages/reduce'); 6 | 7 | const val = []; 8 | const cb = _ => true; 9 | 10 | exports['native'] = arr => arr.reduce(cb, val); 11 | exports['@arr/reduce'] = arr => curr(arr, cb, val); 12 | exports['arr-reduce'] = arr => arrReduce(arr, cb, val); 13 | exports['fastjs.reduce'] = arr => fastjs(arr, cb, val); 14 | exports['lodash.reduce'] = arr => lodash(arr, cb, val); 15 | exports['ramda.reduce'] = arr => ramda(cb, val, arr); 16 | -------------------------------------------------------------------------------- /benchmarks/code/reduceRight.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').reduceRight; 2 | const lodash = require('lodash.reduceright'); 3 | const fastjs = require('fast.js').reduceRight; 4 | const curr = require('../../packages/reduceRight'); 5 | 6 | const val = []; 7 | const cb = _ => true; 8 | 9 | exports['native'] = arr => arr.reduceRight(cb); 10 | exports['@arr/reduceRight'] = arr => curr(arr, cb); 11 | exports['fastjs.reduceRight'] = arr => fastjs(arr, cb); 12 | exports['lodash.reduceright'] = arr => lodash(arr, cb); 13 | exports['ramda.reduceRight'] = arr => ramda(cb, val, arr); 14 | -------------------------------------------------------------------------------- /benchmarks/code/reverse.js: -------------------------------------------------------------------------------- 1 | const ramda = require('ramda').reverse; 2 | const lodash = require('lodash.reverse'); 3 | const compute = require('compute-reverse'); 4 | const curr = require('../../packages/reverse'); 5 | 6 | exports['native'] = arr => arr.reverse(); 7 | exports['@arr/reverse'] = arr => curr(arr); 8 | exports['compute-reverse'] = arr => compute(arr); 9 | exports['lodash.reverse'] = arr => lodash(arr); 10 | exports['ramda.reverse'] = arr => ramda(arr); 11 | -------------------------------------------------------------------------------- /benchmarks/code/some.js: -------------------------------------------------------------------------------- 1 | const lodash = require('lodash.some'); 2 | const fastjs = require('fast.js').some; 3 | const curr = require('../../packages/some'); 4 | 5 | const cb = (x, idx, arr) => idx === Math.floor(arr.length * .85); 6 | 7 | exports['native'] = arr => arr.some(cb); 8 | exports['@arr/some'] = arr => curr(arr, cb); 9 | exports['fastjs.some'] = arr => fastjs(arr, cb); 10 | exports['lodash.some'] = arr => lodash(arr, cb); 11 | -------------------------------------------------------------------------------- /benchmarks/code/unique.js: -------------------------------------------------------------------------------- 1 | const arrUniq = require('arr-uniq'); 2 | const ramda = require('ramda').uniq; 3 | const lodash = require('lodash.uniq'); 4 | const arrayUniq = require('array-unique'); 5 | const curr = require('../../packages/unique'); 6 | 7 | function native(arr) { 8 | return [...new Set(arr)]; 9 | } 10 | 11 | exports['native'] = arr => native(arr); 12 | exports['@arr/unique'] = arr => curr(arr); 13 | exports['arr-uniq'] = arr => arrUniq(arr); 14 | exports['array-unique'] = arr => arrayUniq(arr); 15 | exports['lodash.uniq'] = arr => lodash(arr); 16 | exports['ramda.uniq'] = arr => ramda(arr); 17 | -------------------------------------------------------------------------------- /benchmarks/fixtures/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const dim = require('chalk').dim; 4 | const random = require('./random'); 5 | 6 | const SIZES = [ 100, 500, 1000, 5000, 10000 ]; 7 | const TYPES = { string:'str', number:'int', object:'obj', array:'arr' }; 8 | 9 | module.exports = function (type, size) { 10 | const types = type ? [type] : Object.keys(TYPES).filter(k => k !== 'array'); 11 | const sizes = size ? [size] : SIZES; 12 | 13 | if (type || size) { 14 | console.log(dim(`> Filtering fixtures`)); 15 | } 16 | 17 | let i=0, j, fn, out={}; 18 | for (i; i < types.length; i++) { 19 | fn = TYPES[ types[i] ]; // randomizer 20 | for (j=0; j < sizes.length; j++) { 21 | out[`Array<${ types[i] }>(${ sizes[j] })`] = random[fn](sizes[j]); 22 | } 23 | } 24 | 25 | return out; 26 | } 27 | -------------------------------------------------------------------------------- /benchmarks/fixtures/random.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const randomize = require('randomatic'); 4 | 5 | const rand = (x, y) => Math.floor(Math.random() * y) + x; 6 | 7 | exports.str = num => loop(num, _ => randomize('*', rand(8, 16))); 8 | 9 | exports.int = num => loop(num, idx => Math.random() * (idx + 1) * 1e8 | 0); 10 | 11 | exports.obj = num => loop(num, idx => genObj(rand(8,16), idx)); 12 | 13 | exports.arr = num => loop(num, idx => genArr(rand(8,16), idx)); 14 | 15 | function loop(num, cb) { 16 | let res=new Array(num); 17 | while (num--) res[num] = cb(num); 18 | return res; 19 | } 20 | 21 | function genObj(len, idx) { 22 | let i=0, out={}; 23 | for (; i < len; i++) { 24 | out[ randomize('a',8) ] = idx % 3 ? randomize('*', rand(8, 16)) : genObj(rand(4, 8), 1); 25 | } 26 | return out; 27 | } 28 | 29 | function genArr(len, idx) { 30 | let i=0, out=new Array(len); 31 | for (; i < len; i++) { 32 | out[i] = idx % 3 ? randomize('*', rand(8, 16)) : genArr(rand(4, 8), 1); 33 | } 34 | return out; 35 | } 36 | -------------------------------------------------------------------------------- /benchmarks/fn.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const colors = require('kleur'); 4 | const lpad = require('pad-left'); 5 | const rpad = require('pad-right'); 6 | const clone = require('lodash.clone'); 7 | const sync = require('glob').sync; 8 | const gen = require('./fixtures'); 9 | 10 | const LOOPS = 30000; 11 | const cwd = __dirname; 12 | 13 | const RGX = /(\d)(?=(\d{3})+\.)/g; 14 | const toNum = int => (int || 0).toFixed(2).replace(RGX, '$1,'); 15 | const toNano = arr => arr[0] * 1e9 + arr[1]; 16 | 17 | const glob = str => sync(str, { cwd }); 18 | 19 | function retrieve(file, type, size) { 20 | console.log(colors.dim('> Constructing all fixture data')); 21 | const funcs = require(`./${file}`); 22 | const datas = gen(type, size); 23 | console.log(colors.dim('> Fixtures ready!')); 24 | return { funcs, datas }; 25 | } 26 | 27 | function test(name, func, data) { 28 | let i = 0; 29 | const start = process.hrtime(); 30 | for (; i < LOOPS; i++) { 31 | func(data); 32 | } 33 | const ms = toNano(process.hrtime(start)) / 1e6; 34 | const ops = toNum(data.length * LOOPS * 1000 / ms); 35 | return { name, ms, ops }; 36 | } 37 | 38 | const maxlen = (arr,k) => arr.reduce((a,b) => a[k].length > b[k].length ? a : b)[k].length; 39 | 40 | function report(arr, testname) { 41 | let i=0, len=arr.length; 42 | const fastest = arr.reduce((a,b) => a.ms <= b.ms ? a : b); 43 | arr = arr.map(o => ({ name:o.name, ms:toNum(o.ms)+'ms', ops:o.ops+' op/s' })); 44 | const max = { ms:maxlen(arr, 'ms'), name:maxlen(arr, 'name'), ops:maxlen(arr, 'ops') }; 45 | 46 | console.log(testname); 47 | for (; i < len; i++) { 48 | console.log(` ${ rpad(arr[i].name, max.name, ' ') } ⇝ ${ lpad(arr[i].ms, max.ms, ' ') } @ ${ lpad(arr[i].ops, max.ops, ' ') }`); 49 | } 50 | console.log(colors.blue('\n ➤ ') + 'Fastest is: ' + colors.green(fastest.name) + '!\n\n'); 51 | } 52 | 53 | function run(fns, data, testname) { 54 | let k, arr, res=[]; 55 | for (k in fns) { 56 | arr = clone(data); // `reduce` mutates 57 | res.push( test(k, fns[k], arr) ); 58 | } 59 | report(res, testname); 60 | } 61 | 62 | module.exports = { glob, retrieve, run }; 63 | -------------------------------------------------------------------------------- /benchmarks/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const mri = require('mri'); 4 | const colors = require('kleur'); 5 | const $ = require('./fn'); 6 | 7 | const argv = mri(process.argv.slice(2)); 8 | const codes = $.glob(`code/${argv._[0] || '*'}.js`); 9 | 10 | let i=0, len=codes.length, k; 11 | for (; i < len; i++) { 12 | const obj = $.retrieve(codes[i], argv.type, argv.size); 13 | for (k in obj.datas) { 14 | $.run(obj.funcs, obj.datas[k], `Benchmark: ${ colors.cyan(codes[i]) } • ${ colors.yellow(k) }`); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /benchmarks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "arr-filter": "^1.1.2", 5 | "arr-flatten": "^1.1.0", 6 | "arr-map": "^2.0.2", 7 | "arr-reduce": "^1.0.1", 8 | "arr-uniq": "^1.0.0", 9 | "array-every": "^0.1.2", 10 | "array-filter": "^1.0.0", 11 | "array-flatten": "^2.1.1", 12 | "array-map": "^0.0.0", 13 | "array-uniq": "^1.0.3", 14 | "array-unique": "^0.3.2", 15 | "compute-reverse": "^1.1.0", 16 | "fast.js": "^0.1.1", 17 | "flatten": "^1.0.2", 18 | "flatten-array": "^1.0.0", 19 | "glob": "^7.1.2", 20 | "kleur": "^3.0.0", 21 | "lodash.clone": "^4.5.0", 22 | "lodash.every": "^4.6.0", 23 | "lodash.filter": "^4.6.0", 24 | "lodash.find": "^4.6.0", 25 | "lodash.findindex": "^4.6.0", 26 | "lodash.flattendeep": "^4.4.0", 27 | "lodash.foreach": "^4.5.0", 28 | "lodash.indexof": "^4.0.5", 29 | "lodash.lastindexof": "^4.0.5", 30 | "lodash.map": "^4.6.0", 31 | "lodash.reduce": "^4.6.0", 32 | "lodash.reduceright": "^4.6.0", 33 | "lodash.reverse": "^4.0.1", 34 | "lodash.some": "^4.6.0", 35 | "lodash.uniq": "^4.5.0", 36 | "mri": "^1.1.0", 37 | "pad-left": "^2.1.0", 38 | "pad-right": "^0.2.2", 39 | "ramda": "^0.24.1", 40 | "randomatic": "^3.1.1" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /benchmarks/readme.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | **Process** 4 | 5 | Every new benchmark instance generates its own set of unique fixture data! This data is passed & cloned to _each_ function being benchmarked. In this way, every snippet is working with the _same data_ and is not able to introduce side effects to other codes' execution. It is also important to note that cloning the data-array **is not** tracked as execution time. 6 | 7 | Each fixture entry is completely randomized. 8 | 9 | * Strings (`--type string`) can consist of any 8-16 character string 10 | * Numbers (`--type number`) can be positive or negative, and are usually 9 digits 11 | * Arrays (`--type array`) are nested every 3rd index; values are Strings (see above) when not another Array 12 | * Objects (`--type object`) are nested every 3rd index; keys are 8 random alpha-chars; and values are Strings (see above) when not another object 13 | 14 | Any number of fixtures can be generated. By default, arrays with type `x` and length of 100, 500, 1000, 5000, and 10000 are created. You may use the `--size` flag to pass any number you'd like. 15 | 16 | Together, the combination of `--type`s & `--size`s _should_ serve as a good basis for testing & benchmarking these functions (and their competitors) in a fair and wide variety of cases. 17 | 18 | Please let me know if there is a way in which I can improve the fairness of these benchmarks. Thanks! 19 | 20 | 21 | ## Setup 22 | 23 | ``` 24 | $ npm install 25 | ``` 26 | 27 | ## Usage 28 | 29 | Commands should be run from the root `arr` repo; aka `cd ..` 30 | 31 | ```sh 32 | # run ALL benchmarks -- CAUTION! 33 | $ npm run bench 34 | 35 | # run 'map' benchmarks -- string, number, object 36 | $ npm run bench -- map 37 | 38 | # specify 'type' and 'size' 39 | $ npm run bench -- map --type string --size 100 40 | 41 | # special case: 'flatten' 42 | $ npm run bench -- flatten --type array 43 | ``` 44 | 45 | > **Note:** The `--type` flag defaults to string, number, object. The `--size` flag defaults to 100, 500, 1000, 5000, 10000. 46 | 47 | ## Results: 48 | 49 | * [Node 4](/benchmarks/results/node-4.md) 50 | * [Node 6](/benchmarks/results/node-6.md) 51 | * [Node 7](/benchmarks/results/node-7.md) 52 | * [Node 8](/benchmarks/results/node-8.md) 53 | * [Node 10](/benchmarks/results/node-10.md) 54 | * [Node 12](/benchmarks/results/node-12.md) 55 | -------------------------------------------------------------------------------- /benchmarks/results/node-10.md: -------------------------------------------------------------------------------- 1 | # Benchmark Results for Node `v10.18.1` (LTS) 2 | All benchmarks were run on the same Google Cloud instance: 3 | 4 | ``` 5 | Machine type 6 | n2-standard-4 (4 vCPUs, 16 GB memory) 7 | CPU platform 8 | Intel Cascade Lake 9 | Image OS 10 | debian-9-stretch-v20191210 11 | ``` 12 | 13 | In search for utmost consistency, no other user processes were running.
14 | Please note that numbers will vary per machine. 15 | 16 | > Don't forget to view results for other Node versions! 17 | 18 | 19 | ## every 20 | 21 |
22 | :no_entry_sign: ↝ Strings 23 | 24 | ``` 25 | Benchmark: code/every.js • Array(100) 26 | native ⇝ 13.32ms @ 225,141,963.26 op/s 27 | @arr/every ⇝ 4.49ms @ 667,711,561.07 op/s 28 | array-every ⇝ 10.30ms @ 291,241,749.00 op/s 29 | lodash.every ⇝ 7.68ms @ 390,665,083.87 op/s 30 | fastjs.every ⇝ 3.73ms @ 804,812,996.33 op/s 31 | 32 | Benchmark: code/every.js • Array(500) 33 | native ⇝ 4.96ms @ 3,025,008,959.07 op/s 34 | @arr/every ⇝ 9.48ms @ 1,582,153,143.78 op/s 35 | array-every ⇝ 18.63ms @ 805,224,641.03 op/s 36 | lodash.every ⇝ 14.10ms @ 1,063,857,704.07 op/s 37 | fastjs.every ⇝ 9.50ms @ 1,578,629,150.02 op/s 38 | 39 | Benchmark: code/every.js • Array(1000) 40 | native ⇝ 9.43ms @ 3,181,864,222.43 op/s 41 | @arr/every ⇝ 18.29ms @ 1,639,893,043.99 op/s 42 | array-every ⇝ 36.40ms @ 824,232,682.64 op/s 43 | lodash.every ⇝ 27.44ms @ 1,093,459,794.63 op/s 44 | fastjs.every ⇝ 18.35ms @ 1,635,238,384.23 op/s 45 | 46 | Benchmark: code/every.js • Array(5000) 47 | native ⇝ 45.01ms @ 3,332,549,295.57 op/s 48 | @arr/every ⇝ 89.57ms @ 1,674,616,237.41 op/s 49 | array-every ⇝ 179.28ms @ 836,657,270.41 op/s 50 | lodash.every ⇝ 138.60ms @ 1,082,284,355.08 op/s 51 | fastjs.every ⇝ 89.91ms @ 1,668,379,220.86 op/s 52 | 53 | Benchmark: code/every.js • Array(10000) 54 | native ⇝ 89.85ms @ 3,338,866,614.38 op/s 55 | @arr/every ⇝ 182.07ms @ 1,647,722,435.66 op/s 56 | array-every ⇝ 357.61ms @ 838,910,233.79 op/s 57 | lodash.every ⇝ 268.02ms @ 1,119,338,172.05 op/s 58 | fastjs.every ⇝ 179.41ms @ 1,672,192,137.60 op/s 59 | ``` 60 |
61 | 62 |
63 | :no_entry_sign: ↝ Numbers 64 | 65 | ``` 66 | Benchmark: code/every.js • Array(100) 67 | native ⇝ 1.40ms @ 2,142,779,084.48 op/s 68 | @arr/every ⇝ 2.34ms @ 1,280,778,713.46 op/s 69 | array-every ⇝ 4.24ms @ 707,430,543.88 op/s 70 | lodash.every ⇝ 3.41ms @ 880,141,198.12 op/s 71 | fastjs.every ⇝ 2.36ms @ 1,269,318,498.67 op/s 72 | 73 | Benchmark: code/every.js • Array(500) 74 | native ⇝ 5.00ms @ 2,997,841,554.08 op/s 75 | @arr/every ⇝ 9.64ms @ 1,555,675,446.28 op/s 76 | array-every ⇝ 18.53ms @ 809,553,421.19 op/s 77 | lodash.every ⇝ 14.08ms @ 1,065,363,532.93 op/s 78 | fastjs.every ⇝ 9.83ms @ 1,525,658,525.07 op/s 79 | 80 | Benchmark: code/every.js • Array(1000) 81 | native ⇝ 9.46ms @ 3,172,796,191.63 op/s 82 | @arr/every ⇝ 18.40ms @ 1,630,285,753.23 op/s 83 | array-every ⇝ 39.99ms @ 750,216,043.47 op/s 84 | lodash.every ⇝ 27.46ms @ 1,092,643,732.37 op/s 85 | fastjs.every ⇝ 18.72ms @ 1,602,829,100.22 op/s 86 | 87 | Benchmark: code/every.js • Array(5000) 88 | native ⇝ 45.04ms @ 3,330,517,713.66 op/s 89 | @arr/every ⇝ 90.19ms @ 1,663,109,036.21 op/s 90 | array-every ⇝ 178.73ms @ 839,260,235.74 op/s 91 | lodash.every ⇝ 134.14ms @ 1,118,221,158.83 op/s 92 | fastjs.every ⇝ 89.91ms @ 1,668,397,146.72 op/s 93 | 94 | Benchmark: code/every.js • Array(10000) 95 | native ⇝ 90.16ms @ 3,327,281,894.84 op/s 96 | @arr/every ⇝ 179.16ms @ 1,674,448,844.42 op/s 97 | array-every ⇝ 360.57ms @ 832,023,811.06 op/s 98 | lodash.every ⇝ 268.08ms @ 1,119,050,730.45 op/s 99 | fastjs.every ⇝ 178.50ms @ 1,680,714,225.56 op/s 100 | ``` 101 |
102 | 103 |
104 | :no_entry_sign: ↝ Objects 105 | 106 | ``` 107 | Benchmark: code/every.js • Array(100) 108 | native ⇝ 1.43ms @ 2,099,887,446.03 op/s 109 | @arr/every ⇝ 2.36ms @ 1,271,332,428.43 op/s 110 | array-every ⇝ 4.23ms @ 708,808,146.19 op/s 111 | lodash.every ⇝ 3.38ms @ 887,205,957.77 op/s 112 | fastjs.every ⇝ 2.39ms @ 1,253,158,481.52 op/s 113 | 114 | Benchmark: code/every.js • Array(500) 115 | native ⇝ 5.00ms @ 3,000,998,131.98 op/s 116 | @arr/every ⇝ 9.47ms @ 1,584,536,947.60 op/s 117 | array-every ⇝ 18.50ms @ 810,800,599.11 op/s 118 | lodash.every ⇝ 14.36ms @ 1,044,732,739.60 op/s 119 | fastjs.every ⇝ 9.58ms @ 1,565,953,907.09 op/s 120 | 121 | Benchmark: code/every.js • Array(1000) 122 | native ⇝ 9.66ms @ 3,104,323,266.84 op/s 123 | @arr/every ⇝ 18.33ms @ 1,636,404,635.74 op/s 124 | array-every ⇝ 36.37ms @ 824,745,714.40 op/s 125 | lodash.every ⇝ 27.56ms @ 1,088,448,682.35 op/s 126 | fastjs.every ⇝ 18.39ms @ 1,631,364,837.89 op/s 127 | 128 | Benchmark: code/every.js • Array(5000) 129 | native ⇝ 45.38ms @ 3,305,641,679.15 op/s 130 | @arr/every ⇝ 89.53ms @ 1,675,439,659.66 op/s 131 | array-every ⇝ 179.23ms @ 836,934,485.74 op/s 132 | lodash.every ⇝ 134.63ms @ 1,114,131,049.98 op/s 133 | fastjs.every ⇝ 89.51ms @ 1,675,841,227.05 op/s 134 | 135 | Benchmark: code/every.js • Array(10000) 136 | native ⇝ 89.68ms @ 3,345,392,133.82 op/s 137 | @arr/every ⇝ 178.42ms @ 1,681,403,250.73 op/s 138 | array-every ⇝ 359.63ms @ 834,181,480.40 op/s 139 | lodash.every ⇝ 270.01ms @ 1,111,050,805.74 op/s 140 | fastjs.every ⇝ 179.48ms @ 1,671,501,000.43 op/s 141 | ``` 142 | 143 | 144 | 145 | ## filter 146 | 147 |
148 | :mag: ↝ Strings 149 | 150 | ``` 151 | Benchmark: code/filter.js • Array(100) 152 | native ⇝ 40.67ms @ 73,772,183.73 op/s 153 | @arr/filter ⇝ 21.81ms @ 137,581,350.13 op/s 154 | @arr/filter.mutate ⇝ 5.38ms @ 557,252,906.63 op/s 155 | arr-filter ⇝ 17.84ms @ 168,179,968.71 op/s 156 | array-filter ⇝ 32.69ms @ 91,781,482.24 op/s 157 | lodash.filter ⇝ 28.38ms @ 105,707,299.17 op/s 158 | fastjs.filter ⇝ 25.86ms @ 116,027,133.49 op/s 159 | ramda.filter ⇝ 33.39ms @ 89,849,245.54 op/s 160 | 161 | Benchmark: code/filter.js • Array(500) 162 | native ⇝ 84.68ms @ 177,130,350.86 op/s 163 | @arr/filter ⇝ 96.67ms @ 155,165,384.27 op/s 164 | @arr/filter.mutate ⇝ 13.80ms @ 1,086,895,561.08 op/s 165 | arr-filter ⇝ 37.60ms @ 398,896,185.11 op/s 166 | array-filter ⇝ 86.32ms @ 173,770,867.68 op/s 167 | lodash.filter ⇝ 111.05ms @ 135,069,712.72 op/s 168 | fastjs.filter ⇝ 99.90ms @ 150,146,633.20 op/s 169 | ramda.filter ⇝ 109.63ms @ 136,818,826.38 op/s 170 | 171 | Benchmark: code/filter.js • Array(1000) 172 | native ⇝ 184.13ms @ 162,931,039.90 op/s 173 | @arr/filter ⇝ 196.54ms @ 152,640,707.13 op/s 174 | @arr/filter.mutate ⇝ 27.69ms @ 1,083,555,061.81 op/s 175 | arr-filter ⇝ 69.94ms @ 428,929,235.21 op/s 176 | array-filter ⇝ 180.31ms @ 166,380,474.69 op/s 177 | lodash.filter ⇝ 243.77ms @ 123,065,444.04 op/s 178 | fastjs.filter ⇝ 208.48ms @ 143,896,434.17 op/s 179 | ramda.filter ⇝ 225.00ms @ 133,331,428.77 op/s 180 | 181 | Benchmark: code/filter.js • Array(5000) 182 | native ⇝ 924.79ms @ 162,198,109.65 op/s 183 | @arr/filter ⇝ 1,011.55ms @ 148,287,959.90 op/s 184 | @arr/filter.mutate ⇝ 134.59ms @ 1,114,514,201.80 op/s 185 | arr-filter ⇝ 326.52ms @ 459,393,909.00 op/s 186 | array-filter ⇝ 924.83ms @ 162,191,527.77 op/s 187 | lodash.filter ⇝ 1,248.82ms @ 120,113,544.58 op/s 188 | fastjs.filter ⇝ 1,057.33ms @ 141,867,127.43 op/s 189 | ramda.filter ⇝ 1,133.73ms @ 132,306,882.43 op/s 190 | 191 | Benchmark: code/filter.js • Array(10000) 192 | native ⇝ 1,537.17ms @ 195,163,677.15 op/s 193 | @arr/filter ⇝ 1,754.76ms @ 170,964,015.99 op/s 194 | @arr/filter.mutate ⇝ 267.92ms @ 1,119,756,539.85 op/s 195 | arr-filter ⇝ 653.88ms @ 458,799,260.55 op/s 196 | array-filter ⇝ 1,544.35ms @ 194,256,713.37 op/s 197 | lodash.filter ⇝ 2,203.90ms @ 136,122,621.05 op/s 198 | fastjs.filter ⇝ 1,800.72ms @ 166,599,876.41 op/s 199 | ramda.filter ⇝ 1,951.61ms @ 153,719,611.63 op/s 200 | ``` 201 |
202 | 203 |
204 | :mag: ↝ Numbers 205 | 206 | ``` 207 | Benchmark: code/filter.js • Array(100) 208 | native ⇝ 20.90ms @ 143,525,809.10 op/s 209 | @arr/filter ⇝ 19.97ms @ 150,217,537.53 op/s 210 | @arr/filter.mutate ⇝ 3.11ms @ 963,216,681.37 op/s 211 | arr-filter ⇝ 8.51ms @ 352,639,275.76 op/s 212 | array-filter ⇝ 19.02ms @ 157,726,210.54 op/s 213 | lodash.filter ⇝ 23.31ms @ 128,677,821.23 op/s 214 | fastjs.filter ⇝ 20.26ms @ 148,051,757.32 op/s 215 | ramda.filter ⇝ 26.66ms @ 112,520,315.54 op/s 216 | 217 | Benchmark: code/filter.js • Array(500) 218 | native ⇝ 89.96ms @ 166,746,306.56 op/s 219 | @arr/filter ⇝ 94.64ms @ 158,497,780.86 op/s 220 | @arr/filter.mutate ⇝ 13.79ms @ 1,087,902,208.33 op/s 221 | arr-filter ⇝ 38.61ms @ 388,520,614.52 op/s 222 | array-filter ⇝ 86.97ms @ 172,465,663.64 op/s 223 | lodash.filter ⇝ 112.93ms @ 132,819,923.53 op/s 224 | fastjs.filter ⇝ 97.82ms @ 153,336,220.48 op/s 225 | ramda.filter ⇝ 108.22ms @ 138,606,620.36 op/s 226 | 227 | Benchmark: code/filter.js • Array(1000) 228 | native ⇝ 179.42ms @ 167,210,097.63 op/s 229 | @arr/filter ⇝ 193.35ms @ 155,158,810.11 op/s 230 | @arr/filter.mutate ⇝ 27.11ms @ 1,106,521,791.49 op/s 231 | arr-filter ⇝ 65.87ms @ 455,449,141.55 op/s 232 | array-filter ⇝ 175.49ms @ 170,945,055.78 op/s 233 | lodash.filter ⇝ 238.62ms @ 125,725,316.16 op/s 234 | fastjs.filter ⇝ 202.42ms @ 148,208,032.24 op/s 235 | ramda.filter ⇝ 224.41ms @ 133,686,302.01 op/s 236 | 237 | Benchmark: code/filter.js • Array(5000) 238 | native ⇝ 924.87ms @ 162,184,158.54 op/s 239 | @arr/filter ⇝ 1,017.88ms @ 147,365,505.59 op/s 240 | @arr/filter.mutate ⇝ 133.76ms @ 1,121,374,604.31 op/s 241 | arr-filter ⇝ 328.64ms @ 456,429,230.65 op/s 242 | array-filter ⇝ 936.63ms @ 160,148,501.31 op/s 243 | lodash.filter ⇝ 1,271.12ms @ 118,006,266.75 op/s 244 | fastjs.filter ⇝ 1,099.44ms @ 136,433,621.97 op/s 245 | ramda.filter ⇝ 1,132.71ms @ 132,425,557.55 op/s 246 | 247 | Benchmark: code/filter.js • Array(10000) 248 | native ⇝ 1,527.07ms @ 196,455,115.18 op/s 249 | @arr/filter ⇝ 1,732.57ms @ 173,153,332.28 op/s 250 | @arr/filter.mutate ⇝ 268.00ms @ 1,119,421,860.70 op/s 251 | arr-filter ⇝ 659.73ms @ 454,728,944.56 op/s 252 | array-filter ⇝ 1,543.03ms @ 194,422,462.07 op/s 253 | lodash.filter ⇝ 2,173.07ms @ 138,053,656.22 op/s 254 | fastjs.filter ⇝ 1,813.16ms @ 165,457,432.15 op/s 255 | ramda.filter ⇝ 1,951.34ms @ 153,740,142.06 op/s 256 | ``` 257 |
258 | 259 |
260 | :mag: ↝ Objects 261 | 262 | ``` 263 | Benchmark: code/filter.js • Array(100) 264 | native ⇝ 20.95ms @ 143,183,464.79 op/s 265 | @arr/filter ⇝ 19.61ms @ 152,974,863.94 op/s 266 | @arr/filter.mutate ⇝ 3.12ms @ 962,732,311.32 op/s 267 | arr-filter ⇝ 8.49ms @ 353,316,148.82 op/s 268 | array-filter ⇝ 19.23ms @ 155,998,460.61 op/s 269 | lodash.filter ⇝ 22.54ms @ 133,082,540.76 op/s 270 | fastjs.filter ⇝ 19.97ms @ 150,243,093.32 op/s 271 | ramda.filter ⇝ 25.87ms @ 115,955,612.04 op/s 272 | 273 | Benchmark: code/filter.js • Array(500) 274 | native ⇝ 85.53ms @ 175,378,984.05 op/s 275 | @arr/filter ⇝ 94.72ms @ 158,357,325.26 op/s 276 | @arr/filter.mutate ⇝ 14.00ms @ 1,071,732,101.27 op/s 277 | arr-filter ⇝ 38.32ms @ 391,446,650.60 op/s 278 | array-filter ⇝ 85.22ms @ 176,010,498.86 op/s 279 | lodash.filter ⇝ 112.29ms @ 133,585,245.42 op/s 280 | fastjs.filter ⇝ 98.46ms @ 152,353,615.02 op/s 281 | ramda.filter ⇝ 109.60ms @ 136,864,273.43 op/s 282 | 283 | Benchmark: code/filter.js • Array(1000) 284 | native ⇝ 181.15ms @ 165,613,064.87 op/s 285 | @arr/filter ⇝ 192.07ms @ 156,195,487.77 op/s 286 | @arr/filter.mutate ⇝ 27.13ms @ 1,105,859,751.77 op/s 287 | arr-filter ⇝ 68.89ms @ 435,472,390.65 op/s 288 | array-filter ⇝ 178.03ms @ 168,511,382.30 op/s 289 | lodash.filter ⇝ 237.77ms @ 126,172,496.30 op/s 290 | fastjs.filter ⇝ 204.45ms @ 146,737,863.94 op/s 291 | ramda.filter ⇝ 224.80ms @ 133,453,894.99 op/s 292 | 293 | Benchmark: code/filter.js • Array(5000) 294 | native ⇝ 917.85ms @ 163,426,278.56 op/s 295 | @arr/filter ⇝ 1,020.13ms @ 147,039,627.51 op/s 296 | @arr/filter.mutate ⇝ 134.24ms @ 1,117,382,432.43 op/s 297 | arr-filter ⇝ 324.17ms @ 462,722,177.48 op/s 298 | array-filter ⇝ 939.98ms @ 159,577,570.68 op/s 299 | lodash.filter ⇝ 1,264.48ms @ 118,625,986.98 op/s 300 | fastjs.filter ⇝ 1,074.83ms @ 139,556,795.44 op/s 301 | ramda.filter ⇝ 1,123.10ms @ 133,558,397.63 op/s 302 | 303 | Benchmark: code/filter.js • Array(10000) 304 | native ⇝ 1,517.37ms @ 197,710,426.01 op/s 305 | @arr/filter ⇝ 1,749.22ms @ 171,504,575.79 op/s 306 | @arr/filter.mutate ⇝ 267.51ms @ 1,121,459,473.94 op/s 307 | arr-filter ⇝ 651.42ms @ 460,529,774.51 op/s 308 | array-filter ⇝ 1,548.69ms @ 193,711,708.06 op/s 309 | lodash.filter ⇝ 2,176.71ms @ 137,822,671.20 op/s 310 | fastjs.filter ⇝ 1,811.77ms @ 165,584,231.05 op/s 311 | ramda.filter ⇝ 1,948.61ms @ 153,955,696.17 op/s 312 | ``` 313 | 314 | 315 | 316 | ## find 317 | 318 |
319 | :mag: ↝ Strings 320 | 321 | ``` 322 | Benchmark: code/find.js • Array(100) 323 | native ⇝ 2.73ms @ 1,098,351,520.81 op/s 324 | @arr/find ⇝ 1.60ms @ 1,875,371,557.99 op/s 325 | lodash.find ⇝ 10.70ms @ 280,475,484.48 op/s 326 | ramda.find ⇝ 22.36ms @ 134,155,101.90 op/s 327 | 328 | Benchmark: code/find.js • Array(500) 329 | native ⇝ 0.28ms @ 53,010,276,925.69 op/s 330 | @arr/find ⇝ 0.27ms @ 54,784,514,243.97 op/s 331 | lodash.find ⇝ 1.15ms @ 13,045,679,010.20 op/s 332 | ramda.find ⇝ 12.55ms @ 1,195,161,984.29 op/s 333 | 334 | Benchmark: code/find.js • Array(1000) 335 | native ⇝ 0.29ms @ 103,171,136,842.76 op/s 336 | @arr/find ⇝ 0.27ms @ 109,575,831,954.50 op/s 337 | lodash.find ⇝ 1.20ms @ 25,059,516,351.33 op/s 338 | ramda.find ⇝ 11.71ms @ 2,561,442,604.47 op/s 339 | 340 | Benchmark: code/find.js • Array(5000) 341 | native ⇝ 0.29ms @ 516,838,601,641.48 op/s 342 | @arr/find ⇝ 0.27ms @ 547,853,146,138.00 op/s 343 | lodash.find ⇝ 1.51ms @ 99,117,785,629.37 op/s 344 | ramda.find ⇝ 12.17ms @ 12,326,388,974.49 op/s 345 | 346 | Benchmark: code/find.js • Array(10000) 347 | native ⇝ 0.30ms @ 996,989,092,939.32 op/s 348 | @arr/find ⇝ 0.32ms @ 933,195,635,132.95 op/s 349 | lodash.find ⇝ 1.17ms @ 256,694,595,038.61 op/s 350 | ramda.find ⇝ 11.53ms @ 26,030,328,108.82 op/s 351 | ``` 352 |
353 | 354 |
355 | :mag: ↝ Numbers 356 | 357 | ``` 358 | Benchmark: code/find.js • Array(100) 359 | native ⇝ 14.55ms @ 206,201,439.56 op/s 360 | @arr/find ⇝ 11.53ms @ 260,117,125.54 op/s 361 | lodash.find ⇝ 18.91ms @ 158,662,018.01 op/s 362 | ramda.find ⇝ 22.02ms @ 136,251,674.65 op/s 363 | 364 | Benchmark: code/find.js • Array(500) 365 | native ⇝ 44.96ms @ 333,611,127.61 op/s 366 | @arr/find ⇝ 46.01ms @ 326,011,995.02 op/s 367 | lodash.find ⇝ 59.21ms @ 253,349,281.73 op/s 368 | ramda.find ⇝ 52.98ms @ 283,100,283.29 op/s 369 | 370 | Benchmark: code/find.js • Array(1000) 371 | native ⇝ 91.08ms @ 329,375,184.17 op/s 372 | @arr/find ⇝ 89.65ms @ 334,619,140.84 op/s 373 | lodash.find ⇝ 117.50ms @ 255,315,776.60 op/s 374 | ramda.find ⇝ 94.03ms @ 319,034,457.10 op/s 375 | 376 | Benchmark: code/find.js • Array(5000) 377 | native ⇝ 447.97ms @ 334,843,040.90 op/s 378 | @arr/find ⇝ 450.02ms @ 333,314,886.95 op/s 379 | lodash.find ⇝ 586.37ms @ 255,810,880.58 op/s 380 | ramda.find ⇝ 420.74ms @ 356,512,055.75 op/s 381 | 382 | Benchmark: code/find.js • Array(10000) 383 | native ⇝ 891.80ms @ 336,398,117.54 op/s 384 | @arr/find ⇝ 895.52ms @ 335,001,616.82 op/s 385 | lodash.find ⇝ 1,160.44ms @ 258,523,520.47 op/s 386 | ramda.find ⇝ 821.35ms @ 365,251,712.58 op/s 387 | ``` 388 |
389 | 390 |
391 | :mag: ↝ Objects 392 | 393 | ``` 394 | Benchmark: code/find.js • Array(100) 395 | native ⇝ 76.90ms @ 39,012,895.21 op/s 396 | @arr/find ⇝ 71.28ms @ 42,089,451.70 op/s 397 | lodash.find ⇝ 75.39ms @ 39,794,521.78 op/s 398 | ramda.find ⇝ 85.96ms @ 34,900,682.26 op/s 399 | 400 | Benchmark: code/find.js • Array(500) 401 | native ⇝ 543.85ms @ 27,581,253.48 op/s 402 | @arr/find ⇝ 550.93ms @ 27,226,745.95 op/s 403 | lodash.find ⇝ 549.96ms @ 27,274,637.94 op/s 404 | ramda.find ⇝ 562.78ms @ 26,653,212.13 op/s 405 | 406 | Benchmark: code/find.js • Array(1000) 407 | native ⇝ 2,565.71ms @ 11,692,688.55 op/s 408 | @arr/find ⇝ 2,563.85ms @ 11,701,160.51 op/s 409 | lodash.find ⇝ 2,600.88ms @ 11,534,562.43 op/s 410 | ramda.find ⇝ 2,358.63ms @ 12,719,223.65 op/s 411 | 412 | Benchmark: code/find.js • Array(5000) 413 | native ⇝ 44,536.84ms @ 3,367,998.08 op/s 414 | @arr/find ⇝ 45,040.33ms @ 3,330,348.57 op/s 415 | lodash.find ⇝ 44,578.59ms @ 3,364,844.20 op/s 416 | ramda.find ⇝ 44,711.08ms @ 3,354,873.37 op/s 417 | 418 | Benchmark: code/find.js • Array(10000) 419 | native ⇝ 93,574.67ms @ 3,205,995.66 op/s 420 | @arr/find ⇝ 95,099.74ms @ 3,154,582.82 op/s 421 | lodash.find ⇝ 93,539.27ms @ 3,207,209.19 op/s 422 | ramda.find ⇝ 92,871.81ms @ 3,230,259.16 op/s 423 | ``` 424 | 425 | 426 | 427 | ## findIndex 428 | 429 |
430 | :white_check_mark: ↝ Strings 431 | 432 | ``` 433 | Benchmark: code/findIndex.js • Array(100) 434 | native ⇝ 3.06ms @ 980,816,856.97 op/s 435 | @arr/findIndex ⇝ 1.66ms @ 1,806,250,711.21 op/s 436 | lodash.findindex ⇝ 6.75ms @ 444,257,987.72 op/s 437 | ramda.findIndex ⇝ 20.55ms @ 146,010,894.75 op/s 438 | 439 | Benchmark: code/findIndex.js • Array(500) 440 | native ⇝ 0.28ms @ 53,216,399,165.57 op/s 441 | @arr/findIndex ⇝ 0.23ms @ 66,005,438,848.16 op/s 442 | lodash.findindex ⇝ 0.34ms @ 43,547,558,288.41 op/s 443 | ramda.findIndex ⇝ 13.48ms @ 1,112,981,579.71 op/s 444 | 445 | Benchmark: code/findIndex.js • Array(1000) 446 | native ⇝ 0.27ms @ 109,515,030,938.00 op/s 447 | @arr/findIndex ⇝ 0.24ms @ 127,455,645,435.39 op/s 448 | lodash.findindex ⇝ 0.35ms @ 85,704,735,758.02 op/s 449 | ramda.findIndex ⇝ 12.62ms @ 2,377,850,418.47 op/s 450 | 451 | Benchmark: code/findIndex.js • Array(5000) 452 | native ⇝ 0.27ms @ 547,395,310,646.84 op/s 453 | @arr/findIndex ⇝ 0.23ms @ 653,065,489,407.28 op/s 454 | lodash.findindex ⇝ 0.36ms @ 413,347,258,543.20 op/s 455 | ramda.findIndex ⇝ 13.07ms @ 11,474,543,915.57 op/s 456 | 457 | Benchmark: code/findIndex.js • Array(10000) 458 | native ⇝ 0.28ms @ 1,065,182,039,610.57 op/s 459 | @arr/findIndex ⇝ 0.23ms @ 1,283,115,061,204.59 op/s 460 | lodash.findindex ⇝ 0.36ms @ 828,440,929,400.26 op/s 461 | ramda.findIndex ⇝ 12.36ms @ 24,280,800,661.02 op/s 462 | ``` 463 |
464 | 465 |
466 | :mag: ↝ Numbers 467 | 468 | ``` 469 | Benchmark: code/findIndex.js • Array(100) 470 | native ⇝ 13.62ms @ 220,327,827.24 op/s 471 | @arr/findIndex ⇝ 11.67ms @ 257,117,857.94 op/s 472 | lodash.findindex ⇝ 12.34ms @ 243,158,039.35 op/s 473 | ramda.findIndex ⇝ 23.32ms @ 128,622,844.63 op/s 474 | 475 | Benchmark: code/findIndex.js • Array(500) 476 | native ⇝ 36.19ms @ 414,499,490.62 op/s 477 | @arr/findIndex ⇝ 45.05ms @ 332,991,292.08 op/s 478 | lodash.findindex ⇝ 40.91ms @ 366,629,804.89 op/s 479 | ramda.findIndex ⇝ 54.14ms @ 277,041,345.45 op/s 480 | 481 | Benchmark: code/findIndex.js • Array(1000) 482 | native ⇝ 71.90ms @ 417,259,343.00 op/s 483 | @arr/findIndex ⇝ 92.74ms @ 323,496,812.48 op/s 484 | lodash.findindex ⇝ 80.67ms @ 371,890,364.34 op/s 485 | ramda.findIndex ⇝ 95.63ms @ 313,706,954.83 op/s 486 | 487 | Benchmark: code/findIndex.js • Array(5000) 488 | native ⇝ 356.89ms @ 420,301,415.80 op/s 489 | @arr/findIndex ⇝ 446.68ms @ 335,814,240.14 op/s 490 | lodash.findindex ⇝ 402.21ms @ 372,936,534.69 op/s 491 | ramda.findIndex ⇝ 419.90ms @ 357,225,947.90 op/s 492 | 493 | Benchmark: code/findIndex.js • Array(10000) 494 | native ⇝ 713.53ms @ 420,445,398.08 op/s 495 | @arr/findIndex ⇝ 891.71ms @ 336,430,500.56 op/s 496 | lodash.findindex ⇝ 803.55ms @ 373,344,616.11 op/s 497 | ramda.findIndex ⇝ 822.51ms @ 364,737,017.05 op/s 498 | ``` 499 |
500 | 501 |
502 | :mag: ↝ Objects 503 | 504 | ``` 505 | Benchmark: code/findIndex.js • Array(100) 506 | native ⇝ 78.00ms @ 38,463,490.24 op/s 507 | @arr/findIndex ⇝ 72.40ms @ 41,434,110.81 op/s 508 | lodash.findindex ⇝ 73.28ms @ 40,940,447.94 op/s 509 | ramda.findIndex ⇝ 86.61ms @ 34,639,863.94 op/s 510 | 511 | Benchmark: code/findIndex.js • Array(500) 512 | native ⇝ 592.44ms @ 25,318,940.11 op/s 513 | @arr/findIndex ⇝ 590.42ms @ 25,405,481.43 op/s 514 | lodash.findindex ⇝ 589.26ms @ 25,455,514.42 op/s 515 | ramda.findIndex ⇝ 614.74ms @ 24,400,613.37 op/s 516 | 517 | Benchmark: code/findIndex.js • Array(1000) 518 | native ⇝ 2,401.40ms @ 12,492,729.50 op/s 519 | @arr/findIndex ⇝ 2,434.19ms @ 12,324,443.13 op/s 520 | lodash.findindex ⇝ 2,168.35ms @ 13,835,436.57 op/s 521 | ramda.findIndex ⇝ 2,503.01ms @ 11,985,585.15 op/s 522 | 523 | Benchmark: code/findIndex.js • Array(5000) 524 | native ⇝ 42,624.73ms @ 3,519,084.07 op/s 525 | @arr/findIndex ⇝ 42,416.19ms @ 3,536,385.42 op/s 526 | lodash.findindex ⇝ 42,277.65ms @ 3,547,974.27 op/s 527 | ramda.findIndex ⇝ 42,951.78ms @ 3,492,288.68 op/s 528 | 529 | Benchmark: code/findIndex.js • Array(10000) 530 | native ⇝ 90,025.99ms @ 3,332,371.16 op/s 531 | @arr/findIndex ⇝ 88,851.88ms @ 3,376,405.73 op/s 532 | lodash.findindex ⇝ 91,029.64ms @ 3,295,629.79 op/s 533 | ramda.findIndex ⇝ 90,506.85ms @ 3,314,666.06 op/s 534 | ``` 535 | 536 | 537 | 538 | ## flatten 539 | 540 |
541 | :wavy_dash: ↝ Arrays 542 | 543 | ``` 544 | Benchmark: code/flatten.js • Array(5) 545 | @arr/flatten ⇝ 85.05ms @ 1,763,669.01 op/s 546 | arr-flatten ⇝ 93.36ms @ 1,606,736.48 op/s 547 | array-flatten ⇝ 81.75ms @ 1,834,758.81 op/s 548 | flatten ⇝ 2,638.95ms @ 56,840.69 op/s 549 | flatten-array ⇝ 93.68ms @ 1,601,131.31 op/s 550 | lodash.flattendeep ⇝ 198.96ms @ 753,921.55 op/s 551 | ramda.flatten ⇝ 1,353.97ms @ 110,785.54 op/s 552 | 553 | Benchmark: code/flatten.js • Array(10) 554 | @arr/flatten ⇝ 221.75ms @ 1,352,870.27 op/s 555 | arr-flatten ⇝ 221.60ms @ 1,353,820.88 op/s 556 | array-flatten ⇝ 188.58ms @ 1,590,822.74 op/s 557 | flatten ⇝ 6,911.35ms @ 43,406.86 op/s 558 | flatten-array ⇝ 226.05ms @ 1,327,157.61 op/s 559 | lodash.flattendeep ⇝ 488.65ms @ 613,930.44 op/s 560 | ramda.flatten ⇝ 3,363.78ms @ 89,185.43 op/s 561 | 562 | Benchmark: code/flatten.js • Array(100) 563 | @arr/flatten ⇝ 1,875.79ms @ 1,599,324.20 op/s 564 | arr-flatten ⇝ 1,984.97ms @ 1,511,357.40 op/s 565 | array-flatten ⇝ 1,672.00ms @ 1,794,256.14 op/s 566 | flatten ⇝ 80,742.06ms @ 37,155.35 op/s 567 | flatten-array ⇝ 1,777.38ms @ 1,687,879.40 op/s 568 | lodash.flattendeep ⇝ 3,704.82ms @ 809,755.87 op/s 569 | ramda.flatten ⇝ 27,375.45ms @ 109,587.24 op/s 570 | 571 | Benchmark: code/flatten.js • Array(500) 572 | @arr/flatten ⇝ 9,471.80ms @ 1,583,648.56 op/s 573 | arr-flatten ⇝ 10,165.86ms @ 1,475,526.92 op/s 574 | array-flatten ⇝ 9,346.85ms @ 1,604,818.30 op/s 575 | flatten ⇝ 947,453.81ms @ 15,831.91 op/s 576 | flatten-array ⇝ 10,088.49ms @ 1,486,842.78 op/s 577 | lodash.flattendeep ⇝ 18,516.13ms @ 810,104.53 op/s 578 | ramda.flatten ⇝ 135,704.14ms @ 110,534.58 op/s 579 | ``` 580 |
581 | 582 | 583 | ## forEach 584 | 585 |
586 | :no_entry_sign: ↝ Strings 587 | 588 | ``` 589 | Benchmark: code/forEach.js • Array(100) 590 | native ⇝ 13.29ms @ 225,660,536.60 op/s 591 | @arr/forEach ⇝ 4.40ms @ 681,697,800.18 op/s 592 | fastjs.forEach ⇝ 8.76ms @ 342,500,433.55 op/s 593 | lodash.foreach ⇝ 8.63ms @ 347,650,588.91 op/s 594 | ramda.forEach ⇝ 9.48ms @ 316,449,420.62 op/s 595 | 596 | Benchmark: code/forEach.js • Array(500) 597 | native ⇝ 8.00ms @ 1,874,369,274.74 op/s 598 | @arr/forEach ⇝ 9.45ms @ 1,586,909,645.81 op/s 599 | fastjs.forEach ⇝ 9.62ms @ 1,559,673,741.21 op/s 600 | lodash.foreach ⇝ 22.99ms @ 652,527,412.68 op/s 601 | ramda.forEach ⇝ 15.52ms @ 966,228,634.43 op/s 602 | 603 | Benchmark: code/forEach.js • Array(1000) 604 | native ⇝ 15.41ms @ 1,946,787,294.80 op/s 605 | @arr/forEach ⇝ 18.30ms @ 1,639,421,395.73 op/s 606 | fastjs.forEach ⇝ 18.64ms @ 1,609,633,160.85 op/s 607 | lodash.foreach ⇝ 45.18ms @ 664,032,111.88 op/s 608 | ramda.forEach ⇝ 15.83ms @ 1,895,687,040.27 op/s 609 | 610 | Benchmark: code/forEach.js • Array(5000) 611 | native ⇝ 74.87ms @ 2,003,577,293.76 op/s 612 | @arr/forEach ⇝ 92.84ms @ 1,615,604,098.93 op/s 613 | fastjs.forEach ⇝ 89.88ms @ 1,668,954,562.30 op/s 614 | lodash.foreach ⇝ 223.63ms @ 670,745,055.96 op/s 615 | ramda.forEach ⇝ 75.20ms @ 1,994,599,316.51 op/s 616 | 617 | Benchmark: code/forEach.js • Array(10000) 618 | native ⇝ 148.79ms @ 2,016,230,304.47 op/s 619 | @arr/forEach ⇝ 178.54ms @ 1,680,274,707.44 op/s 620 | fastjs.forEach ⇝ 178.69ms @ 1,678,913,970.99 op/s 621 | lodash.foreach ⇝ 449.05ms @ 668,070,380.52 op/s 622 | ramda.forEach ⇝ 149.22ms @ 2,010,476,647.42 op/s 623 | ``` 624 |
625 | 626 |
627 | :no_entry_sign: ↝ Numbers 628 | 629 | ``` 630 | Benchmark: code/forEach.js • Array(100) 631 | native ⇝ 2.04ms @ 1,469,373,841.03 op/s 632 | @arr/forEach ⇝ 2.28ms @ 1,317,942,112.47 op/s 633 | fastjs.forEach ⇝ 2.50ms @ 1,198,790,659.98 op/s 634 | lodash.foreach ⇝ 5.19ms @ 578,196,109.09 op/s 635 | ramda.forEach ⇝ 2.40ms @ 1,247,853,172.60 op/s 636 | 637 | Benchmark: code/forEach.js • Array(500) 638 | native ⇝ 8.08ms @ 1,857,447,124.67 op/s 639 | @arr/forEach ⇝ 9.41ms @ 1,594,518,597.83 op/s 640 | fastjs.forEach ⇝ 9.58ms @ 1,565,797,308.16 op/s 641 | lodash.foreach ⇝ 23.16ms @ 647,599,411.58 op/s 642 | ramda.forEach ⇝ 8.38ms @ 1,790,865,796.46 op/s 643 | 644 | Benchmark: code/forEach.js • Array(1000) 645 | native ⇝ 15.36ms @ 1,953,157,298.30 op/s 646 | @arr/forEach ⇝ 18.23ms @ 1,645,364,046.94 op/s 647 | fastjs.forEach ⇝ 18.48ms @ 1,623,674,033.37 op/s 648 | lodash.foreach ⇝ 45.44ms @ 660,229,269.90 op/s 649 | ramda.forEach ⇝ 17.42ms @ 1,721,678,404.59 op/s 650 | 651 | Benchmark: code/forEach.js • Array(5000) 652 | native ⇝ 74.87ms @ 2,003,465,969.41 op/s 653 | @arr/forEach ⇝ 89.80ms @ 1,670,385,241.17 op/s 654 | fastjs.forEach ⇝ 89.74ms @ 1,671,492,711.86 op/s 655 | lodash.foreach ⇝ 222.97ms @ 672,726,877.41 op/s 656 | ramda.forEach ⇝ 75.26ms @ 1,993,102,351.11 op/s 657 | 658 | Benchmark: code/forEach.js • Array(10000) 659 | native ⇝ 148.83ms @ 2,015,679,595.31 op/s 660 | @arr/forEach ⇝ 178.96ms @ 1,676,316,428.75 op/s 661 | fastjs.forEach ⇝ 178.72ms @ 1,678,600,189.79 op/s 662 | lodash.foreach ⇝ 446.39ms @ 672,057,275.41 op/s 663 | ramda.forEach ⇝ 149.39ms @ 2,008,165,441.67 op/s 664 | ``` 665 |
666 | 667 |
668 | :no_entry_sign: ↝ Objects 669 | 670 | ``` 671 | Benchmark: code/forEach.js • Array(100) 672 | native ⇝ 2.03ms @ 1,478,603,862.80 op/s 673 | @arr/forEach ⇝ 2.27ms @ 1,319,616,941.59 op/s 674 | fastjs.forEach ⇝ 2.48ms @ 1,210,891,728.92 op/s 675 | lodash.foreach ⇝ 5.18ms @ 579,706,896.33 op/s 676 | ramda.forEach ⇝ 2.41ms @ 1,244,358,906.29 op/s 677 | 678 | Benchmark: code/forEach.js • Array(500) 679 | native ⇝ 8.10ms @ 1,851,139,734.39 op/s 680 | @arr/forEach ⇝ 9.37ms @ 1,601,156,419.21 op/s 681 | fastjs.forEach ⇝ 9.62ms @ 1,559,921,579.62 op/s 682 | lodash.foreach ⇝ 22.98ms @ 652,791,453.76 op/s 683 | ramda.forEach ⇝ 8.36ms @ 1,794,716,712.94 op/s 684 | 685 | Benchmark: code/forEach.js • Array(1000) 686 | native ⇝ 15.37ms @ 1,952,382,941.95 op/s 687 | @arr/forEach ⇝ 18.26ms @ 1,642,520,070.36 op/s 688 | fastjs.forEach ⇝ 18.46ms @ 1,625,513,540.37 op/s 689 | lodash.foreach ⇝ 45.38ms @ 661,026,436.56 op/s 690 | ramda.forEach ⇝ 16.96ms @ 1,768,944,481.44 op/s 691 | 692 | Benchmark: code/forEach.js • Array(5000) 693 | native ⇝ 74.72ms @ 2,007,374,075.28 op/s 694 | @arr/forEach ⇝ 89.39ms @ 1,677,972,115.66 op/s 695 | fastjs.forEach ⇝ 90.01ms @ 1,666,456,711.64 op/s 696 | lodash.foreach ⇝ 223.62ms @ 670,784,202.45 op/s 697 | ramda.forEach ⇝ 74.99ms @ 2,000,148,357.67 op/s 698 | 699 | Benchmark: code/forEach.js • Array(10000) 700 | native ⇝ 148.90ms @ 2,014,818,817.79 op/s 701 | @arr/forEach ⇝ 178.27ms @ 1,682,821,170.26 op/s 702 | fastjs.forEach ⇝ 179.11ms @ 1,674,933,075.54 op/s 703 | lodash.foreach ⇝ 448.32ms @ 669,166,946.51 op/s 704 | ramda.forEach ⇝ 149.44ms @ 2,007,449,229.22 op/s 705 | ``` 706 | 707 | 708 | 709 | ## includes 710 | 711 |
712 | :no_entry_sign: ↝ Strings 713 | 714 | ``` 715 | Benchmark: code/includes.js • Array(100) 716 | native ⇝ 7.04ms @ 426,291,681.56 op/s 717 | @arr/includes ⇝ 15.42ms @ 194,508,304.40 op/s 718 | 719 | Benchmark: code/includes.js • Array(500) 720 | native ⇝ 40.68ms @ 368,721,801.54 op/s 721 | @arr/includes ⇝ 45.67ms @ 328,468,575.05 op/s 722 | 723 | Benchmark: code/includes.js • Array(1000) 724 | native ⇝ 80.94ms @ 370,666,871.83 op/s 725 | @arr/includes ⇝ 89.83ms @ 333,982,431.90 op/s 726 | 727 | Benchmark: code/includes.js • Array(5000) 728 | native ⇝ 402.00ms @ 373,130,546.00 op/s 729 | @arr/includes ⇝ 451.34ms @ 332,343,600.80 op/s 730 | 731 | Benchmark: code/includes.js • Array(10000) 732 | native ⇝ 805.00ms @ 372,669,773.70 op/s 733 | @arr/includes ⇝ 893.92ms @ 335,601,488.91 op/s 734 | ``` 735 |
736 | 737 |
738 | :no_entry_sign: ↝ Numbers 739 | 740 | ``` 741 | Benchmark: code/includes.js • Array(100) 742 | native ⇝ 3.66ms @ 820,183,289.09 op/s 743 | @arr/includes ⇝ 12.43ms @ 241,382,795.14 op/s 744 | 745 | Benchmark: code/includes.js • Array(500) 746 | native ⇝ 14.41ms @ 1,040,764,092.92 op/s 747 | @arr/includes ⇝ 49.93ms @ 300,412,364.04 op/s 748 | 749 | Benchmark: code/includes.js • Array(1000) 750 | native ⇝ 27.66ms @ 1,084,456,339.08 op/s 751 | @arr/includes ⇝ 98.85ms @ 303,482,421.33 op/s 752 | 753 | Benchmark: code/includes.js • Array(5000) 754 | native ⇝ 134.30ms @ 1,116,940,606.15 op/s 755 | @arr/includes ⇝ 491.02ms @ 305,486,523.92 op/s 756 | 757 | Benchmark: code/includes.js • Array(10000) 758 | native ⇝ 268.60ms @ 1,116,883,670.59 op/s 759 | @arr/includes ⇝ 981.25ms @ 305,732,514.61 op/s 760 | ``` 761 |
762 | 763 |
764 | :no_entry_sign: ↝ Objects 765 | 766 | ``` 767 | Benchmark: code/includes.js • Array(100) 768 | native ⇝ 7.76ms @ 386,815,023.12 op/s 769 | @arr/includes ⇝ 16.60ms @ 180,679,702.59 op/s 770 | 771 | Benchmark: code/includes.js • Array(500) 772 | native ⇝ 36.44ms @ 411,680,020.88 op/s 773 | @arr/includes ⇝ 81.48ms @ 184,099,351.30 op/s 774 | 775 | Benchmark: code/includes.js • Array(1000) 776 | native ⇝ 72.16ms @ 415,740,345.21 op/s 777 | @arr/includes ⇝ 160.71ms @ 186,674,880.69 op/s 778 | 779 | Benchmark: code/includes.js • Array(5000) 780 | native ⇝ 652.49ms @ 229,888,256.53 op/s 781 | @arr/includes ⇝ 974.97ms @ 153,850,691.89 op/s 782 | 783 | Benchmark: code/includes.js • Array(10000) 784 | native ⇝ 2,128.97ms @ 140,913,014.84 op/s 785 | @arr/includes ⇝ 3,299.77ms @ 90,915,481.96 op/s 786 | ``` 787 | 788 | 789 | 790 | ## map 791 | 792 |
793 | :white_check_mark: ↝ Strings 794 | 795 | ``` 796 | Benchmark: code/map.js • Array(100) 797 | native ⇝ 28.82ms @ 104,102,654.38 op/s 798 | @arr/map ⇝ 11.29ms @ 265,821,401.87 op/s 799 | arr-map ⇝ 20.04ms @ 149,702,727.81 op/s 800 | array-map ⇝ 24.15ms @ 124,226,184.74 op/s 801 | fastjs.map ⇝ 14.96ms @ 200,567,673.37 op/s 802 | lodash.map ⇝ 15.83ms @ 189,564,283.97 op/s 803 | ramda.map ⇝ 22.68ms @ 132,254,122.06 op/s 804 | 805 | Benchmark: code/map.js • Array(500) 806 | native ⇝ 71.72ms @ 209,155,424.54 op/s 807 | @arr/map ⇝ 44.31ms @ 338,506,051.83 op/s 808 | arr-map ⇝ 44.81ms @ 334,725,732.88 op/s 809 | array-map ⇝ 70.77ms @ 211,940,522.76 op/s 810 | fastjs.map ⇝ 46.06ms @ 325,681,468.93 op/s 811 | lodash.map ⇝ 48.02ms @ 312,398,021.57 op/s 812 | ramda.map ⇝ 50.08ms @ 299,533,434.74 op/s 813 | 814 | Benchmark: code/map.js • Array(1000) 815 | native ⇝ 144.80ms @ 207,186,273.87 op/s 816 | @arr/map ⇝ 88.72ms @ 338,150,291.75 op/s 817 | arr-map ⇝ 94.57ms @ 317,238,475.45 op/s 818 | array-map ⇝ 143.70ms @ 208,769,069.18 op/s 819 | fastjs.map ⇝ 88.02ms @ 340,849,984.42 op/s 820 | lodash.map ⇝ 98.17ms @ 305,606,737.61 op/s 821 | ramda.map ⇝ 93.99ms @ 319,181,740.58 op/s 822 | 823 | Benchmark: code/map.js • Array(5000) 824 | native ⇝ 718.70ms @ 208,708,750.52 op/s 825 | @arr/map ⇝ 443.30ms @ 338,368,511.69 op/s 826 | arr-map ⇝ 451.19ms @ 332,456,822.00 op/s 827 | array-map ⇝ 725.20ms @ 206,839,197.35 op/s 828 | fastjs.map ⇝ 449.80ms @ 333,482,294.69 op/s 829 | lodash.map ⇝ 492.96ms @ 304,281,748.09 op/s 830 | ramda.map ⇝ 456.24ms @ 328,773,778.03 op/s 831 | 832 | Benchmark: code/map.js • Array(10000) 833 | native ⇝ 1,452.87ms @ 206,488,098.47 op/s 834 | @arr/map ⇝ 869.49ms @ 345,031,618.87 op/s 835 | arr-map ⇝ 898.99ms @ 333,707,934.95 op/s 836 | array-map ⇝ 1,437.29ms @ 208,725,801.62 op/s 837 | fastjs.map ⇝ 900.78ms @ 333,042,903.64 op/s 838 | lodash.map ⇝ 979.44ms @ 306,297,813.85 op/s 839 | ramda.map ⇝ 891.31ms @ 336,583,488.59 op/s 840 | ``` 841 |
842 | 843 |
844 | :white_check_mark: ↝ Numbers 845 | 846 | ``` 847 | Benchmark: code/map.js • Array(100) 848 | native ⇝ 9.42ms @ 318,417,220.17 op/s 849 | @arr/map ⇝ 9.10ms @ 329,816,608.77 op/s 850 | arr-map ⇝ 10.57ms @ 283,800,926.89 op/s 851 | array-map ⇝ 9.44ms @ 317,664,227.64 op/s 852 | fastjs.map ⇝ 9.41ms @ 318,794,429.98 op/s 853 | lodash.map ⇝ 9.70ms @ 309,143,092.44 op/s 854 | ramda.map ⇝ 14.10ms @ 212,825,427.81 op/s 855 | 856 | Benchmark: code/map.js • Array(500) 857 | native ⇝ 47.25ms @ 317,454,808.19 op/s 858 | @arr/map ⇝ 41.75ms @ 359,272,470.37 op/s 859 | arr-map ⇝ 44.23ms @ 339,165,832.49 op/s 860 | array-map ⇝ 46.79ms @ 320,614,834.95 op/s 861 | fastjs.map ⇝ 43.05ms @ 348,466,902.44 op/s 862 | lodash.map ⇝ 46.66ms @ 321,447,084.48 op/s 863 | ramda.map ⇝ 48.48ms @ 309,385,519.11 op/s 864 | 865 | Benchmark: code/map.js • Array(1000) 866 | native ⇝ 94.52ms @ 317,407,725.18 op/s 867 | @arr/map ⇝ 85.98ms @ 348,904,771.06 op/s 868 | arr-map ⇝ 88.41ms @ 339,320,016.71 op/s 869 | array-map ⇝ 96.68ms @ 310,289,157.43 op/s 870 | fastjs.map ⇝ 85.59ms @ 350,512,930.11 op/s 871 | lodash.map ⇝ 94.21ms @ 318,431,891.91 op/s 872 | ramda.map ⇝ 91.85ms @ 326,621,721.49 op/s 873 | 874 | Benchmark: code/map.js • Array(5000) 875 | native ⇝ 479.87ms @ 312,586,619.05 op/s 876 | @arr/map ⇝ 435.27ms @ 344,616,650.71 op/s 877 | arr-map ⇝ 434.16ms @ 345,495,633.39 op/s 878 | array-map ⇝ 479.86ms @ 312,594,253.68 op/s 879 | fastjs.map ⇝ 438.23ms @ 342,284,327.88 op/s 880 | lodash.map ⇝ 487.87ms @ 307,456,047.74 op/s 881 | ramda.map ⇝ 440.11ms @ 340,825,721.84 op/s 882 | 883 | Benchmark: code/map.js • Array(10000) 884 | native ⇝ 964.03ms @ 311,192,332.22 op/s 885 | @arr/map ⇝ 869.77ms @ 344,918,019.75 op/s 886 | arr-map ⇝ 877.51ms @ 341,875,997.81 op/s 887 | array-map ⇝ 959.17ms @ 312,769,933.81 op/s 888 | fastjs.map ⇝ 867.28ms @ 345,908,605.87 op/s 889 | lodash.map ⇝ 957.07ms @ 313,456,105.45 op/s 890 | ramda.map ⇝ 886.63ms @ 338,360,885.47 op/s 891 | ``` 892 |
893 | 894 |
895 | :white_check_mark: ↝ Objects 896 | 897 | ``` 898 | Benchmark: code/map.js • Array(100) 899 | native ⇝ 14.30ms @ 209,838,516.67 op/s 900 | @arr/map ⇝ 9.23ms @ 325,011,134.34 op/s 901 | arr-map ⇝ 10.37ms @ 289,295,795.21 op/s 902 | array-map ⇝ 13.63ms @ 220,140,621.43 op/s 903 | fastjs.map ⇝ 9.05ms @ 331,542,304.96 op/s 904 | lodash.map ⇝ 9.55ms @ 314,245,700.33 op/s 905 | ramda.map ⇝ 13.92ms @ 215,528,373.92 op/s 906 | 907 | Benchmark: code/map.js • Array(500) 908 | native ⇝ 69.52ms @ 215,765,008.43 op/s 909 | @arr/map ⇝ 42.46ms @ 353,244,193.50 op/s 910 | arr-map ⇝ 43.91ms @ 341,597,417.47 op/s 911 | array-map ⇝ 69.81ms @ 214,854,858.67 op/s 912 | fastjs.map ⇝ 42.29ms @ 354,684,521.83 op/s 913 | lodash.map ⇝ 47.31ms @ 317,039,811.96 op/s 914 | ramda.map ⇝ 48.04ms @ 312,259,410.63 op/s 915 | 916 | Benchmark: code/map.js • Array(1000) 917 | native ⇝ 141.85ms @ 211,493,857.89 op/s 918 | @arr/map ⇝ 86.19ms @ 348,084,811.84 op/s 919 | arr-map ⇝ 87.25ms @ 343,855,372.69 op/s 920 | array-map ⇝ 139.82ms @ 214,559,598.08 op/s 921 | fastjs.map ⇝ 86.73ms @ 345,882,827.00 op/s 922 | lodash.map ⇝ 95.47ms @ 314,245,453.46 op/s 923 | ramda.map ⇝ 92.49ms @ 324,362,164.24 op/s 924 | 925 | Benchmark: code/map.js • Array(5000) 926 | native ⇝ 710.10ms @ 211,238,605.85 op/s 927 | @arr/map ⇝ 441.13ms @ 340,034,626.95 op/s 928 | arr-map ⇝ 438.91ms @ 341,754,927.36 op/s 929 | array-map ⇝ 704.99ms @ 212,767,667.74 op/s 930 | fastjs.map ⇝ 431.52ms @ 347,610,608.68 op/s 931 | lodash.map ⇝ 482.56ms @ 310,842,110.65 op/s 932 | ramda.map ⇝ 443.74ms @ 338,033,688.01 op/s 933 | 934 | Benchmark: code/map.js • Array(10000) 935 | native ⇝ 1,429.47ms @ 209,868,096.39 op/s 936 | @arr/map ⇝ 874.88ms @ 342,902,511.41 op/s 937 | arr-map ⇝ 879.83ms @ 340,974,181.72 op/s 938 | array-map ⇝ 1,429.00ms @ 209,936,338.84 op/s 939 | fastjs.map ⇝ 881.01ms @ 340,516,432.51 op/s 940 | lodash.map ⇝ 976.71ms @ 307,153,894.01 op/s 941 | ramda.map ⇝ 885.50ms @ 338,790,952.55 op/s 942 | ``` 943 | 944 | 945 | 946 | ## reduce 947 | 948 |
949 | :white_check_mark: ↝ Strings 950 | 951 | ``` 952 | Benchmark: code/reduce.js • Array(100) 953 | native ⇝ 12.63ms @ 237,442,384.61 op/s 954 | @arr/reduce ⇝ 4.57ms @ 657,092,536.37 op/s 955 | arr-reduce ⇝ 8.64ms @ 347,183,204.29 op/s 956 | fastjs.reduce ⇝ 5.15ms @ 582,389,474.13 op/s 957 | lodash.reduce ⇝ 17.28ms @ 173,647,177.07 op/s 958 | ramda.reduce ⇝ 15.95ms @ 188,033,191.62 op/s 959 | 960 | Benchmark: code/reduce.js • Array(500) 961 | native ⇝ 18.20ms @ 823,981,147.31 op/s 962 | @arr/reduce ⇝ 7.98ms @ 1,880,630,608.04 op/s 963 | arr-reduce ⇝ 8.03ms @ 1,868,075,045.81 op/s 964 | fastjs.reduce ⇝ 9.62ms @ 1,559,755,642.44 op/s 965 | lodash.reduce ⇝ 14.20ms @ 1,055,978,326.26 op/s 966 | ramda.reduce ⇝ 16.94ms @ 885,383,452.49 op/s 967 | 968 | Benchmark: code/reduce.js • Array(1000) 969 | native ⇝ 36.06ms @ 831,963,690.00 op/s 970 | @arr/reduce ⇝ 15.44ms @ 1,943,237,765.76 op/s 971 | arr-reduce ⇝ 15.44ms @ 1,942,878,088.93 op/s 972 | fastjs.reduce ⇝ 18.81ms @ 1,594,622,761.95 op/s 973 | lodash.reduce ⇝ 27.60ms @ 1,086,763,818.04 op/s 974 | ramda.reduce ⇝ 23.64ms @ 1,269,233,703.11 op/s 975 | 976 | Benchmark: code/reduce.js • Array(5000) 977 | native ⇝ 178.20ms @ 841,738,702.20 op/s 978 | @arr/reduce ⇝ 74.70ms @ 2,008,062,988.71 op/s 979 | arr-reduce ⇝ 78.49ms @ 1,911,132,979.00 op/s 980 | fastjs.reduce ⇝ 90.02ms @ 1,666,388,879.64 op/s 981 | lodash.reduce ⇝ 136.33ms @ 1,100,301,835.53 op/s 982 | ramda.reduce ⇝ 97.85ms @ 1,533,015,026.95 op/s 983 | 984 | Benchmark: code/reduce.js • Array(10000) 985 | native ⇝ 356.83ms @ 840,727,767.58 op/s 986 | @arr/reduce ⇝ 148.74ms @ 2,016,926,233.20 op/s 987 | arr-reduce ⇝ 148.69ms @ 2,017,627,893.85 op/s 988 | fastjs.reduce ⇝ 178.44ms @ 1,681,224,727.83 op/s 989 | lodash.reduce ⇝ 268.06ms @ 1,119,169,446.15 op/s 990 | ramda.reduce ⇝ 187.10ms @ 1,603,463,138.31 op/s 991 | ``` 992 |
993 | 994 |
995 | :white_check_mark: ↝ Numbers 996 | 997 | ``` 998 | Benchmark: code/reduce.js • Array(100) 999 | native ⇝ 3.99ms @ 752,459,224.86 op/s 1000 | @arr/reduce ⇝ 2.08ms @ 1,439,171,958.02 op/s 1001 | arr-reduce ⇝ 2.10ms @ 1,426,021,566.20 op/s 1002 | fastjs.reduce ⇝ 2.58ms @ 1,160,877,948.78 op/s 1003 | lodash.reduce ⇝ 3.71ms @ 809,654,536.60 op/s 1004 | ramda.reduce ⇝ 7.71ms @ 389,155,835.38 op/s 1005 | 1006 | Benchmark: code/reduce.js • Array(500) 1007 | native ⇝ 18.22ms @ 823,156,828.39 op/s 1008 | @arr/reduce ⇝ 8.19ms @ 1,832,151,697.27 op/s 1009 | arr-reduce ⇝ 8.03ms @ 1,867,356,210.77 op/s 1010 | fastjs.reduce ⇝ 9.62ms @ 1,559,997,179.53 op/s 1011 | lodash.reduce ⇝ 15.49ms @ 968,267,611.09 op/s 1012 | ramda.reduce ⇝ 14.77ms @ 1,015,241,962.96 op/s 1013 | 1014 | Benchmark: code/reduce.js • Array(1000) 1015 | native ⇝ 36.01ms @ 833,013,039.82 op/s 1016 | @arr/reduce ⇝ 15.44ms @ 1,943,250,730.71 op/s 1017 | arr-reduce ⇝ 15.44ms @ 1,943,487,276.96 op/s 1018 | fastjs.reduce ⇝ 18.49ms @ 1,622,864,209.27 op/s 1019 | lodash.reduce ⇝ 27.53ms @ 1,089,732,021.82 op/s 1020 | ramda.reduce ⇝ 24.90ms @ 1,205,040,781.99 op/s 1021 | 1022 | Benchmark: code/reduce.js • Array(5000) 1023 | native ⇝ 178.27ms @ 841,438,428.22 op/s 1024 | @arr/reduce ⇝ 75.14ms @ 1,996,159,920.62 op/s 1025 | arr-reduce ⇝ 74.67ms @ 2,008,789,713.84 op/s 1026 | fastjs.reduce ⇝ 89.84ms @ 1,669,720,139.54 op/s 1027 | lodash.reduce ⇝ 134.56ms @ 1,114,764,259.65 op/s 1028 | ramda.reduce ⇝ 96.46ms @ 1,555,061,509.06 op/s 1029 | 1030 | Benchmark: code/reduce.js • Array(10000) 1031 | native ⇝ 357.14ms @ 840,014,535.95 op/s 1032 | @arr/reduce ⇝ 148.95ms @ 2,014,057,395.56 op/s 1033 | arr-reduce ⇝ 148.71ms @ 2,017,399,967.12 op/s 1034 | fastjs.reduce ⇝ 178.39ms @ 1,681,701,338.23 op/s 1035 | lodash.reduce ⇝ 269.81ms @ 1,111,892,264.84 op/s 1036 | ramda.reduce ⇝ 185.01ms @ 1,621,495,837.37 op/s 1037 | ``` 1038 |
1039 | 1040 |
1041 | :white_check_mark: ↝ Objects 1042 | 1043 | ``` 1044 | Benchmark: code/reduce.js • Array(100) 1045 | native ⇝ 3.98ms @ 753,686,279.59 op/s 1046 | @arr/reduce ⇝ 2.08ms @ 1,440,089,400.75 op/s 1047 | arr-reduce ⇝ 2.10ms @ 1,428,953,843.84 op/s 1048 | fastjs.reduce ⇝ 2.55ms @ 1,177,718,045.66 op/s 1049 | lodash.reduce ⇝ 3.51ms @ 854,217,528.20 op/s 1050 | ramda.reduce ⇝ 9.04ms @ 331,719,517.88 op/s 1051 | 1052 | Benchmark: code/reduce.js • Array(500) 1053 | native ⇝ 18.43ms @ 814,066,593.14 op/s 1054 | @arr/reduce ⇝ 7.98ms @ 1,880,271,340.70 op/s 1055 | arr-reduce ⇝ 8.04ms @ 1,865,404,823.94 op/s 1056 | fastjs.reduce ⇝ 9.61ms @ 1,560,525,447.64 op/s 1057 | lodash.reduce ⇝ 14.20ms @ 1,056,259,403.79 op/s 1058 | ramda.reduce ⇝ 14.72ms @ 1,018,933,620.75 op/s 1059 | 1060 | Benchmark: code/reduce.js • Array(1000) 1061 | native ⇝ 36.00ms @ 833,354,421.83 op/s 1062 | @arr/reduce ⇝ 15.42ms @ 1,946,011,794.78 op/s 1063 | arr-reduce ⇝ 15.40ms @ 1,947,530,793.87 op/s 1064 | fastjs.reduce ⇝ 18.49ms @ 1,622,804,865.67 op/s 1065 | lodash.reduce ⇝ 27.55ms @ 1,088,922,026.00 op/s 1066 | ramda.reduce ⇝ 24.90ms @ 1,204,756,958.76 op/s 1067 | 1068 | Benchmark: code/reduce.js • Array(5000) 1069 | native ⇝ 178.18ms @ 841,850,895.40 op/s 1070 | @arr/reduce ⇝ 74.75ms @ 2,006,672,748.76 op/s 1071 | arr-reduce ⇝ 74.60ms @ 2,010,658,204.24 op/s 1072 | fastjs.reduce ⇝ 90.36ms @ 1,659,986,401.83 op/s 1073 | lodash.reduce ⇝ 135.13ms @ 1,110,017,242.56 op/s 1074 | ramda.reduce ⇝ 97.11ms @ 1,544,688,979.81 op/s 1075 | 1076 | Benchmark: code/reduce.js • Array(10000) 1077 | native ⇝ 356.57ms @ 841,344,989.58 op/s 1078 | @arr/reduce ⇝ 149.14ms @ 2,011,521,701.28 op/s 1079 | arr-reduce ⇝ 148.67ms @ 2,017,916,515.73 op/s 1080 | fastjs.reduce ⇝ 178.63ms @ 1,679,481,173.33 op/s 1081 | lodash.reduce ⇝ 268.57ms @ 1,117,014,541.24 op/s 1082 | ramda.reduce ⇝ 185.10ms @ 1,620,702,893.33 op/s 1083 | ``` 1084 | 1085 | 1086 | 1087 | ## reduceRight 1088 | 1089 |
1090 | :white_check_mark: ↝ Strings 1091 | 1092 | ``` 1093 | Benchmark: code/reduceRight.js • Array(100) 1094 | native ⇝ 44.92ms @ 66,786,893.46 op/s 1095 | @arr/reduceRight ⇝ 5.15ms @ 582,624,279.59 op/s 1096 | fastjs.reduceRight ⇝ 9.79ms @ 306,499,568.55 op/s 1097 | lodash.reduceright ⇝ 9.19ms @ 326,407,545.50 op/s 1098 | ramda.reduceRight ⇝ 17.85ms @ 168,055,062.91 op/s 1099 | 1100 | Benchmark: code/reduceRight.js • Array(500) 1101 | native ⇝ 22.66ms @ 661,977,921.18 op/s 1102 | @arr/reduceRight ⇝ 17.11ms @ 876,619,693.68 op/s 1103 | fastjs.reduceRight ⇝ 14.00ms @ 1,071,241,410.25 op/s 1104 | lodash.reduceright ⇝ 18.62ms @ 805,523,095.96 op/s 1105 | ramda.reduceRight ⇝ 14.75ms @ 1,017,170,102.58 op/s 1106 | 1107 | Benchmark: code/reduceRight.js • Array(1000) 1108 | native ⇝ 44.88ms @ 668,402,776.04 op/s 1109 | @arr/reduceRight ⇝ 27.37ms @ 1,095,909,666.94 op/s 1110 | fastjs.reduceRight ⇝ 27.30ms @ 1,098,953,510.53 op/s 1111 | lodash.reduceright ⇝ 36.47ms @ 822,571,606.16 op/s 1112 | ramda.reduceRight ⇝ 28.10ms @ 1,067,448,133.58 op/s 1113 | 1114 | Benchmark: code/reduceRight.js • Array(5000) 1115 | native ⇝ 223.63ms @ 670,763,337.35 op/s 1116 | @arr/reduceRight ⇝ 134.17ms @ 1,118,015,486.14 op/s 1117 | fastjs.reduceRight ⇝ 134.39ms @ 1,116,174,849.15 op/s 1118 | lodash.reduceright ⇝ 178.98ms @ 838,094,262.82 op/s 1119 | ramda.reduceRight ⇝ 137.33ms @ 1,092,254,422.67 op/s 1120 | 1121 | Benchmark: code/reduceRight.js • Array(10000) 1122 | native ⇝ 445.74ms @ 673,035,054.47 op/s 1123 | @arr/reduceRight ⇝ 267.88ms @ 1,119,896,934.84 op/s 1124 | fastjs.reduceRight ⇝ 269.51ms @ 1,113,135,946.63 op/s 1125 | lodash.reduceright ⇝ 357.38ms @ 839,448,007.87 op/s 1126 | ramda.reduceRight ⇝ 268.87ms @ 1,115,766,875.69 op/s 1127 | ``` 1128 |
1129 | 1130 |
1131 | :white_check_mark: ↝ Numbers 1132 | 1133 | ``` 1134 | Benchmark: code/reduceRight.js • Array(100) 1135 | native ⇝ 4.86ms @ 617,543,674.75 op/s 1136 | @arr/reduceRight ⇝ 3.16ms @ 948,002,385.17 op/s 1137 | fastjs.reduceRight ⇝ 3.30ms @ 908,905,272.07 op/s 1138 | lodash.reduceright ⇝ 4.46ms @ 672,285,328.65 op/s 1139 | ramda.reduceRight ⇝ 4.11ms @ 729,917,417.14 op/s 1140 | 1141 | Benchmark: code/reduceRight.js • Array(500) 1142 | native ⇝ 22.86ms @ 656,296,769.35 op/s 1143 | @arr/reduceRight ⇝ 13.78ms @ 1,088,820,219.01 op/s 1144 | fastjs.reduceRight ⇝ 13.97ms @ 1,073,592,781.10 op/s 1145 | lodash.reduceright ⇝ 18.67ms @ 803,364,791.67 op/s 1146 | ramda.reduceRight ⇝ 14.71ms @ 1,019,483,900.55 op/s 1147 | 1148 | Benchmark: code/reduceRight.js • Array(1000) 1149 | native ⇝ 44.83ms @ 669,235,549.63 op/s 1150 | @arr/reduceRight ⇝ 27.14ms @ 1,105,489,940.43 op/s 1151 | fastjs.reduceRight ⇝ 27.26ms @ 1,100,572,315.95 op/s 1152 | lodash.reduceright ⇝ 36.44ms @ 823,279,060.67 op/s 1153 | ramda.reduceRight ⇝ 29.63ms @ 1,012,601,624.70 op/s 1154 | 1155 | Benchmark: code/reduceRight.js • Array(5000) 1156 | native ⇝ 223.23ms @ 671,958,681.74 op/s 1157 | @arr/reduceRight ⇝ 134.40ms @ 1,116,090,511.73 op/s 1158 | fastjs.reduceRight ⇝ 133.89ms @ 1,120,329,405.53 op/s 1159 | lodash.reduceright ⇝ 178.85ms @ 838,705,170.06 op/s 1160 | ramda.reduceRight ⇝ 135.50ms @ 1,107,008,463.94 op/s 1161 | 1162 | Benchmark: code/reduceRight.js • Array(10000) 1163 | native ⇝ 445.67ms @ 673,139,620.64 op/s 1164 | @arr/reduceRight ⇝ 267.42ms @ 1,121,819,937.76 op/s 1165 | fastjs.reduceRight ⇝ 267.26ms @ 1,122,519,765.92 op/s 1166 | lodash.reduceright ⇝ 358.15ms @ 837,639,776.71 op/s 1167 | ramda.reduceRight ⇝ 268.58ms @ 1,116,998,304.46 op/s 1168 | ``` 1169 |
1170 | 1171 |
1172 | :white_check_mark: ↝ Objects 1173 | 1174 | ``` 1175 | Benchmark: code/reduceRight.js • Array(100) 1176 | native ⇝ 4.89ms @ 613,191,214.69 op/s 1177 | @arr/reduceRight ⇝ 3.12ms @ 962,109,868.46 op/s 1178 | fastjs.reduceRight ⇝ 3.31ms @ 906,685,171.10 op/s 1179 | lodash.reduceright ⇝ 4.45ms @ 674,491,062.77 op/s 1180 | ramda.reduceRight ⇝ 4.11ms @ 729,816,380.63 op/s 1181 | 1182 | Benchmark: code/reduceRight.js • Array(500) 1183 | native ⇝ 22.69ms @ 661,143,648.93 op/s 1184 | @arr/reduceRight ⇝ 14.06ms @ 1,067,183,543.97 op/s 1185 | fastjs.reduceRight ⇝ 13.98ms @ 1,072,938,272.22 op/s 1186 | lodash.reduceright ⇝ 20.33ms @ 737,766,684.83 op/s 1187 | ramda.reduceRight ⇝ 14.97ms @ 1,001,871,495.95 op/s 1188 | 1189 | Benchmark: code/reduceRight.js • Array(1000) 1190 | native ⇝ 45.79ms @ 655,103,464.53 op/s 1191 | @arr/reduceRight ⇝ 27.17ms @ 1,104,189,925.97 op/s 1192 | fastjs.reduceRight ⇝ 27.72ms @ 1,082,366,893.95 op/s 1193 | lodash.reduceright ⇝ 36.70ms @ 817,525,657.23 op/s 1194 | ramda.reduceRight ⇝ 28.10ms @ 1,067,613,112.81 op/s 1195 | 1196 | Benchmark: code/reduceRight.js • Array(5000) 1197 | native ⇝ 223.58ms @ 670,894,341.65 op/s 1198 | @arr/reduceRight ⇝ 135.60ms @ 1,106,180,136.98 op/s 1199 | fastjs.reduceRight ⇝ 133.89ms @ 1,120,311,741.83 op/s 1200 | lodash.reduceright ⇝ 178.85ms @ 838,679,434.82 op/s 1201 | ramda.reduceRight ⇝ 135.64ms @ 1,105,899,359.68 op/s 1202 | 1203 | Benchmark: code/reduceRight.js • Array(10000) 1204 | native ⇝ 446.95ms @ 671,213,597.34 op/s 1205 | @arr/reduceRight ⇝ 267.64ms @ 1,120,902,066.11 op/s 1206 | fastjs.reduceRight ⇝ 267.60ms @ 1,121,067,762.34 op/s 1207 | lodash.reduceright ⇝ 357.47ms @ 839,224,251.65 op/s 1208 | ramda.reduceRight ⇝ 270.69ms @ 1,108,284,902.51 op/s 1209 | ``` 1210 | 1211 | 1212 | 1213 | ## reverse 1214 | 1215 |
1216 | :white_check_mark: ↝ Strings 1217 | 1218 | ``` 1219 | Benchmark: code/reverse.js • Array(100) 1220 | native ⇝ 34.07ms @ 88,058,919.87 op/s 1221 | @arr/reverse ⇝ 8.01ms @ 374,314,629.91 op/s 1222 | compute-reverse ⇝ 11.01ms @ 272,566,953.80 op/s 1223 | lodash.reverse ⇝ 30.44ms @ 98,567,796.77 op/s 1224 | ramda.reverse ⇝ 51.96ms @ 57,732,769.48 op/s 1225 | 1226 | Benchmark: code/reverse.js • Array(500) 1227 | native ⇝ 143.89ms @ 104,243,016.71 op/s 1228 | @arr/reverse ⇝ 22.74ms @ 659,501,548.73 op/s 1229 | compute-reverse ⇝ 22.80ms @ 657,768,924.11 op/s 1230 | lodash.reverse ⇝ 144.02ms @ 104,150,533.46 op/s 1231 | ramda.reverse ⇝ 178.24ms @ 84,156,124.96 op/s 1232 | 1233 | Benchmark: code/reverse.js • Array(1000) 1234 | native ⇝ 297.83ms @ 100,728,445.62 op/s 1235 | @arr/reverse ⇝ 45.08ms @ 665,522,662.79 op/s 1236 | compute-reverse ⇝ 48.61ms @ 617,212,450.49 op/s 1237 | lodash.reverse ⇝ 297.88ms @ 100,712,250.80 op/s 1238 | ramda.reverse ⇝ 358.32ms @ 83,725,097.25 op/s 1239 | 1240 | Benchmark: code/reverse.js • Array(5000) 1241 | native ⇝ 1,441.29ms @ 104,073,782.12 op/s 1242 | @arr/reverse ⇝ 223.65ms @ 670,683,764.33 op/s 1243 | compute-reverse ⇝ 223.15ms @ 672,179,349.93 op/s 1244 | lodash.reverse ⇝ 1,442.21ms @ 104,007,181.19 op/s 1245 | ramda.reverse ⇝ 1,696.15ms @ 88,435,744.45 op/s 1246 | 1247 | Benchmark: code/reverse.js • Array(10000) 1248 | native ⇝ 2,872.10ms @ 104,453,323.51 op/s 1249 | @arr/reverse ⇝ 445.76ms @ 673,003,454.83 op/s 1250 | compute-reverse ⇝ 446.03ms @ 672,598,846.50 op/s 1251 | lodash.reverse ⇝ 2,875.54ms @ 104,328,330.44 op/s 1252 | ramda.reverse ⇝ 3,375.55ms @ 88,874,393.44 op/s 1253 | ``` 1254 |
1255 | 1256 |
1257 | :white_check_mark: ↝ Numbers 1258 | 1259 | ``` 1260 | Benchmark: code/reverse.js • Array(100) 1261 | native ⇝ 29.53ms @ 101,579,149.46 op/s 1262 | @arr/reverse ⇝ 4.68ms @ 640,829,831.91 op/s 1263 | compute-reverse ⇝ 4.74ms @ 632,556,413.49 op/s 1264 | lodash.reverse ⇝ 29.56ms @ 101,498,376.55 op/s 1265 | ramda.reverse ⇝ 41.97ms @ 71,471,568.38 op/s 1266 | 1267 | Benchmark: code/reverse.js • Array(500) 1268 | native ⇝ 143.86ms @ 104,266,309.78 op/s 1269 | @arr/reverse ⇝ 22.73ms @ 659,976,586.67 op/s 1270 | compute-reverse ⇝ 22.78ms @ 658,350,211.24 op/s 1271 | lodash.reverse ⇝ 143.91ms @ 104,230,786.70 op/s 1272 | ramda.reverse ⇝ 176.58ms @ 84,947,893.10 op/s 1273 | 1274 | Benchmark: code/reverse.js • Array(1000) 1275 | native ⇝ 298.70ms @ 100,434,242.51 op/s 1276 | @arr/reverse ⇝ 45.74ms @ 655,920,903.98 op/s 1277 | compute-reverse ⇝ 44.97ms @ 667,080,849.75 op/s 1278 | lodash.reverse ⇝ 297.45ms @ 100,856,041.88 op/s 1279 | ramda.reverse ⇝ 356.65ms @ 84,115,837.27 op/s 1280 | 1281 | Benchmark: code/reverse.js • Array(5000) 1282 | native ⇝ 1,441.48ms @ 104,059,537.16 op/s 1283 | @arr/reverse ⇝ 225.16ms @ 666,180,609.45 op/s 1284 | compute-reverse ⇝ 223.57ms @ 670,926,378.24 op/s 1285 | lodash.reverse ⇝ 1,440.86ms @ 104,104,677.68 op/s 1286 | ramda.reverse ⇝ 1,693.17ms @ 88,590,997.39 op/s 1287 | 1288 | Benchmark: code/reverse.js • Array(10000) 1289 | native ⇝ 2,871.49ms @ 104,475,346.01 op/s 1290 | @arr/reverse ⇝ 446.02ms @ 672,613,241.83 op/s 1291 | compute-reverse ⇝ 446.49ms @ 671,904,589.98 op/s 1292 | lodash.reverse ⇝ 2,868.96ms @ 104,567,367.22 op/s 1293 | ramda.reverse ⇝ 3,345.24ms @ 89,679,548.54 op/s 1294 | ``` 1295 |
1296 | 1297 |
1298 | :white_check_mark: ↝ Objects 1299 | 1300 | ``` 1301 | Benchmark: code/reverse.js • Array(100) 1302 | native ⇝ 29.51ms @ 101,671,217.24 op/s 1303 | @arr/reverse ⇝ 4.67ms @ 641,865,414.94 op/s 1304 | compute-reverse ⇝ 4.77ms @ 629,486,930.38 op/s 1305 | lodash.reverse ⇝ 29.81ms @ 100,643,247.90 op/s 1306 | ramda.reverse ⇝ 40.31ms @ 74,430,707.43 op/s 1307 | 1308 | Benchmark: code/reverse.js • Array(500) 1309 | native ⇝ 143.89ms @ 104,246,647.01 op/s 1310 | @arr/reverse ⇝ 22.73ms @ 659,808,006.43 op/s 1311 | compute-reverse ⇝ 22.89ms @ 655,256,267.01 op/s 1312 | lodash.reverse ⇝ 144.38ms @ 103,895,767.83 op/s 1313 | ramda.reverse ⇝ 177.74ms @ 84,394,477.61 op/s 1314 | 1315 | Benchmark: code/reverse.js • Array(1000) 1316 | native ⇝ 297.58ms @ 100,813,782.97 op/s 1317 | @arr/reverse ⇝ 44.98ms @ 666,981,748.84 op/s 1318 | compute-reverse ⇝ 45.05ms @ 665,973,506.64 op/s 1319 | lodash.reverse ⇝ 297.10ms @ 100,977,514.85 op/s 1320 | ramda.reverse ⇝ 358.25ms @ 83,741,429.75 op/s 1321 | 1322 | Benchmark: code/reverse.js • Array(5000) 1323 | native ⇝ 1,441.34ms @ 104,069,748.46 op/s 1324 | @arr/reverse ⇝ 223.29ms @ 671,780,257.99 op/s 1325 | compute-reverse ⇝ 223.27ms @ 671,820,801.21 op/s 1326 | lodash.reverse ⇝ 1,442.58ms @ 103,980,020.15 op/s 1327 | ramda.reverse ⇝ 1,683.07ms @ 89,122,996.01 op/s 1328 | 1329 | Benchmark: code/reverse.js • Array(10000) 1330 | native ⇝ 2,878.55ms @ 104,219,043.07 op/s 1331 | @arr/reverse ⇝ 446.36ms @ 672,107,728.22 op/s 1332 | compute-reverse ⇝ 446.09ms @ 672,502,551.15 op/s 1333 | lodash.reverse ⇝ 2,874.96ms @ 104,349,426.83 op/s 1334 | ramda.reverse ⇝ 3,366.55ms @ 89,111,913.30 op/s 1335 | ``` 1336 | 1337 | 1338 | 1339 | ## some 1340 | 1341 |
1342 | :white_check_mark: ↝ Strings 1343 | 1344 | ``` 1345 | Benchmark: code/some.js • Array(100) 1346 | native ⇝ 15.60ms @ 192,291,680.33 op/s 1347 | @arr/some ⇝ 7.69ms @ 389,921,617.96 op/s 1348 | fastjs.some ⇝ 8.09ms @ 370,792,982.82 op/s 1349 | lodash.some ⇝ 7.21ms @ 416,040,814.16 op/s 1350 | 1351 | Benchmark: code/some.js • Array(500) 1352 | native ⇝ 31.26ms @ 479,779,470.33 op/s 1353 | @arr/some ⇝ 11.86ms @ 1,264,760,706.01 op/s 1354 | fastjs.some ⇝ 11.88ms @ 1,262,892,235.38 op/s 1355 | lodash.some ⇝ 19.91ms @ 753,457,427.77 op/s 1356 | 1357 | Benchmark: code/some.js • Array(1000) 1358 | native ⇝ 61.95ms @ 484,226,679.10 op/s 1359 | @arr/some ⇝ 23.27ms @ 1,289,224,771.10 op/s 1360 | fastjs.some ⇝ 23.26ms @ 1,289,975,868.42 op/s 1361 | lodash.some ⇝ 38.67ms @ 775,865,252.69 op/s 1362 | 1363 | Benchmark: code/some.js • Array(5000) 1364 | native ⇝ 306.71ms @ 489,061,608.93 op/s 1365 | @arr/some ⇝ 116.12ms @ 1,291,810,702.12 op/s 1366 | fastjs.some ⇝ 114.18ms @ 1,313,746,114.46 op/s 1367 | lodash.some ⇝ 190.21ms @ 788,586,279.77 op/s 1368 | 1369 | Benchmark: code/some.js • Array(10000) 1370 | native ⇝ 611.88ms @ 490,294,158.09 op/s 1371 | @arr/some ⇝ 227.56ms @ 1,318,350,050.63 op/s 1372 | fastjs.some ⇝ 227.72ms @ 1,317,425,010.61 op/s 1373 | lodash.some ⇝ 379.69ms @ 790,108,380.35 op/s 1374 | ``` 1375 |
1376 | 1377 |
1378 | :white_check_mark: ↝ Numbers 1379 | 1380 | ``` 1381 | Benchmark: code/some.js • Array(100) 1382 | native ⇝ 6.88ms @ 436,281,774.04 op/s 1383 | @arr/some ⇝ 2.53ms @ 1,184,494,960.96 op/s 1384 | fastjs.some ⇝ 2.55ms @ 1,176,307,289.11 op/s 1385 | lodash.some ⇝ 4.27ms @ 702,869,276.39 op/s 1386 | 1387 | Benchmark: code/some.js • Array(500) 1388 | native ⇝ 31.22ms @ 480,520,422.84 op/s 1389 | @arr/some ⇝ 11.93ms @ 1,257,805,943.69 op/s 1390 | fastjs.some ⇝ 11.86ms @ 1,264,547,992.38 op/s 1391 | lodash.some ⇝ 20.06ms @ 747,711,330.39 op/s 1392 | 1393 | Benchmark: code/some.js • Array(1000) 1394 | native ⇝ 63.02ms @ 476,072,667.10 op/s 1395 | @arr/some ⇝ 23.18ms @ 1,294,438,226.11 op/s 1396 | fastjs.some ⇝ 23.41ms @ 1,281,767,868.93 op/s 1397 | lodash.some ⇝ 39.40ms @ 761,513,087.92 op/s 1398 | 1399 | Benchmark: code/some.js • Array(5000) 1400 | native ⇝ 306.69ms @ 489,088,515.11 op/s 1401 | @arr/some ⇝ 114.01ms @ 1,315,673,463.60 op/s 1402 | fastjs.some ⇝ 114.50ms @ 1,310,033,668.39 op/s 1403 | lodash.some ⇝ 190.22ms @ 788,549,752.92 op/s 1404 | 1405 | Benchmark: code/some.js • Array(10000) 1406 | native ⇝ 615.07ms @ 487,745,756.13 op/s 1407 | @arr/some ⇝ 227.83ms @ 1,316,756,215.31 op/s 1408 | fastjs.some ⇝ 231.61ms @ 1,295,303,448.60 op/s 1409 | lodash.some ⇝ 382.79ms @ 783,717,413.86 op/s 1410 | ``` 1411 |
1412 | 1413 |
1414 | :white_check_mark: ↝ Objects 1415 | 1416 | ``` 1417 | Benchmark: code/some.js • Array(100) 1418 | native ⇝ 6.85ms @ 438,238,980.48 op/s 1419 | @arr/some ⇝ 2.53ms @ 1,184,241,067.27 op/s 1420 | fastjs.some ⇝ 2.55ms @ 1,176,186,919.63 op/s 1421 | lodash.some ⇝ 4.36ms @ 688,588,414.41 op/s 1422 | 1423 | Benchmark: code/some.js • Array(500) 1424 | native ⇝ 31.57ms @ 475,164,302.31 op/s 1425 | @arr/some ⇝ 12.29ms @ 1,220,411,727.86 op/s 1426 | fastjs.some ⇝ 12.46ms @ 1,203,799,866.51 op/s 1427 | lodash.some ⇝ 20.56ms @ 729,683,069.46 op/s 1428 | 1429 | Benchmark: code/some.js • Array(1000) 1430 | native ⇝ 63.54ms @ 472,159,924.22 op/s 1431 | @arr/some ⇝ 23.16ms @ 1,295,366,990.42 op/s 1432 | fastjs.some ⇝ 23.31ms @ 1,286,896,723.19 op/s 1433 | lodash.some ⇝ 38.68ms @ 775,549,248.50 op/s 1434 | 1435 | Benchmark: code/some.js • Array(5000) 1436 | native ⇝ 306.95ms @ 488,683,140.98 op/s 1437 | @arr/some ⇝ 115.76ms @ 1,295,736,339.84 op/s 1438 | fastjs.some ⇝ 117.91ms @ 1,272,108,525.31 op/s 1439 | lodash.some ⇝ 192.16ms @ 780,597,713.04 op/s 1440 | 1441 | Benchmark: code/some.js • Array(10000) 1442 | native ⇝ 623.40ms @ 481,229,188.70 op/s 1443 | @arr/some ⇝ 228.72ms @ 1,311,631,526.96 op/s 1444 | fastjs.some ⇝ 233.76ms @ 1,283,386,651.35 op/s 1445 | lodash.some ⇝ 383.18ms @ 782,920,703.85 op/s 1446 | ``` 1447 | 1448 | 1449 | 1450 | ## unique 1451 | 1452 |
1453 | :mag: ↝ Strings 1454 | 1455 | ``` 1456 | Benchmark: code/unique.js • Array(5) 1457 | native ⇝ 16.26ms @ 9,225,327.71 op/s 1458 | @arr/unique ⇝ 6.77ms @ 22,157,011.67 op/s 1459 | arr-uniq ⇝ 19.95ms @ 7,517,550.47 op/s 1460 | array-unique ⇝ 6.55ms @ 22,906,729.60 op/s 1461 | lodash.uniq ⇝ 9.63ms @ 15,572,894.07 op/s 1462 | ramda.uniq ⇝ 46.19ms @ 3,247,221.63 op/s 1463 | 1464 | Benchmark: code/unique.js • Array(10) 1465 | native ⇝ 22.67ms @ 13,235,654.21 op/s 1466 | @arr/unique ⇝ 11.88ms @ 25,244,992.13 op/s 1467 | arr-uniq ⇝ 40.24ms @ 7,456,095.16 op/s 1468 | array-unique ⇝ 13.09ms @ 22,923,858.71 op/s 1469 | lodash.uniq ⇝ 15.68ms @ 19,132,640.86 op/s 1470 | ramda.uniq ⇝ 71.78ms @ 4,179,318.63 op/s 1471 | 1472 | Benchmark: code/unique.js • Array(100) 1473 | native ⇝ 136.17ms @ 22,030,682.09 op/s 1474 | @arr/unique ⇝ 599.74ms @ 5,002,147.00 op/s 1475 | arr-uniq ⇝ 2,243.32ms @ 1,337,306.29 op/s 1476 | array-unique ⇝ 978.89ms @ 3,064,689.93 op/s 1477 | lodash.uniq ⇝ 720.74ms @ 4,162,366.83 op/s 1478 | ramda.uniq ⇝ 652.45ms @ 4,598,068.76 op/s 1479 | 1480 | Benchmark: code/unique.js • Array(500) 1481 | native ⇝ 698.15ms @ 21,485,337.38 op/s 1482 | @arr/unique ⇝ 14,947.39ms @ 1,003,519.54 op/s 1483 | arr-uniq ⇝ 53,945.97ms @ 278,056.01 op/s 1484 | array-unique ⇝ 29,208.68ms @ 513,545.90 op/s 1485 | lodash.uniq ⇝ 892.80ms @ 16,801,068.48 op/s 1486 | ramda.uniq ⇝ 2,897.51ms @ 5,176,861.23 op/s 1487 | ``` 1488 |
1489 | 1490 | 1491 |
1492 | 1493 | > :white_check_mark: — Denotes function **is** faster than native
1494 | > :no_entry_sign: — Denotes function **is not** faster than native
1495 | > :mag: — Denotes function **is sometimes** faster than native
1496 | > :wavy_dash: — Denotes function has no native counterpart
1497 | -------------------------------------------------------------------------------- /benchmarks/results/node-7.md: -------------------------------------------------------------------------------- 1 | # Benchmark Results for Node `v7.9.0` 2 | 3 | All benchmarks were run on the same machine: 4 | 5 | ``` 6 | MacBook Pro (Retina, 15-inch, Early 2013) 7 | - 2.4 GHz Intel Core i7 8 | - 8 GB 1600 MHz DDR3 9 | ``` 10 | 11 | In search for utmost consistency, no other applications were running during testing. Please note that numbers will vary per machine. 12 | 13 | > Don't forget to view results for other Node versions! 14 | 15 | 16 | ## every 17 | 18 |
19 | :white_check_mark: ↝ Strings 20 | 21 | ``` 22 | Array(100) 23 | native ⇝ 58.41ms @ 51,363,468.09 op/s 24 | @arr/every ⇝ 6.03ms @ 497,405,450.27 op/s 25 | array-every ⇝ 9.95ms @ 301,566,517.43 op/s 26 | lodash.every ⇝ 7.64ms @ 392,675,862.18 op/s 27 | fastjs.every ⇝ 8.66ms @ 346,561,909.47 op/s 28 | 29 | Array(500) 30 | native ⇝ 289.76ms @ 51,767,710.63 op/s 31 | @arr/every ⇝ 23.11ms @ 649,153,402.26 op/s 32 | array-every ⇝ 32.61ms @ 460,018,941.13 op/s 33 | lodash.every ⇝ 31.37ms @ 478,192,767.98 op/s 34 | fastjs.every ⇝ 23.62ms @ 635,125,299.85 op/s 35 | 36 | Array(1000) 37 | native ⇝ 577.41ms @ 51,956,558.61 op/s 38 | @arr/every ⇝ 45.45ms @ 660,014,338.15 op/s 39 | array-every ⇝ 72.15ms @ 415,818,028.27 op/s 40 | lodash.every ⇝ 54.28ms @ 552,680,195.90 op/s 41 | fastjs.every ⇝ 45.15ms @ 664,383,328.81 op/s 42 | 43 | Array(5000) 44 | native ⇝ 2,828.80ms @ 53,026,053.72 op/s 45 | @arr/every ⇝ 223.32ms @ 671,676,775.38 op/s 46 | array-every ⇝ 318.54ms @ 470,891,300.20 op/s 47 | lodash.every ⇝ 268.06ms @ 559,578,854.98 op/s 48 | fastjs.every ⇝ 223.56ms @ 670,954,525.31 op/s 49 | 50 | Array(10000) 51 | native ⇝ 5,671.45ms @ 52,896,535.40 op/s 52 | @arr/every ⇝ 449.61ms @ 667,241,600.58 op/s 53 | array-every ⇝ 629.47ms @ 476,588,789.43 op/s 54 | lodash.every ⇝ 539.38ms @ 556,192,522.68 op/s 55 | fastjs.every ⇝ 454.38ms @ 660,235,334.81 op/s 56 | ``` 57 |
58 | 59 |
60 | :white_check_mark: ↝ Numbers 61 | 62 | ``` 63 | Array(100) 64 | native ⇝ 57.66ms @ 52,032,266.73 op/s 65 | @arr/every ⇝ 7.18ms @ 417,921,184.80 op/s 66 | array-every ⇝ 7.86ms @ 381,705,419.10 op/s 67 | lodash.every ⇝ 7.79ms @ 384,937,399.56 op/s 68 | fastjs.every ⇝ 6.30ms @ 476,240,519.24 op/s 69 | 70 | Array(500) 71 | native ⇝ 291.89ms @ 51,388,768.45 op/s 72 | @arr/every ⇝ 22.92ms @ 654,469,022.08 op/s 73 | array-every ⇝ 32.27ms @ 464,825,896.21 op/s 74 | lodash.every ⇝ 27.78ms @ 539,910,975.16 op/s 75 | fastjs.every ⇝ 23.03ms @ 651,195,336.33 op/s 76 | 77 | Array(1000) 78 | native ⇝ 570.40ms @ 52,594,496.60 op/s 79 | @arr/every ⇝ 45.27ms @ 662,723,828.07 op/s 80 | array-every ⇝ 63.54ms @ 472,172,564.97 op/s 81 | lodash.every ⇝ 54.12ms @ 554,299,676.73 op/s 82 | fastjs.every ⇝ 45.56ms @ 658,459,264.58 op/s 83 | 84 | Array(5000) 85 | native ⇝ 2,826.25ms @ 53,073,926.04 op/s 86 | @arr/every ⇝ 223.76ms @ 670,357,176.58 op/s 87 | array-every ⇝ 317.05ms @ 473,117,477.54 op/s 88 | lodash.every ⇝ 272.85ms @ 549,747,674.98 op/s 89 | fastjs.every ⇝ 227.41ms @ 659,590,097.47 op/s 90 | 91 | Array(10000) 92 | native ⇝ 6,738.48ms @ 44,520,405.41 op/s 93 | @arr/every ⇝ 449.13ms @ 667,950,727.72 op/s 94 | array-every ⇝ 629.20ms @ 476,796,502.71 op/s 95 | lodash.every ⇝ 534.59ms @ 561,178,540.63 op/s 96 | fastjs.every ⇝ 446.23ms @ 672,299,579.49 op/s 97 | ``` 98 |
99 | 100 |
101 | :white_check_mark: ↝ Objects 102 | 103 | ``` 104 | Array(100) 105 | native ⇝ 64.13ms @ 46,781,481.63 op/s 106 | @arr/every ⇝ 5.16ms @ 581,156,241.34 op/s 107 | array-every ⇝ 9.46ms @ 317,290,659.29 op/s 108 | lodash.every ⇝ 6.30ms @ 476,301,915.72 op/s 109 | fastjs.every ⇝ 5.33ms @ 562,788,640.22 op/s 110 | 111 | Array(500) 112 | native ⇝ 288.31ms @ 52,028,144.30 op/s 113 | @arr/every ⇝ 22.86ms @ 656,072,380.70 op/s 114 | array-every ⇝ 34.73ms @ 431,866,471.03 op/s 115 | lodash.every ⇝ 27.62ms @ 543,071,114.95 op/s 116 | fastjs.every ⇝ 22.94ms @ 653,882,764.57 op/s 117 | 118 | Array(1000) 119 | native ⇝ 576.90ms @ 52,001,842.29 op/s 120 | @arr/every ⇝ 45.03ms @ 666,234,043.89 op/s 121 | array-every ⇝ 69.54ms @ 431,391,347.53 op/s 122 | lodash.every ⇝ 54.25ms @ 553,044,090.17 op/s 123 | fastjs.every ⇝ 45.06ms @ 665,766,727.59 op/s 124 | 125 | Array(5000) 126 | native ⇝ 2,830.97ms @ 52,985,398.78 op/s 127 | @arr/every ⇝ 223.20ms @ 672,043,092.05 op/s 128 | array-every ⇝ 314.79ms @ 476,503,118.21 op/s 129 | lodash.every ⇝ 275.69ms @ 544,093,662.34 op/s 130 | fastjs.every ⇝ 223.75ms @ 670,387,232.38 op/s 131 | 132 | Array(10000) 133 | native ⇝ 5,670.54ms @ 52,904,973.38 op/s 134 | @arr/every ⇝ 445.04ms @ 674,094,183.92 op/s 135 | array-every ⇝ 629.55ms @ 476,534,365.32 op/s 136 | lodash.every ⇝ 534.83ms @ 560,927,199.05 op/s 137 | fastjs.every ⇝ 446.42ms @ 672,006,958.12 op/s 138 | ``` 139 | 140 | 141 | 142 | ## filter 143 | 144 |
145 | :white_check_mark: ↝ Strings 146 | 147 | ``` 148 | Array(100) 149 | native ⇝ 399.46ms @ 7,510,160.23 op/s 150 | @arr/filter ⇝ 24.40ms @ 122,960,827.88 op/s 151 | @arr/filter.mutate ⇝ 6.86ms @ 437,607,140.81 op/s 152 | arr-filter ⇝ 30.77ms @ 97,482,149.80 op/s 153 | array-filter ⇝ 391.18ms @ 7,669,175.41 op/s 154 | lodash.filter ⇝ 26.67ms @ 112,498,648.61 op/s 155 | fastjs.filter ⇝ 32.22ms @ 93,102,816.14 op/s 156 | ramda.filter ⇝ 37.37ms @ 80,287,220.57 op/s 157 | 158 | Array(500) 159 | native ⇝ 1,868.70ms @ 8,026,954.32 op/s 160 | @arr/filter ⇝ 102.46ms @ 146,399,480.46 op/s 161 | @arr/filter.mutate ⇝ 27.56ms @ 544,182,405.30 op/s 162 | arr-filter ⇝ 95.76ms @ 156,645,687.01 op/s 163 | array-filter ⇝ 1,855.01ms @ 8,086,211.60 op/s 164 | lodash.filter ⇝ 112.45ms @ 133,391,987.87 op/s 165 | fastjs.filter ⇝ 103.11ms @ 145,481,682.28 op/s 166 | ramda.filter ⇝ 116.21ms @ 129,071,323.65 op/s 167 | 168 | Array(1000) 169 | native ⇝ 3,737.02ms @ 8,027,790.54 op/s 170 | @arr/filter ⇝ 222.43ms @ 134,873,711.00 op/s 171 | @arr/filter.mutate ⇝ 54.39ms @ 551,522,465.82 op/s 172 | arr-filter ⇝ 186.84ms @ 160,561,594.79 op/s 173 | array-filter ⇝ 3,730.01ms @ 8,042,871.62 op/s 174 | lodash.filter ⇝ 238.38ms @ 125,849,522.56 op/s 175 | fastjs.filter ⇝ 220.34ms @ 136,151,252.17 op/s 176 | ramda.filter ⇝ 227.30ms @ 131,983,841.96 op/s 177 | 178 | Array(5000) 179 | native ⇝ 18,746.54ms @ 8,001,476.68 op/s 180 | @arr/filter ⇝ 1,139.04ms @ 131,690,243.41 op/s 181 | @arr/filter.mutate ⇝ 268.02ms @ 559,662,562.58 op/s 182 | arr-filter ⇝ 906.95ms @ 165,389,807.55 op/s 183 | array-filter ⇝ 18,719.09ms @ 8,013,208.45 op/s 184 | lodash.filter ⇝ 1,225.86ms @ 122,363,264.57 op/s 185 | fastjs.filter ⇝ 1,144.29ms @ 131,085,357.18 op/s 186 | ramda.filter ⇝ 1,142.85ms @ 131,250,757.73 op/s 187 | 188 | Array(10000) 189 | native ⇝ 36,867.70ms @ 8,137,203.53 op/s 190 | @arr/filter ⇝ 1,940.73ms @ 154,581,072.61 op/s 191 | @arr/filter.mutate ⇝ 543.18ms @ 552,304,605.75 op/s 192 | arr-filter ⇝ 1,798.63ms @ 166,793,382.47 op/s 193 | array-filter ⇝ 36,911.30ms @ 8,127,593.45 op/s 194 | lodash.filter ⇝ 2,110.98ms @ 142,114,291.90 op/s 195 | fastjs.filter ⇝ 1,937.96ms @ 154,801,874.50 op/s 196 | ramda.filter ⇝ 1,888.60ms @ 158,847,587.69 op/s 197 | ``` 198 |
199 | 200 |
201 | :white_check_mark: ↝ Numbers 202 | 203 | ``` 204 | Array(100) 205 | native ⇝ 386.01ms @ 7,771,722.34 op/s 206 | @arr/filter ⇝ 22.68ms @ 132,256,903.22 op/s 207 | @arr/filter.mutate ⇝ 6.02ms @ 498,314,699.69 op/s 208 | arr-filter ⇝ 23.71ms @ 126,508,593.90 op/s 209 | array-filter ⇝ 379.20ms @ 7,911,470.12 op/s 210 | lodash.filter ⇝ 24.20ms @ 123,972,454.31 op/s 211 | fastjs.filter ⇝ 23.49ms @ 127,711,196.96 op/s 212 | ramda.filter ⇝ 34.87ms @ 86,043,665.78 op/s 213 | 214 | Array(500) 215 | native ⇝ 1,863.16ms @ 8,050,823.24 op/s 216 | @arr/filter ⇝ 97.65ms @ 153,612,047.51 op/s 217 | @arr/filter.mutate ⇝ 27.39ms @ 547,633,989.33 op/s 218 | arr-filter ⇝ 89.94ms @ 166,771,582.67 op/s 219 | array-filter ⇝ 1,841.70ms @ 8,144,663.11 op/s 220 | lodash.filter ⇝ 106.93ms @ 140,283,226.22 op/s 221 | fastjs.filter ⇝ 97.85ms @ 153,300,186.63 op/s 222 | ramda.filter ⇝ 111.87ms @ 134,080,578.10 op/s 223 | 224 | Array(1000) 225 | native ⇝ 3,697.08ms @ 8,114,522.90 op/s 226 | @arr/filter ⇝ 210.70ms @ 142,384,584.69 op/s 227 | @arr/filter.mutate ⇝ 54.13ms @ 554,217,776.48 op/s 228 | arr-filter ⇝ 170.29ms @ 176,169,099.69 op/s 229 | array-filter ⇝ 3,681.91ms @ 8,147,939.58 op/s 230 | lodash.filter ⇝ 235.13ms @ 127,586,828.80 op/s 231 | fastjs.filter ⇝ 212.01ms @ 141,499,544.35 op/s 232 | ramda.filter ⇝ 220.13ms @ 136,280,526.92 op/s 233 | 234 | Array(5000) 235 | native ⇝ 18,523.06ms @ 8,098,014.81 op/s 236 | @arr/filter ⇝ 1,088.55ms @ 137,797,687.12 op/s 237 | @arr/filter.mutate ⇝ 267.67ms @ 560,391,807.42 op/s 238 | arr-filter ⇝ 831.67ms @ 180,360,006.15 op/s 239 | array-filter ⇝ 18,349.92ms @ 8,174,423.10 op/s 240 | lodash.filter ⇝ 1,193.71ms @ 125,658,678.29 op/s 241 | fastjs.filter ⇝ 1,092.10ms @ 137,349,550.54 op/s 242 | ramda.filter ⇝ 1,083.45ms @ 138,447,051.53 op/s 243 | 244 | Array(10000) 245 | native ⇝ 36,294.12ms @ 8,265,802.63 op/s 246 | @arr/filter ⇝ 1,851.95ms @ 161,991,490.29 op/s 247 | @arr/filter.mutate ⇝ 535.06ms @ 560,679,920.84 op/s 248 | arr-filter ⇝ 1,689.80ms @ 177,535,438.70 op/s 249 | array-filter ⇝ 36,271.65ms @ 8,270,923.21 op/s 250 | lodash.filter ⇝ 2,028.00ms @ 147,929,189.72 op/s 251 | fastjs.filter ⇝ 1,842.97ms @ 162,781,110.76 op/s 252 | ramda.filter ⇝ 1,806.21ms @ 166,093,868.98 op/s 253 | ``` 254 |
255 | 256 |
257 | :white_check_mark: ↝ Objects 258 | 259 | ``` 260 | Array(100) 261 | native ⇝ 391.66ms @ 7,659,662.09 op/s 262 | @arr/filter ⇝ 23.24ms @ 129,071,495.80 op/s 263 | @arr/filter.mutate ⇝ 6.02ms @ 498,443,858.27 op/s 264 | arr-filter ⇝ 25.43ms @ 117,975,832.02 op/s 265 | array-filter ⇝ 388.24ms @ 7,727,267.10 op/s 266 | lodash.filter ⇝ 24.81ms @ 120,941,130.01 op/s 267 | fastjs.filter ⇝ 23.42ms @ 128,093,511.68 op/s 268 | ramda.filter ⇝ 34.64ms @ 86,605,498.36 op/s 269 | 270 | Array(500) 271 | native ⇝ 1,890.16ms @ 7,935,846.99 op/s 272 | @arr/filter ⇝ 101.61ms @ 147,618,869.26 op/s 273 | @arr/filter.mutate ⇝ 27.29ms @ 549,744,693.07 op/s 274 | arr-filter ⇝ 96.28ms @ 155,796,594.58 op/s 275 | array-filter ⇝ 1,873.74ms @ 8,005,378.25 op/s 276 | lodash.filter ⇝ 119.63ms @ 125,383,344.95 op/s 277 | fastjs.filter ⇝ 102.96ms @ 145,683,320.18 op/s 278 | ramda.filter ⇝ 116.41ms @ 128,860,165.18 op/s 279 | 280 | Array(1000) 281 | native ⇝ 3,790.15ms @ 7,915,262.79 op/s 282 | @arr/filter ⇝ 224.04ms @ 133,902,590.14 op/s 283 | @arr/filter.mutate ⇝ 54.00ms @ 555,544,845.89 op/s 284 | arr-filter ⇝ 192.17ms @ 156,112,360.12 op/s 285 | array-filter ⇝ 3,823.31ms @ 7,846,607.33 op/s 286 | lodash.filter ⇝ 241.50ms @ 124,224,590.62 op/s 287 | fastjs.filter ⇝ 224.12ms @ 133,857,891.47 op/s 288 | ramda.filter ⇝ 233.35ms @ 128,563,609.15 op/s 289 | 290 | Array(5000) 291 | native ⇝ 20,269.19ms @ 7,400,396.11 op/s 292 | @arr/filter ⇝ 1,205.19ms @ 124,461,374.73 op/s 293 | @arr/filter.mutate ⇝ 267.65ms @ 560,431,502.67 op/s 294 | arr-filter ⇝ 951.77ms @ 157,600,819.61 op/s 295 | array-filter ⇝ 19,868.70ms @ 7,549,564.55 op/s 296 | lodash.filter ⇝ 1,309.43ms @ 114,554,005.35 op/s 297 | fastjs.filter ⇝ 1,244.75ms @ 120,506,020.30 op/s 298 | ramda.filter ⇝ 1,193.22ms @ 125,710,015.93 op/s 299 | 300 | Array(10000) 301 | native ⇝ 38,785.31ms @ 7,734,887.95 op/s 302 | @arr/filter ⇝ 2,061.96ms @ 145,492,416.30 op/s 303 | @arr/filter.mutate ⇝ 537.66ms @ 557,975,881.34 op/s 304 | arr-filter ⇝ 1,893.51ms @ 158,436,146.09 op/s 305 | array-filter ⇝ 38,897.36ms @ 7,712,605.11 op/s 306 | lodash.filter ⇝ 2,229.66ms @ 134,549,666.14 op/s 307 | fastjs.filter ⇝ 2,072.31ms @ 144,766,194.31 op/s 308 | ramda.filter ⇝ 2,059.35ms @ 145,677,104.33 op/s 309 | ``` 310 | 311 | 312 | 313 | ## find 314 | 315 |
316 | :white_check_mark: ↝ Strings 317 | 318 | ``` 319 | Array(100) 320 | native ⇝ 2.26ms @ 1,328,305,843.31 op/s 321 | @arr/find ⇝ 0.94ms @ 3,181,079,785.72 op/s 322 | lodash.find ⇝ 9.67ms @ 310,210,902.05 op/s 323 | ramda.find ⇝ 40.26ms @ 74,507,361.05 op/s 324 | 325 | Array(500) 326 | native ⇝ 1.34ms @ 11,217,435,783.92 op/s 327 | @arr/find ⇝ 0.53ms @ 28,537,563,995.49 op/s 328 | lodash.find ⇝ 3.90ms @ 3,844,444,546.96 op/s 329 | ramda.find ⇝ 28.13ms @ 533,178,924.72 op/s 330 | 331 | Array(1000) 332 | native ⇝ 1.37ms @ 21,956,226,602.90 op/s 333 | @arr/find ⇝ 0.56ms @ 53,972,948,758.08 op/s 334 | lodash.find ⇝ 3.95ms @ 7,601,701,260.74 op/s 335 | ramda.find ⇝ 29.20ms @ 1,027,263,927.05 op/s 336 | 337 | Array(5000) 338 | native ⇝ 2.04ms @ 73,380,743,816.57 op/s 339 | @arr/find ⇝ 0.73ms @ 205,888,973,684.64 op/s 340 | lodash.find ⇝ 6.06ms @ 24,757,663,734.81 op/s 341 | ramda.find ⇝ 29.18ms @ 5,140,450,824.39 op/s 342 | 343 | Array(10000) 344 | native ⇝ 1.41ms @ 213,391,299,894.44 op/s 345 | @arr/find ⇝ 0.55ms @ 550,165,966,733.30 op/s 346 | lodash.find ⇝ 3.91ms @ 76,718,710,082.30 op/s 347 | ramda.find ⇝ 28.02ms @ 10,704,885,677.71 op/s 348 | ``` 349 |
350 | 351 |
352 | :white_check_mark: ↝ Numbers 353 | 354 | ``` 355 | Array(100) 356 | native ⇝ 334.13ms @ 8,978,509.71 op/s 357 | @arr/find ⇝ 287.83ms @ 10,422,893.01 op/s 358 | lodash.find ⇝ 303.12ms @ 9,897,225.30 op/s 359 | ramda.find ⇝ 326.72ms @ 9,182,270.09 op/s 360 | 361 | Array(500) 362 | native ⇝ 1,608.55ms @ 9,325,144.73 op/s 363 | @arr/find ⇝ 1,394.19ms @ 10,758,898.20 op/s 364 | lodash.find ⇝ 1,408.26ms @ 10,651,479.40 op/s 365 | ramda.find ⇝ 1,422.91ms @ 10,541,801.79 op/s 366 | 367 | Array(1000) 368 | native ⇝ 3,197.71ms @ 9,381,721.22 op/s 369 | @arr/find ⇝ 2,770.44ms @ 10,828,618.93 op/s 370 | lodash.find ⇝ 2,843.48ms @ 10,550,452.87 op/s 371 | ramda.find ⇝ 2,836.42ms @ 10,576,707.38 op/s 372 | 373 | Array(5000) 374 | native ⇝ 16,035.87ms @ 9,354,031.68 op/s 375 | @arr/find ⇝ 13,832.32ms @ 10,844,169.14 op/s 376 | lodash.find ⇝ 14,084.22ms @ 10,650,216.78 op/s 377 | ramda.find ⇝ 13,867.79ms @ 10,816,434.84 op/s 378 | 379 | Array(10000) 380 | native ⇝ 32,103.50ms @ 9,344,774.08 op/s 381 | @arr/find ⇝ 27,724.05ms @ 10,820,928.51 op/s 382 | lodash.find ⇝ 28,186.21ms @ 10,643,504.42 op/s 383 | ramda.find ⇝ 27,877.50ms @ 10,761,366.21 op/s 384 | ``` 385 |
386 | 387 |
388 | :white_check_mark: ↝ Objects 389 | 390 | ``` 391 | Array(100) 392 | native ⇝ 183.65ms @ 16,335,845.11 op/s 393 | @arr/find ⇝ 132.08ms @ 22,713,991.75 op/s 394 | lodash.find ⇝ 140.36ms @ 21,374,205.07 op/s 395 | ramda.find ⇝ 174.40ms @ 17,201,824.60 op/s 396 | 397 | Array(500) 398 | native ⇝ 1,232.32ms @ 12,172,147.45 op/s 399 | @arr/find ⇝ 999.29ms @ 15,010,623.92 op/s 400 | lodash.find ⇝ 1,046.98ms @ 14,326,946.51 op/s 401 | ramda.find ⇝ 1,085.87ms @ 13,813,794.31 op/s 402 | 403 | Array(1000) 404 | native ⇝ 4,141.24ms @ 7,244,205.16 op/s 405 | @arr/find ⇝ 3,780.68ms @ 7,935,083.01 op/s 406 | lodash.find ⇝ 3,881.48ms @ 7,729,008.23 op/s 407 | ramda.find ⇝ 3,982.42ms @ 7,533,100.81 op/s 408 | 409 | Array(5000) 410 | native ⇝ 46,390.04ms @ 3,233,452.46 op/s 411 | @arr/find ⇝ 44,107.26ms @ 3,400,800.78 op/s 412 | lodash.find ⇝ 44,357.61ms @ 3,381,606.90 op/s 413 | ramda.find ⇝ 44,896.28ms @ 3,341,034.35 op/s 414 | 415 | Array(10000) 416 | native ⇝ 150,708.27ms @ 1,990,600.80 op/s 417 | @arr/find ⇝ 147,405.44ms @ 2,035,203.10 op/s 418 | lodash.find ⇝ 147,642.71ms @ 2,031,932.36 op/s 419 | ramda.find ⇝ 148,599.63ms @ 2,018,847.60 op/s 420 | ``` 421 | 422 | 423 | 424 | ## findIndex 425 | 426 |
427 | :white_check_mark: ↝ Strings 428 | 429 | ``` 430 | Array(100) 431 | native ⇝ 2.48ms @ 1,211,764,781.91 op/s 432 | @arr/findIndex ⇝ 1.06ms @ 2,826,314,495.32 op/s 433 | lodash.findindex ⇝ 1.84ms @ 1,632,321,711.02 op/s 434 | ramda.findIndex ⇝ 41.77ms @ 71,813,539.88 op/s 435 | 436 | Array(500) 437 | native ⇝ 1.33ms @ 11,266,040,024.48 op/s 438 | @arr/findIndex ⇝ 0.55ms @ 27,352,147,964.18 op/s 439 | lodash.findindex ⇝ 0.69ms @ 21,661,619,509.32 op/s 440 | ramda.findIndex ⇝ 36.91ms @ 406,431,777.46 op/s 441 | 442 | Array(1000) 443 | native ⇝ 1.31ms @ 22,878,356,540.88 op/s 444 | @arr/findIndex ⇝ 0.51ms @ 58,307,451,303.56 op/s 445 | lodash.findindex ⇝ 0.66ms @ 45,424,468,950.10 op/s 446 | ramda.findIndex ⇝ 32.29ms @ 929,061,738.69 op/s 447 | 448 | Array(5000) 449 | native ⇝ 1.39ms @ 107,785,412,178.60 op/s 450 | @arr/findIndex ⇝ 0.59ms @ 253,941,596,818.62 op/s 451 | lodash.findindex ⇝ 0.69ms @ 217,842,459,238.05 op/s 452 | ramda.findIndex ⇝ 33.98ms @ 4,414,254,345.33 op/s 453 | 454 | Array(10000) 455 | native ⇝ 1.44ms @ 208,659,073,331.14 op/s 456 | @arr/findIndex ⇝ 0.58ms @ 512,833,662,401.60 op/s 457 | lodash.findindex ⇝ 0.76ms @ 396,018,169,313.61 op/s 458 | ramda.findIndex ⇝ 31.95ms @ 9,390,905,846.78 op/s 459 | ``` 460 |
461 | 462 |
463 | :white_check_mark: ↝ Numbers 464 | 465 | ``` 466 | Array(100) 467 | native ⇝ 343.06ms @ 8,744,857.05 op/s 468 | @arr/findIndex ⇝ 301.25ms @ 9,958,444.94 op/s 469 | lodash.findindex ⇝ 287.99ms @ 10,417,112.36 op/s 470 | ramda.findIndex ⇝ 318.20ms @ 9,427,895.65 op/s 471 | 472 | Array(500) 473 | native ⇝ 1,626.82ms @ 9,220,456.26 op/s 474 | @arr/findIndex ⇝ 1,406.63ms @ 10,663,762.89 op/s 475 | lodash.findindex ⇝ 1,397.69ms @ 10,731,965.53 op/s 476 | ramda.findIndex ⇝ 1,492.11ms @ 10,052,909.80 op/s 477 | 478 | Array(1000) 479 | native ⇝ 3,257.34ms @ 9,209,971.20 op/s 480 | @arr/findIndex ⇝ 2,855.40ms @ 10,506,393.21 op/s 481 | lodash.findindex ⇝ 2,807.12ms @ 10,687,094.21 op/s 482 | ramda.findIndex ⇝ 2,847.85ms @ 10,534,253.45 op/s 483 | 484 | Array(5000) 485 | native ⇝ 16,258.23ms @ 9,226,094.22 op/s 486 | @arr/findIndex ⇝ 14,052.58ms @ 10,674,198.44 op/s 487 | lodash.findindex ⇝ 14,073.30ms @ 10,658,480.46 op/s 488 | ramda.findIndex ⇝ 14,080.21ms @ 10,653,253.29 op/s 489 | 490 | Array(10000) 491 | native ⇝ 32,426.24ms @ 9,251,767.60 op/s 492 | @arr/findIndex ⇝ 28,136.20ms @ 10,662,422.51 op/s 493 | lodash.findindex ⇝ 28,104.55ms @ 10,674,428.77 op/s 494 | ramda.findIndex ⇝ 28,118.35ms @ 10,669,188.66 op/s 495 | ``` 496 |
497 | 498 |
499 | :white_check_mark: ↝ Objects 500 | 501 | ``` 502 | Array(100) 503 | native ⇝ 188.84ms @ 15,886,277.47 op/s 504 | @arr/findIndex ⇝ 129.87ms @ 23,100,672.70 op/s 505 | lodash.findindex ⇝ 130.20ms @ 23,041,255.04 op/s 506 | ramda.findIndex ⇝ 173.78ms @ 17,262,956.72 op/s 507 | 508 | Array(500) 509 | native ⇝ 1,203.98ms @ 12,458,628.51 op/s 510 | @arr/findIndex ⇝ 1,011.32ms @ 14,832,085.38 op/s 511 | lodash.findindex ⇝ 1,015.98ms @ 14,764,092.51 op/s 512 | ramda.findIndex ⇝ 1,093.14ms @ 13,721,935.12 op/s 513 | 514 | Array(1000) 515 | native ⇝ 4,294.35ms @ 6,985,916.25 op/s 516 | @arr/findIndex ⇝ 3,953.35ms @ 7,588,499.93 op/s 517 | lodash.findindex ⇝ 3,895.20ms @ 7,701,780.01 op/s 518 | ramda.findIndex ⇝ 4,125.94ms @ 7,271,069.80 op/s 519 | 520 | Array(5000) 521 | native ⇝ 45,012.20ms @ 3,332,429.94 op/s 522 | @arr/findIndex ⇝ 43,856.45ms @ 3,420,249.38 op/s 523 | lodash.findindex ⇝ 43,433.11ms @ 3,453,586.38 op/s 524 | ramda.findIndex ⇝ 44,473.01ms @ 3,372,832.39 op/s 525 | 526 | Array(10000) 527 | native ⇝ 148,255.73ms @ 2,023,530.58 op/s 528 | @arr/findIndex ⇝ 145,271.82ms @ 2,065,094.18 op/s 529 | lodash.findindex ⇝ 144,900.21ms @ 2,070,390.31 op/s 530 | ramda.findIndex ⇝ 147,068.33ms @ 2,039,868.08 op/s 531 | ``` 532 | 533 | 534 | 535 | ## flatten 536 | 537 |
538 | :wavy_dash: ↝ Arrays 539 | 540 | ``` 541 | Array(5) 542 | @arr/flatten ⇝ 159.87ms @ 938,242.57 op/s 543 | arr-flatten ⇝ 158.31ms @ 947,504.44 op/s 544 | array-flatten ⇝ 127.82ms @ 1,173,551.45 op/s 545 | flatten ⇝ 4,316.50ms @ 34,750.37 op/s 546 | flatten-array ⇝ 132.68ms @ 1,130,510.39 op/s 547 | lodash.flattendeep ⇝ 769.63ms @ 194,898.97 op/s 548 | ramda.flatten ⇝ 442.93ms @ 338,654.08 op/s 549 | 550 | Array(10) 551 | @arr/flatten ⇝ 272.60ms @ 1,100,529.58 op/s 552 | arr-flatten ⇝ 228.63ms @ 1,312,137.72 op/s 553 | array-flatten ⇝ 218.34ms @ 1,374,028.11 op/s 554 | flatten ⇝ 7,610.36ms @ 39,419.92 op/s 555 | flatten-array ⇝ 233.04ms @ 1,287,307.62 op/s 556 | lodash.flattendeep ⇝ 1,364.42ms @ 219,872.93 op/s 557 | ramda.flatten ⇝ 772.48ms @ 388,361.37 op/s 558 | 559 | Array(100) 560 | @arr/flatten ⇝ 2,278.78ms @ 1,316,494.57 op/s 561 | arr-flatten ⇝ 2,213.52ms @ 1,355,306.62 op/s 562 | array-flatten ⇝ 2,191.77ms @ 1,368,755.16 op/s 563 | flatten ⇝ 89,584.53ms @ 33,487.92 op/s 564 | flatten-array ⇝ 2,324.15ms @ 1,290,792.47 op/s 565 | lodash.flattendeep ⇝ 12,966.90ms @ 231,358.22 op/s 566 | ramda.flatten ⇝ 7,478.40ms @ 401,155.48 op/s 567 | 568 | Array(500) 569 | @arr/flatten ⇝ 11,684.47ms @ 1,283,755.06 op/s 570 | arr-flatten ⇝ 11,599.19ms @ 1,293,194.27 op/s 571 | array-flatten ⇝ 11,572.31ms @ 1,296,198.09 op/s 572 | flatten ⇝ 1,003,580.80ms @ 14,946.48 op/s 573 | flatten-array ⇝ 16,160.71ms @ 928,177.14 op/s 574 | lodash.flattendeep ⇝ 71,211.86ms @ 210,639.06 op/s 575 | ramda.flatten ⇝ 53,101.65ms @ 282,477.10 op/s 576 | ``` 577 |
578 | 579 | 580 | ## forEach 581 | 582 |
583 | :white_check_mark: ↝ Strings 584 | 585 | ``` 586 | Array(100) 587 | native ⇝ 61.93ms @ 48,440,482.87 op/s 588 | @arr/forEach ⇝ 5.98ms @ 501,535,199.24 op/s 589 | @arr/forEach.spec ⇝ 110.94ms @ 27,042,153.82 op/s 590 | fastjs.forEach ⇝ 8.87ms @ 338,396,038.87 op/s 591 | lodash.foreach ⇝ 9.73ms @ 308,347,902.77 op/s 592 | ramda.forEach ⇝ 9.62ms @ 311,808,337.65 op/s 593 | 594 | Array(500) 595 | native ⇝ 280.01ms @ 53,570,064.26 op/s 596 | @arr/forEach ⇝ 23.08ms @ 649,930,522.43 op/s 597 | @arr/forEach.spec ⇝ 473.28ms @ 31,693,953.98 op/s 598 | fastjs.forEach ⇝ 23.32ms @ 643,313,224.36 op/s 599 | lodash.foreach ⇝ 32.47ms @ 462,013,852.47 op/s 600 | ramda.forEach ⇝ 26.62ms @ 563,473,103.96 op/s 601 | 602 | Array(1000) 603 | native ⇝ 560.42ms @ 53,530,916.28 op/s 604 | @arr/forEach ⇝ 45.33ms @ 661,863,888.13 op/s 605 | @arr/forEach.spec ⇝ 935.37ms @ 32,073,023.00 op/s 606 | fastjs.forEach ⇝ 45.37ms @ 661,285,842.55 op/s 607 | lodash.foreach ⇝ 63.17ms @ 474,924,064.79 op/s 608 | ramda.forEach ⇝ 48.36ms @ 620,316,776.34 op/s 609 | 610 | Array(5000) 611 | native ⇝ 2,783.48ms @ 53,889,402.51 op/s 612 | @arr/forEach ⇝ 227.88ms @ 658,248,120.81 op/s 613 | @arr/forEach.spec ⇝ 4,620.83ms @ 32,461,715.80 op/s 614 | fastjs.forEach ⇝ 225.78ms @ 664,354,117.89 op/s 615 | lodash.foreach ⇝ 316.87ms @ 473,374,141.99 op/s 616 | ramda.forEach ⇝ 226.97ms @ 660,871,161.42 op/s 617 | 618 | Array(10000) 619 | native ⇝ 5,462.68ms @ 54,918,120.48 op/s 620 | @arr/forEach ⇝ 445.87ms @ 672,840,519.70 op/s 621 | @arr/forEach.spec ⇝ 9,281.61ms @ 32,321,972.56 op/s 622 | fastjs.forEach ⇝ 449.83ms @ 666,922,100.80 op/s 623 | lodash.foreach ⇝ 622.71ms @ 481,763,080.21 op/s 624 | ramda.forEach ⇝ 448.54ms @ 668,841,989.03 op/s 625 | ``` 626 |
627 | 628 |
629 | :white_check_mark: ↝ Numbers 630 | 631 | ``` 632 | Array(100) 633 | native ⇝ 65.71ms @ 45,652,785.06 op/s 634 | @arr/forEach ⇝ 5.36ms @ 559,224,065.42 op/s 635 | @arr/forEach.spec ⇝ 99.86ms @ 30,041,670.20 op/s 636 | fastjs.forEach ⇝ 5.62ms @ 533,982,276.06 op/s 637 | lodash.foreach ⇝ 7.22ms @ 415,495,028.39 op/s 638 | ramda.forEach ⇝ 8.01ms @ 374,689,195.31 op/s 639 | 640 | Array(500) 641 | native ⇝ 281.20ms @ 53,342,954.60 op/s 642 | @arr/forEach ⇝ 22.99ms @ 652,598,130.20 op/s 643 | @arr/forEach.spec ⇝ 468.89ms @ 31,990,404.18 op/s 644 | fastjs.forEach ⇝ 23.18ms @ 647,060,754.56 op/s 645 | lodash.foreach ⇝ 32.02ms @ 468,493,777.82 op/s 646 | ramda.forEach ⇝ 26.39ms @ 568,446,016.39 op/s 647 | 648 | Array(1000) 649 | native ⇝ 549.22ms @ 54,622,720.57 op/s 650 | @arr/forEach ⇝ 49.19ms @ 609,897,068.08 op/s 651 | @arr/forEach.spec ⇝ 938.14ms @ 31,978,114.52 op/s 652 | fastjs.forEach ⇝ 45.66ms @ 657,025,992.87 op/s 653 | lodash.foreach ⇝ 63.11ms @ 475,382,273.51 op/s 654 | ramda.forEach ⇝ 49.02ms @ 611,953,533.14 op/s 655 | 656 | Array(5000) 657 | native ⇝ 2,721.28ms @ 55,121,072.87 op/s 658 | @arr/forEach ⇝ 227.48ms @ 659,392,851.37 op/s 659 | @arr/forEach.spec ⇝ 4,651.54ms @ 32,247,413.50 op/s 660 | fastjs.forEach ⇝ 222.91ms @ 672,924,490.58 op/s 661 | lodash.foreach ⇝ 313.20ms @ 478,920,462.70 op/s 662 | ramda.forEach ⇝ 226.43ms @ 662,446,341.74 op/s 663 | 664 | Array(10000) 665 | native ⇝ 5,441.35ms @ 55,133,365.13 op/s 666 | @arr/forEach ⇝ 450.04ms @ 666,613,786.42 op/s 667 | @arr/forEach.spec ⇝ 9,299.29ms @ 32,260,522.65 op/s 668 | fastjs.forEach ⇝ 454.29ms @ 660,375,474.97 op/s 669 | lodash.foreach ⇝ 623.84ms @ 480,890,092.17 op/s 670 | ramda.forEach ⇝ 450.82ms @ 665,452,489.45 op/s 671 | ``` 672 |
673 | 674 |
675 | :white_check_mark: ↝ Objects 676 | 677 | ``` 678 | Array(100) 679 | native ⇝ 56.24ms @ 53,342,327.09 op/s 680 | @arr/forEach ⇝ 5.33ms @ 562,782,833.55 op/s 681 | @arr/forEach.spec ⇝ 105.68ms @ 28,386,275.71 op/s 682 | fastjs.forEach ⇝ 5.20ms @ 577,186,695.85 op/s 683 | lodash.foreach ⇝ 7.21ms @ 415,840,472.51 op/s 684 | ramda.forEach ⇝ 8.05ms @ 372,495,480.08 op/s 685 | 686 | Array(500) 687 | native ⇝ 285.01ms @ 52,629,144.16 op/s 688 | @arr/forEach ⇝ 23.05ms @ 650,650,485.65 op/s 689 | @arr/forEach.spec ⇝ 468.82ms @ 31,994,979.57 op/s 690 | fastjs.forEach ⇝ 23.14ms @ 648,122,471.30 op/s 691 | lodash.foreach ⇝ 32.28ms @ 464,736,952.84 op/s 692 | ramda.forEach ⇝ 25.95ms @ 577,999,801.63 op/s 693 | 694 | Array(1000) 695 | native ⇝ 555.98ms @ 53,959,163.51 op/s 696 | @arr/forEach ⇝ 45.07ms @ 665,694,648.93 op/s 697 | @arr/forEach.spec ⇝ 937.75ms @ 31,991,303.79 op/s 698 | fastjs.forEach ⇝ 45.27ms @ 662,698,940.84 op/s 699 | lodash.foreach ⇝ 63.38ms @ 473,344,436.42 op/s 700 | ramda.forEach ⇝ 48.15ms @ 622,997,931.25 op/s 701 | 702 | Array(5000) 703 | native ⇝ 2,736.81ms @ 54,808,362.11 op/s 704 | @arr/forEach ⇝ 223.43ms @ 671,336,558.36 op/s 705 | @arr/forEach.spec ⇝ 4,640.48ms @ 32,324,210.68 op/s 706 | fastjs.forEach ⇝ 223.63ms @ 670,740,350.05 op/s 707 | lodash.foreach ⇝ 311.93ms @ 480,872,750.96 op/s 708 | ramda.forEach ⇝ 226.68ms @ 661,716,991.22 op/s 709 | 710 | Array(10000) 711 | native ⇝ 5,431.92ms @ 55,229,131.55 op/s 712 | @arr/forEach ⇝ 451.00ms @ 665,191,077.73 op/s 713 | @arr/forEach.spec ⇝ 9,281.87ms @ 32,321,067.34 op/s 714 | fastjs.forEach ⇝ 453.40ms @ 661,672,173.95 op/s 715 | lodash.foreach ⇝ 630.41ms @ 475,880,486.13 op/s 716 | ramda.forEach ⇝ 454.50ms @ 660,065,084.40 op/s 717 | ``` 718 | 719 | 720 | 721 | ## includes 722 | 723 |
724 | :no_entry_sign: ↝ Strings (`true`) 725 | 726 | ``` 727 | Array(100) 728 | native ⇝ 10.23ms @ 293,166,236.40 op/s 729 | @arr/includes ⇝ 17.95ms @ 167,141,487.78 op/s 730 | 731 | Array(500) 732 | native ⇝ 48.11ms @ 311,791,648.35 op/s 733 | @arr/includes ⇝ 63.54ms @ 236,073,437.73 op/s 734 | 735 | Array(1000) 736 | native ⇝ 166.76ms @ 179,902,869.36 op/s 737 | @arr/includes ⇝ 195.24ms @ 153,658,229.04 op/s 738 | 739 | Array(5000) 740 | native ⇝ 984.52ms @ 152,358,611.09 op/s 741 | @arr/includes ⇝ 1,119.56ms @ 133,981,199.84 op/s 742 | 743 | Array(10000) 744 | native ⇝ 1,832.39ms @ 163,720,177.35 op/s 745 | @arr/includes ⇝ 2,099.99ms @ 142,857,771.91 op/s 746 | ``` 747 |
748 | 749 |
750 | :no_entry_sign: ↝ Strings (`false`) 751 | 752 | ``` 753 | Array(100) 754 | native ⇝ 11.90ms @ 252,194,088.57 op/s 755 | @arr/includes ⇝ 15.67ms @ 191,439,269.78 op/s 756 | 757 | Array(500) 758 | native ⇝ 52.12ms @ 287,774,554.19 op/s 759 | @arr/includes ⇝ 69.47ms @ 215,931,734.13 op/s 760 | 761 | Array(1000) 762 | native ⇝ 101.71ms @ 294,960,299.47 op/s 763 | @arr/includes ⇝ 134.52ms @ 223,014,583.12 op/s 764 | 765 | Array(5000) 766 | native ⇝ 514.43ms @ 291,582,700.24 op/s 767 | @arr/includes ⇝ 677.83ms @ 221,295,017.41 op/s 768 | 769 | Array(10000) 770 | native ⇝ 1,009.06ms @ 297,306,648.53 op/s 771 | @arr/includes ⇝ 1,345.66ms @ 222,939,162.20 op/s 772 | ``` 773 |
774 | 775 |
776 | :mag: ↝ Numbers (`true`) 777 | 778 | ``` 779 | Array(100) 780 | native ⇝ 6.07ms @ 494,352,516.85 op/s 781 | @arr/includes ⇝ 6.05ms @ 495,937,199.80 op/s 782 | 783 | Array(500) 784 | native ⇝ 22.85ms @ 656,371,063.54 op/s 785 | @arr/includes ⇝ 22.09ms @ 678,929,952.08 op/s 786 | 787 | Array(1000) 788 | native ⇝ 45.09ms @ 665,283,188.10 op/s 789 | @arr/includes ⇝ 43.54ms @ 688,995,463.22 op/s 790 | 791 | Array(5000) 792 | native ⇝ 222.87ms @ 673,026,038.86 op/s 793 | @arr/includes ⇝ 214.54ms @ 699,180,857.42 op/s 794 | 795 | Array(10000) 796 | native ⇝ 453.39ms @ 661,675,639.96 op/s 797 | @arr/includes ⇝ 437.49ms @ 685,735,622.67 op/s 798 | ``` 799 |
800 | 801 |
802 | :no_entry_sign: ↝ Numbers (`false`) 803 | 804 | ``` 805 | Array(100) 806 | native ⇝ 6.88ms @ 435,838,601.41 op/s 807 | @arr/includes ⇝ 18.43ms @ 162,795,339.23 op/s 808 | 809 | Array(500) 810 | native ⇝ 31.44ms @ 477,046,342.76 op/s 811 | @arr/includes ⇝ 85.16ms @ 176,138,240.24 op/s 812 | 813 | Array(1000) 814 | native ⇝ 57.66ms @ 520,319,617.08 op/s 815 | @arr/includes ⇝ 169.84ms @ 176,633,160.36 op/s 816 | 817 | Array(5000) 818 | native ⇝ 275.56ms @ 544,342,742.23 op/s 819 | @arr/includes ⇝ 863.61ms @ 173,688,826.81 op/s 820 | 821 | Array(10000) 822 | native ⇝ 571.23ms @ 525,180,270.49 op/s 823 | @arr/includes ⇝ 1,708.78ms @ 175,563,381.19 op/s 824 | ``` 825 |
826 | 827 | 828 | ## map 829 | 830 |
831 | :white_check_mark: ↝ Strings 832 | 833 | ``` 834 | Array(100) 835 | native ⇝ 329.10ms @ 9,115,759.62 op/s 836 | @arr/map ⇝ 12.21ms @ 245,740,638.94 op/s 837 | @arr/map.spec ⇝ 486.00ms @ 6,172,833.22 op/s 838 | arr-map ⇝ 14.33ms @ 209,328,150.83 op/s 839 | array-map ⇝ 321.75ms @ 9,323,934.18 op/s 840 | fastjs.map ⇝ 12.63ms @ 237,522,206.35 op/s 841 | lodash.map ⇝ 13.06ms @ 229,727,047.51 op/s 842 | ramda.map ⇝ 47.51ms @ 63,146,016.64 op/s 843 | 844 | Array(500) 845 | native ⇝ 1,645.68ms @ 9,114,777.52 op/s 846 | @arr/map ⇝ 52.99ms @ 283,094,587.71 op/s 847 | @arr/map.spec ⇝ 2,250.29ms @ 6,665,820.80 op/s 848 | arr-map ⇝ 54.32ms @ 276,143,809.29 op/s 849 | array-map ⇝ 1,632.97ms @ 9,185,734.56 op/s 850 | fastjs.map ⇝ 54.11ms @ 277,204,360.03 op/s 851 | lodash.map ⇝ 58.97ms @ 254,384,632.89 op/s 852 | ramda.map ⇝ 166.88ms @ 89,883,110.61 op/s 853 | 854 | Array(1000) 855 | native ⇝ 3,254.22ms @ 9,218,799.99 op/s 856 | @arr/map ⇝ 104.96ms @ 285,816,463.74 op/s 857 | @arr/map.spec ⇝ 4,409.21ms @ 6,803,946.74 op/s 858 | arr-map ⇝ 106.35ms @ 282,088,998.80 op/s 859 | array-map ⇝ 3,248.89ms @ 9,233,934.81 op/s 860 | fastjs.map ⇝ 103.75ms @ 289,167,688.74 op/s 861 | lodash.map ⇝ 111.77ms @ 268,417,615.61 op/s 862 | ramda.map ⇝ 321.30ms @ 93,370,040.83 op/s 863 | 864 | Array(5000) 865 | native ⇝ 16,295.78ms @ 9,204,837.71 op/s 866 | @arr/map ⇝ 512.21ms @ 292,849,823.23 op/s 867 | @arr/map.spec ⇝ 21,942.57ms @ 6,836,028.25 op/s 868 | arr-map ⇝ 518.79ms @ 289,135,006.17 op/s 869 | array-map ⇝ 16,307.62ms @ 9,198,155.21 op/s 870 | fastjs.map ⇝ 516.52ms @ 290,402,580.37 op/s 871 | lodash.map ⇝ 556.48ms @ 269,553,767.70 op/s 872 | ramda.map ⇝ 1,513.40ms @ 99,114,679.47 op/s 873 | 874 | Array(10000) 875 | native ⇝ 32,583.24ms @ 9,207,187.07 op/s 876 | @arr/map ⇝ 1,022.29ms @ 293,457,555.72 op/s 877 | @arr/map.spec ⇝ 43,796.35ms @ 6,849,886.65 op/s 878 | arr-map ⇝ 1,022.59ms @ 293,372,249.44 op/s 879 | array-map ⇝ 32,552.30ms @ 9,215,939.84 op/s 880 | fastjs.map ⇝ 1,024.63ms @ 292,788,862.41 op/s 881 | lodash.map ⇝ 1,112.77ms @ 269,597,701.73 op/s 882 | ramda.map ⇝ 3,022.78ms @ 99,246,311.30 op/s 883 | ``` 884 |
885 | 886 |
887 | :white_check_mark: ↝ Numbers 888 | 889 | ``` 890 | Array(100) 891 | native ⇝ 326.54ms @ 9,187,303.05 op/s 892 | @arr/map ⇝ 9.45ms @ 317,330,698.78 op/s 893 | @arr/map.spec ⇝ 472.39ms @ 6,350,719.80 op/s 894 | arr-map ⇝ 11.08ms @ 270,875,909.76 op/s 895 | array-map ⇝ 322.11ms @ 9,313,668.68 op/s 896 | fastjs.map ⇝ 9.59ms @ 312,687,221.47 op/s 897 | lodash.map ⇝ 10.97ms @ 273,408,681.73 op/s 898 | ramda.map ⇝ 44.80ms @ 66,963,862.71 op/s 899 | 900 | Array(500) 901 | native ⇝ 1,625.32ms @ 9,228,967.72 op/s 902 | @arr/map ⇝ 48.41ms @ 309,838,135.39 op/s 903 | @arr/map.spec ⇝ 2,198.05ms @ 6,824,244.60 op/s 904 | arr-map ⇝ 50.37ms @ 297,775,007.28 op/s 905 | array-map ⇝ 1,613.93ms @ 9,294,105.36 op/s 906 | fastjs.map ⇝ 48.41ms @ 309,830,404.41 op/s 907 | lodash.map ⇝ 52.48ms @ 285,809,615.47 op/s 908 | ramda.map ⇝ 162.59ms @ 92,258,504.61 op/s 909 | 910 | Array(1000) 911 | native ⇝ 3,206.77ms @ 9,355,201.83 op/s 912 | @arr/map ⇝ 94.28ms @ 318,214,759.20 op/s 913 | @arr/map.spec ⇝ 4,362.99ms @ 6,876,021.81 op/s 914 | arr-map ⇝ 96.29ms @ 311,559,114.19 op/s 915 | array-map ⇝ 3,203.83ms @ 9,363,787.27 op/s 916 | fastjs.map ⇝ 94.31ms @ 318,093,859.45 op/s 917 | lodash.map ⇝ 103.35ms @ 290,274,489.65 op/s 918 | ramda.map ⇝ 307.16ms @ 97,669,166.68 op/s 919 | 920 | Array(5000) 921 | native ⇝ 16,194.43ms @ 9,262,444.24 op/s 922 | @arr/map ⇝ 468.88ms @ 319,912,132.85 op/s 923 | @arr/map.spec ⇝ 21,614.64ms @ 6,939,740.06 op/s 924 | arr-map ⇝ 469.89ms @ 319,220,805.68 op/s 925 | array-map ⇝ 16,046.00ms @ 9,348,124.06 op/s 926 | fastjs.map ⇝ 468.99ms @ 319,835,879.67 op/s 927 | lodash.map ⇝ 512.37ms @ 292,755,493.63 op/s 928 | ramda.map ⇝ 1,472.49ms @ 101,868,476.49 op/s 929 | 930 | Array(10000) 931 | native ⇝ 32,349.41ms @ 9,273,739.52 op/s 932 | @arr/map ⇝ 936.24ms @ 320,431,256.38 op/s 933 | @arr/map.spec ⇝ 43,238.52ms @ 6,938,258.02 op/s 934 | arr-map ⇝ 932.13ms @ 321,842,138.23 op/s 935 | array-map ⇝ 32,260.26ms @ 9,299,367.55 op/s 936 | fastjs.map ⇝ 941.10ms @ 318,776,735.84 op/s 937 | lodash.map ⇝ 1,031.09ms @ 290,954,936.38 op/s 938 | ramda.map ⇝ 2,917.02ms @ 102,844,575.12 op/s 939 | ``` 940 |
941 | 942 |
943 | :white_check_mark: ↝ Objects 944 | 945 | ``` 946 | Array(100) 947 | native ⇝ 333.77ms @ 8,988,292.83 op/s 948 | @arr/map ⇝ 11.03ms @ 272,108,275.87 op/s 949 | @arr/map.spec ⇝ 479.68ms @ 6,254,173.04 op/s 950 | arr-map ⇝ 13.34ms @ 224,946,372.78 op/s 951 | array-map ⇝ 332.72ms @ 9,016,492.37 op/s 952 | fastjs.map ⇝ 11.13ms @ 269,577,722.67 op/s 953 | lodash.map ⇝ 11.39ms @ 263,498,709.52 op/s 954 | ramda.map ⇝ 45.78ms @ 65,531,903.13 op/s 955 | 956 | Array(500) 957 | native ⇝ 1,628.00ms @ 9,213,771.73 op/s 958 | @arr/map ⇝ 52.58ms @ 285,300,730.08 op/s 959 | @arr/map.spec ⇝ 2,227.37ms @ 6,734,395.12 op/s 960 | arr-map ⇝ 54.53ms @ 275,101,362.47 op/s 961 | array-map ⇝ 1,629.01ms @ 9,208,053.87 op/s 962 | fastjs.map ⇝ 52.25ms @ 287,083,229.79 op/s 963 | lodash.map ⇝ 56.73ms @ 264,397,520.19 op/s 964 | ramda.map ⇝ 166.12ms @ 90,296,060.56 op/s 965 | 966 | Array(1000) 967 | native ⇝ 3,273.46ms @ 9,164,613.80 op/s 968 | @arr/map ⇝ 103.76ms @ 289,115,528.91 op/s 969 | @arr/map.spec ⇝ 4,448.58ms @ 6,743,720.03 op/s 970 | arr-map ⇝ 105.39ms @ 284,661,809.67 op/s 971 | array-map ⇝ 3,272.14ms @ 9,168,322.76 op/s 972 | fastjs.map ⇝ 102.92ms @ 291,482,802.55 op/s 973 | lodash.map ⇝ 112.65ms @ 266,314,192.14 op/s 974 | ramda.map ⇝ 319.37ms @ 93,936,135.33 op/s 975 | 976 | Array(5000) 977 | native ⇝ 17,254.61ms @ 8,693,329.02 op/s 978 | @arr/map ⇝ 544.31ms @ 275,577,372.07 op/s 979 | @arr/map.spec ⇝ 22,588.48ms @ 6,640,553.00 op/s 980 | arr-map ⇝ 549.93ms @ 272,762,470.49 op/s 981 | array-map ⇝ 17,224.98ms @ 8,708,283.14 op/s 982 | fastjs.map ⇝ 545.00ms @ 275,229,108.32 op/s 983 | lodash.map ⇝ 595.23ms @ 252,001,799.82 op/s 984 | ramda.map ⇝ 1,566.92ms @ 95,728,954.36 op/s 985 | 986 | Array(10000) 987 | native ⇝ 34,365.57ms @ 8,729,668.00 op/s 988 | @arr/map ⇝ 1,093.38ms @ 274,378,517.07 op/s 989 | @arr/map.spec ⇝ 44,985.69ms @ 6,668,787.79 op/s 990 | arr-map ⇝ 1,098.47ms @ 273,107,778.65 op/s 991 | array-map ⇝ 34,300.57ms @ 8,746,211.05 op/s 992 | fastjs.map ⇝ 1,084.82ms @ 276,542,508.23 op/s 993 | lodash.map ⇝ 1,177.47ms @ 254,783,692.49 op/s 994 | ramda.map ⇝ 3,075.81ms @ 97,535,364.79 op/s 995 | ``` 996 | 997 | 998 | 999 | ## reduce 1000 | 1001 |
1002 | :white_check_mark: ↝ Strings 1003 | 1004 | ``` 1005 | Array(100) 1006 | native ⇝ 57.22ms @ 52,430,001.23 op/s 1007 | @arr/reduce ⇝ 6.07ms @ 494,578,512.77 op/s 1008 | arr-reduce ⇝ 7.26ms @ 412,940,111.57 op/s 1009 | fastjs.reduce ⇝ 6.64ms @ 451,562,337.95 op/s 1010 | lodash.reduce ⇝ 7.83ms @ 383,234,022.49 op/s 1011 | ramda.reduce ⇝ 200.92ms @ 14,931,587.87 op/s 1012 | 1013 | Array(500) 1014 | native ⇝ 276.39ms @ 54,270,652.43 op/s 1015 | @arr/reduce ⇝ 23.11ms @ 648,940,412.26 op/s 1016 | arr-reduce ⇝ 27.45ms @ 546,350,819.07 op/s 1017 | fastjs.reduce ⇝ 24.43ms @ 614,015,342.28 op/s 1018 | lodash.reduce ⇝ 35.79ms @ 419,081,484.02 op/s 1019 | ramda.reduce ⇝ 956.00ms @ 15,690,443.84 op/s 1020 | 1021 | Array(1000) 1022 | native ⇝ 531.18ms @ 56,477,795.60 op/s 1023 | @arr/reduce ⇝ 45.42ms @ 660,556,431.60 op/s 1024 | arr-reduce ⇝ 54.00ms @ 555,585,886.43 op/s 1025 | fastjs.reduce ⇝ 49.52ms @ 605,788,270.58 op/s 1026 | lodash.reduce ⇝ 54.98ms @ 545,634,227.77 op/s 1027 | ramda.reduce ⇝ 1,922.96ms @ 15,600,917.43 op/s 1028 | 1029 | Array(5000) 1030 | native ⇝ 2,661.88ms @ 56,351,076.31 op/s 1031 | @arr/reduce ⇝ 228.16ms @ 657,424,525.48 op/s 1032 | arr-reduce ⇝ 268.59ms @ 558,469,920.49 op/s 1033 | fastjs.reduce ⇝ 227.99ms @ 657,912,382.17 op/s 1034 | lodash.reduce ⇝ 272.36ms @ 550,743,764.40 op/s 1035 | ramda.reduce ⇝ 9,582.54ms @ 15,653,467.15 op/s 1036 | 1037 | Array(10000) 1038 | native ⇝ 5,290.38ms @ 56,706,678.63 op/s 1039 | @arr/reduce ⇝ 455.88ms @ 658,065,966.76 op/s 1040 | arr-reduce ⇝ 536.73ms @ 558,937,656.26 op/s 1041 | fastjs.reduce ⇝ 450.56ms @ 665,844,851.36 op/s 1042 | lodash.reduce ⇝ 534.37ms @ 561,408,303.66 op/s 1043 | ramda.reduce ⇝ 19,155.89ms @ 15,660,979.51 op/s 1044 | ``` 1045 |
1046 | 1047 |
1048 | :white_check_mark: ↝ Numbers 1049 | 1050 | ``` 1051 | Array(100) 1052 | native ⇝ 58.27ms @ 51,485,160.68 op/s 1053 | @arr/reduce ⇝ 5.42ms @ 553,633,115.82 op/s 1054 | arr-reduce ⇝ 6.14ms @ 488,325,838.35 op/s 1055 | fastjs.reduce ⇝ 5.70ms @ 526,303,047.40 op/s 1056 | lodash.reduce ⇝ 6.74ms @ 445,220,645.42 op/s 1057 | ramda.reduce ⇝ 199.29ms @ 15,053,558.15 op/s 1058 | 1059 | Array(500) 1060 | native ⇝ 272.89ms @ 54,967,557.82 op/s 1061 | @arr/reduce ⇝ 23.13ms @ 648,570,792.11 op/s 1062 | arr-reduce ⇝ 27.51ms @ 545,228,919.81 op/s 1063 | fastjs.reduce ⇝ 23.15ms @ 647,930,671.42 op/s 1064 | lodash.reduce ⇝ 30.73ms @ 488,119,862.19 op/s 1065 | ramda.reduce ⇝ 958.86ms @ 15,643,638.27 op/s 1066 | 1067 | Array(1000) 1068 | native ⇝ 531.16ms @ 56,480,414.82 op/s 1069 | @arr/reduce ⇝ 45.63ms @ 657,414,953.68 op/s 1070 | arr-reduce ⇝ 54.91ms @ 546,350,112.63 op/s 1071 | fastjs.reduce ⇝ 45.32ms @ 661,903,287.02 op/s 1072 | lodash.reduce ⇝ 57.04ms @ 525,912,718.89 op/s 1073 | ramda.reduce ⇝ 1,913.86ms @ 15,675,157.33 op/s 1074 | 1075 | Array(5000) 1076 | native ⇝ 2,631.48ms @ 57,002,113.30 op/s 1077 | @arr/reduce ⇝ 230.72ms @ 650,126,125.99 op/s 1078 | arr-reduce ⇝ 268.24ms @ 559,196,435.91 op/s 1079 | fastjs.reduce ⇝ 231.29ms @ 648,547,968.76 op/s 1080 | lodash.reduce ⇝ 273.61ms @ 548,219,437.36 op/s 1081 | ramda.reduce ⇝ 9,561.54ms @ 15,687,853.65 op/s 1082 | 1083 | Array(10000) 1084 | native ⇝ 5,275.75ms @ 56,863,972.81 op/s 1085 | @arr/reduce ⇝ 449.62ms @ 667,228,430.01 op/s 1086 | arr-reduce ⇝ 538.46ms @ 557,145,166.03 op/s 1087 | fastjs.reduce ⇝ 457.19ms @ 656,188,230.13 op/s 1088 | lodash.reduce ⇝ 543.41ms @ 552,073,396.57 op/s 1089 | ramda.reduce ⇝ 19,121.49ms @ 15,689,155.20 op/s 1090 | ``` 1091 |
1092 | 1093 |
1094 | :white_check_mark: ↝ Objects 1095 | 1096 | ``` 1097 | Array(100) 1098 | native ⇝ 60.37ms @ 49,694,070.05 op/s 1099 | @arr/reduce ⇝ 5.35ms @ 560,314,388.67 op/s 1100 | arr-reduce ⇝ 6.10ms @ 491,605,508.21 op/s 1101 | fastjs.reduce ⇝ 5.37ms @ 558,485,744.09 op/s 1102 | lodash.reduce ⇝ 9.37ms @ 320,010,752.36 op/s 1103 | ramda.reduce ⇝ 199.40ms @ 15,045,325.93 op/s 1104 | 1105 | Array(500) 1106 | native ⇝ 271.73ms @ 55,202,198.31 op/s 1107 | @arr/reduce ⇝ 23.12ms @ 648,732,415.78 op/s 1108 | arr-reduce ⇝ 27.45ms @ 546,493,937.18 op/s 1109 | fastjs.reduce ⇝ 24.20ms @ 619,863,552.33 op/s 1110 | lodash.reduce ⇝ 29.05ms @ 516,300,039.71 op/s 1111 | ramda.reduce ⇝ 966.84ms @ 15,514,498.45 op/s 1112 | 1113 | Array(1000) 1114 | native ⇝ 534.25ms @ 56,152,989.25 op/s 1115 | @arr/reduce ⇝ 45.32ms @ 661,991,520.73 op/s 1116 | arr-reduce ⇝ 54.14ms @ 554,169,485.31 op/s 1117 | fastjs.reduce ⇝ 45.62ms @ 657,579,214.18 op/s 1118 | lodash.reduce ⇝ 55.86ms @ 537,082,234.16 op/s 1119 | ramda.reduce ⇝ 1,910.29ms @ 15,704,433.33 op/s 1120 | 1121 | Array(5000) 1122 | native ⇝ 2,644.12ms @ 56,729,726.42 op/s 1123 | @arr/reduce ⇝ 223.12ms @ 672,271,583.09 op/s 1124 | arr-reduce ⇝ 268.39ms @ 558,881,215.49 op/s 1125 | fastjs.reduce ⇝ 224.21ms @ 669,029,139.39 op/s 1126 | lodash.reduce ⇝ 269.27ms @ 557,071,623.92 op/s 1127 | ramda.reduce ⇝ 9,652.43ms @ 15,540,134.01 op/s 1128 | 1129 | Array(10000) 1130 | native ⇝ 5,265.70ms @ 56,972,510.77 op/s 1131 | @arr/reduce ⇝ 465.58ms @ 644,358,291.02 op/s 1132 | arr-reduce ⇝ 534.85ms @ 560,899,794.25 op/s 1133 | fastjs.reduce ⇝ 445.63ms @ 673,206,949.98 op/s 1134 | lodash.reduce ⇝ 537.26ms @ 558,391,923.88 op/s 1135 | ramda.reduce ⇝ 19,220.20ms @ 15,608,580.87 op/s 1136 | ``` 1137 | 1138 | 1139 | 1140 | ## reduceRight 1141 | 1142 |
1143 | :white_check_mark: ↝ Strings 1144 | 1145 | ``` 1146 | Array(100) 1147 | native ⇝ 29.69ms @ 101,028,095.58 op/s 1148 | @arr/reduceRight ⇝ 7.01ms @ 427,860,263.69 op/s 1149 | fastjs.reduceRight ⇝ 9.32ms @ 321,715,990.20 op/s 1150 | lodash.reduceright ⇝ 8.96ms @ 334,804,015.77 op/s 1151 | ramda.reduceRight ⇝ 8.19ms @ 366,153,010.95 op/s 1152 | 1153 | Array(500) 1154 | native ⇝ 139.54ms @ 107,499,555.26 op/s 1155 | @arr/reduceRight ⇝ 28.22ms @ 531,629,020.48 op/s 1156 | fastjs.reduceRight ⇝ 23.87ms @ 628,355,312.64 op/s 1157 | lodash.reduceright ⇝ 30.92ms @ 485,171,524.79 op/s 1158 | ramda.reduceRight ⇝ 23.96ms @ 626,088,376.38 op/s 1159 | 1160 | Array(1000) 1161 | native ⇝ 269.29ms @ 111,405,152.22 op/s 1162 | @arr/reduceRight ⇝ 53.94ms @ 556,150,925.42 op/s 1163 | fastjs.reduceRight ⇝ 45.29ms @ 662,332,290.56 op/s 1164 | lodash.reduceright ⇝ 54.97ms @ 545,780,008.96 op/s 1165 | ramda.reduceRight ⇝ 51.63ms @ 581,085,492.88 op/s 1166 | 1167 | Array(5000) 1168 | native ⇝ 1,349.14ms @ 111,181,935.98 op/s 1169 | @arr/reduceRight ⇝ 267.24ms @ 561,296,220.97 op/s 1170 | fastjs.reduceRight ⇝ 223.79ms @ 670,256,366.13 op/s 1171 | lodash.reduceright ⇝ 268.29ms @ 559,097,562.86 op/s 1172 | ramda.reduceRight ⇝ 224.42ms @ 668,378,181.19 op/s 1173 | 1174 | Array(10000) 1175 | native ⇝ 2,876.62ms @ 104,289,043.52 op/s 1176 | @arr/reduceRight ⇝ 564.36ms @ 531,571,283.68 op/s 1177 | fastjs.reduceRight ⇝ 477.84ms @ 627,830,403.34 op/s 1178 | lodash.reduceright ⇝ 562.81ms @ 533,038,243.36 op/s 1179 | ramda.reduceRight ⇝ 465.28ms @ 644,768,135.67 op/s 1180 | ``` 1181 |
1182 | 1183 |
1184 | :white_check_mark: ↝ Numbers 1185 | 1186 | ``` 1187 | Array(100) 1188 | native ⇝ 34.95ms @ 85,827,899.78 op/s 1189 | @arr/reduceRight ⇝ 6.49ms @ 461,962,258.61 op/s 1190 | fastjs.reduceRight ⇝ 5.73ms @ 523,729,850.37 op/s 1191 | lodash.reduceright ⇝ 8.31ms @ 361,049,411.78 op/s 1192 | ramda.reduceRight ⇝ 7.34ms @ 408,841,218.61 op/s 1193 | 1194 | Array(500) 1195 | native ⇝ 145.92ms @ 102,799,048.82 op/s 1196 | @arr/reduceRight ⇝ 28.93ms @ 518,411,398.08 op/s 1197 | fastjs.reduceRight ⇝ 24.28ms @ 617,751,865.88 op/s 1198 | lodash.reduceright ⇝ 31.46ms @ 476,848,709.07 op/s 1199 | ramda.reduceRight ⇝ 25.02ms @ 599,434,972.59 op/s 1200 | 1201 | Array(1000) 1202 | native ⇝ 286.84ms @ 104,587,772.26 op/s 1203 | @arr/reduceRight ⇝ 57.15ms @ 524,942,438.75 op/s 1204 | fastjs.reduceRight ⇝ 48.31ms @ 621,053,489.72 op/s 1205 | lodash.reduceright ⇝ 57.55ms @ 521,292,351.16 op/s 1206 | ramda.reduceRight ⇝ 49.44ms @ 606,749,886.19 op/s 1207 | 1208 | Array(5000) 1209 | native ⇝ 1,413.66ms @ 106,107,531.62 op/s 1210 | @arr/reduceRight ⇝ 288.37ms @ 520,164,371.25 op/s 1211 | fastjs.reduceRight ⇝ 234.24ms @ 640,360,935.43 op/s 1212 | lodash.reduceright ⇝ 291.49ms @ 514,596,486.46 op/s 1213 | ramda.reduceRight ⇝ 241.16ms @ 622,001,243.89 op/s 1214 | 1215 | Array(10000) 1216 | native ⇝ 2,794.02ms @ 107,372,182.46 op/s 1217 | @arr/reduceRight ⇝ 538.08ms @ 557,533,859.14 op/s 1218 | fastjs.reduceRight ⇝ 456.32ms @ 657,435,081.59 op/s 1219 | lodash.reduceright ⇝ 552.93ms @ 542,566,166.84 op/s 1220 | ramda.reduceRight ⇝ 454.63ms @ 659,880,096.09 op/s 1221 | ``` 1222 |
1223 | 1224 |
1225 | :white_check_mark: ↝ Objects 1226 | 1227 | ``` 1228 | Array(100) 1229 | native ⇝ 28.32ms @ 105,918,971.00 op/s 1230 | @arr/reduceRight ⇝ 6.40ms @ 468,679,551.60 op/s 1231 | fastjs.reduceRight ⇝ 8.07ms @ 371,785,864.73 op/s 1232 | lodash.reduceright ⇝ 7.73ms @ 388,132,461.85 op/s 1233 | ramda.reduceRight ⇝ 6.74ms @ 444,999,804.20 op/s 1234 | 1235 | Array(500) 1236 | native ⇝ 142.70ms @ 105,114,559.10 op/s 1237 | @arr/reduceRight ⇝ 27.60ms @ 543,549,887.35 op/s 1238 | fastjs.reduceRight ⇝ 23.03ms @ 651,444,069.10 op/s 1239 | lodash.reduceright ⇝ 28.35ms @ 529,021,521.09 op/s 1240 | ramda.reduceRight ⇝ 24.19ms @ 620,005,801.60 op/s 1241 | 1242 | Array(1000) 1243 | native ⇝ 277.41ms @ 108,144,947.15 op/s 1244 | @arr/reduceRight ⇝ 54.13ms @ 554,172,781.58 op/s 1245 | fastjs.reduceRight ⇝ 45.36ms @ 661,321,790.48 op/s 1246 | lodash.reduceright ⇝ 55.76ms @ 537,990,784.11 op/s 1247 | ramda.reduceRight ⇝ 46.14ms @ 650,199,257.90 op/s 1248 | 1249 | Array(5000) 1250 | native ⇝ 1,401.93ms @ 106,995,305.73 op/s 1251 | @arr/reduceRight ⇝ 275.07ms @ 545,311,265.42 op/s 1252 | fastjs.reduceRight ⇝ 235.41ms @ 637,186,091.07 op/s 1253 | lodash.reduceright ⇝ 280.24ms @ 535,258,816.78 op/s 1254 | ramda.reduceRight ⇝ 236.38ms @ 634,566,432.70 op/s 1255 | 1256 | Array(10000) 1257 | native ⇝ 2,846.28ms @ 105,400,859.46 op/s 1258 | @arr/reduceRight ⇝ 562.03ms @ 533,780,044.13 op/s 1259 | fastjs.reduceRight ⇝ 466.17ms @ 643,543,859.78 op/s 1260 | lodash.reduceright ⇝ 567.29ms @ 528,833,085.99 op/s 1261 | ramda.reduceRight ⇝ 470.63ms @ 637,448,652.40 op/s 1262 | ``` 1263 | 1264 | 1265 | 1266 | ## reverse 1267 | 1268 |
1269 | :white_check_mark: ↝ Strings 1270 | 1271 | ``` 1272 | Array(100) 1273 | native ⇝ 35.06ms @ 85,564,738.11 op/s 1274 | @arr/reverse ⇝ 7.49ms @ 400,583,035.26 op/s 1275 | compute-reverse ⇝ 8.85ms @ 338,947,777.30 op/s 1276 | lodash.reverse ⇝ 31.32ms @ 95,797,653.90 op/s 1277 | ramda.reverse ⇝ 33.38ms @ 89,869,628.83 op/s 1278 | 1279 | Array(500) 1280 | native ⇝ 147.23ms @ 101,883,551.09 op/s 1281 | @arr/reverse ⇝ 27.91ms @ 537,505,407.30 op/s 1282 | compute-reverse ⇝ 28.34ms @ 529,257,663.55 op/s 1283 | lodash.reverse ⇝ 151.65ms @ 98,911,038.92 op/s 1284 | ramda.reverse ⇝ 92.39ms @ 162,353,820.41 op/s 1285 | 1286 | Array(1000) 1287 | native ⇝ 313.06ms @ 95,829,276.08 op/s 1288 | @arr/reverse ⇝ 56.03ms @ 535,452,248.77 op/s 1289 | compute-reverse ⇝ 56.34ms @ 532,524,057.71 op/s 1290 | lodash.reverse ⇝ 314.50ms @ 95,388,301.53 op/s 1291 | ramda.reverse ⇝ 172.32ms @ 174,094,002.34 op/s 1292 | 1293 | Array(5000) 1294 | native ⇝ 1,470.12ms @ 102,032,623.18 op/s 1295 | @arr/reverse ⇝ 278.93ms @ 537,762,025.89 op/s 1296 | compute-reverse ⇝ 288.25ms @ 520,374,229.56 op/s 1297 | lodash.reverse ⇝ 1,529.93ms @ 98,043,987.87 op/s 1298 | ramda.reverse ⇝ 844.47ms @ 177,627,195.39 op/s 1299 | 1300 | Array(10000) 1301 | native ⇝ 2,960.99ms @ 101,317,578.75 op/s 1302 | @arr/reverse ⇝ 540.12ms @ 555,432,715.44 op/s 1303 | compute-reverse ⇝ 568.63ms @ 527,583,197.03 op/s 1304 | lodash.reverse ⇝ 2,975.22ms @ 100,832,747.82 op/s 1305 | ramda.reverse ⇝ 1,612.75ms @ 186,017,428.77 op/s 1306 | ``` 1307 |
1308 | 1309 |
1310 | :white_check_mark: ↝ Numbers 1311 | 1312 | ``` 1313 | Array(100) 1314 | native ⇝ 30.79ms @ 97,441,396.80 op/s 1315 | @arr/reverse ⇝ 5.98ms @ 501,827,824.21 op/s 1316 | compute-reverse ⇝ 7.26ms @ 413,058,201.69 op/s 1317 | lodash.reverse ⇝ 33.67ms @ 89,108,912.66 op/s 1318 | ramda.reverse ⇝ 24.78ms @ 121,051,472.46 op/s 1319 | 1320 | Array(500) 1321 | native ⇝ 149.90ms @ 100,065,655.75 op/s 1322 | @arr/reverse ⇝ 24.47ms @ 613,060,694.07 op/s 1323 | compute-reverse ⇝ 24.88ms @ 602,906,733.95 op/s 1324 | lodash.reverse ⇝ 148.33ms @ 101,124,415.86 op/s 1325 | ramda.reverse ⇝ 80.64ms @ 186,020,975.13 op/s 1326 | 1327 | Array(1000) 1328 | native ⇝ 302.70ms @ 99,107,984.86 op/s 1329 | @arr/reverse ⇝ 45.42ms @ 660,529,103.63 op/s 1330 | compute-reverse ⇝ 45.95ms @ 652,829,254.27 op/s 1331 | lodash.reverse ⇝ 294.76ms @ 101,776,409.87 op/s 1332 | ramda.reverse ⇝ 143.68ms @ 208,799,885.08 op/s 1333 | 1334 | Array(5000) 1335 | native ⇝ 1,450.16ms @ 103,437,020.42 op/s 1336 | @arr/reverse ⇝ 233.06ms @ 643,615,403.63 op/s 1337 | compute-reverse ⇝ 237.17ms @ 632,446,112.21 op/s 1338 | lodash.reverse ⇝ 1,469.81ms @ 102,053,663.01 op/s 1339 | ramda.reverse ⇝ 715.91ms @ 209,524,822.13 op/s 1340 | 1341 | Array(10000) 1342 | native ⇝ 2,891.15ms @ 103,764,894.65 op/s 1343 | @arr/reverse ⇝ 450.71ms @ 665,616,573.69 op/s 1344 | compute-reverse ⇝ 456.62ms @ 657,007,265.55 op/s 1345 | lodash.reverse ⇝ 2,831.14ms @ 105,964,350.44 op/s 1346 | ramda.reverse ⇝ 1,382.85ms @ 216,943,462.77 op/s 1347 | ``` 1348 |
1349 | 1350 |
1351 | :white_check_mark: ↝ Objects 1352 | 1353 | ``` 1354 | Array(100) 1355 | native ⇝ 32.95ms @ 91,047,604.66 op/s 1356 | @arr/reverse ⇝ 6.50ms @ 461,410,757.24 op/s 1357 | compute-reverse ⇝ 7.25ms @ 413,900,203.69 op/s 1358 | lodash.reverse ⇝ 30.42ms @ 98,630,495.84 op/s 1359 | ramda.reverse ⇝ 25.25ms @ 118,804,715.26 op/s 1360 | 1361 | Array(500) 1362 | native ⇝ 148.95ms @ 100,702,891.41 op/s 1363 | @arr/reverse ⇝ 27.83ms @ 538,990,772.12 op/s 1364 | compute-reverse ⇝ 28.00ms @ 535,630,842.08 op/s 1365 | lodash.reverse ⇝ 143.36ms @ 104,633,855.38 op/s 1366 | ramda.reverse ⇝ 94.50ms @ 158,737,154.92 op/s 1367 | 1368 | Array(1000) 1369 | native ⇝ 304.52ms @ 98,514,563.59 op/s 1370 | @arr/reverse ⇝ 54.99ms @ 545,528,062.80 op/s 1371 | compute-reverse ⇝ 55.27ms @ 542,741,469.66 op/s 1372 | lodash.reverse ⇝ 298.20ms @ 100,603,980.69 op/s 1373 | ramda.reverse ⇝ 169.84ms @ 176,640,462.33 op/s 1374 | 1375 | Array(5000) 1376 | native ⇝ 1,457.93ms @ 102,885,482.41 op/s 1377 | @arr/reverse ⇝ 295.87ms @ 506,973,064.69 op/s 1378 | compute-reverse ⇝ 298.34ms @ 502,786,639.64 op/s 1379 | lodash.reverse ⇝ 1,475.46ms @ 101,662,951.18 op/s 1380 | ramda.reverse ⇝ 891.32ms @ 168,289,419.08 op/s 1381 | 1382 | Array(10000) 1383 | native ⇝ 2,972.28ms @ 100,932,605.06 op/s 1384 | @arr/reverse ⇝ 588.80ms @ 509,512,382.18 op/s 1385 | compute-reverse ⇝ 597.01ms @ 502,502,952.97 op/s 1386 | lodash.reverse ⇝ 2,962.23ms @ 101,274,928.20 op/s 1387 | ramda.reverse ⇝ 1,825.02ms @ 164,381,768.22 op/s 1388 | ``` 1389 | 1390 | 1391 | 1392 | ## some 1393 | 1394 |
1395 | :white_check_mark: ↝ Strings 1396 | 1397 | ``` 1398 | Array(100) 1399 | native ⇝ 2.33ms @ 1,290,141,128.54 op/s 1400 | @arr/some ⇝ 0.94ms @ 3,204,272,363.15 op/s 1401 | fastjs.some ⇝ 1.00ms @ 3,014,445,221.50 op/s 1402 | lodash.some ⇝ 1.77ms @ 1,696,766,359.23 op/s 1403 | 1404 | Array(500) 1405 | native ⇝ 1.55ms @ 9,685,517,697.38 op/s 1406 | @arr/some ⇝ 0.54ms @ 27,684,113,194.80 op/s 1407 | fastjs.some ⇝ 0.55ms @ 27,207,034,650.88 op/s 1408 | lodash.some ⇝ 0.80ms @ 18,786,751,582.78 op/s 1409 | 1410 | Array(1000) 1411 | native ⇝ 1.52ms @ 19,732,376,356.93 op/s 1412 | @arr/some ⇝ 0.56ms @ 53,453,258,688.83 op/s 1413 | fastjs.some ⇝ 0.57ms @ 52,722,687,451.12 op/s 1414 | lodash.some ⇝ 0.82ms @ 36,534,084,474.11 op/s 1415 | 1416 | Array(5000) 1417 | native ⇝ 1.62ms @ 92,725,212,541.64 op/s 1418 | @arr/some ⇝ 0.54ms @ 276,651,192,643.29 op/s 1419 | fastjs.some ⇝ 0.55ms @ 272,428,591,925.58 op/s 1420 | lodash.some ⇝ 1.31ms @ 114,393,527,461.69 op/s 1421 | 1422 | Array(10000) 1423 | native ⇝ 1.96ms @ 152,799,749,815.88 op/s 1424 | @arr/some ⇝ 0.75ms @ 399,970,668,817.62 op/s 1425 | fastjs.some ⇝ 0.76ms @ 395,820,139,328.69 op/s 1426 | lodash.some ⇝ 1.11ms @ 270,281,471,124.03 op/s 1427 | 1428 | ``` 1429 |
1430 | 1431 |
1432 | :white_check_mark: ↝ Numbers 1433 | 1434 | ``` 1435 | Array(100) 1436 | native ⇝ 2.39ms @ 1,257,593,770.38 op/s 1437 | @arr/some ⇝ 0.59ms @ 5,110,453,944.59 op/s 1438 | fastjs.some ⇝ 0.69ms @ 4,368,879,018.46 op/s 1439 | lodash.some ⇝ 0.81ms @ 3,689,469,638.74 op/s 1440 | 1441 | Array(500) 1442 | native ⇝ 1.50ms @ 10,004,788,958.98 op/s 1443 | @arr/some ⇝ 0.55ms @ 27,354,691,876.75 op/s 1444 | fastjs.some ⇝ 0.55ms @ 27,335,798,414.89 op/s 1445 | lodash.some ⇝ 0.81ms @ 18,474,294,251.17 op/s 1446 | 1447 | Array(1000) 1448 | native ⇝ 1.49ms @ 20,199,639,773.09 op/s 1449 | @arr/some ⇝ 0.53ms @ 56,361,737,143.89 op/s 1450 | fastjs.some ⇝ 0.52ms @ 57,227,772,256.36 op/s 1451 | lodash.some ⇝ 0.77ms @ 39,194,167,907.82 op/s 1452 | 1453 | Array(5000) 1454 | native ⇝ 1.48ms @ 101,172,795,040.10 op/s 1455 | @arr/some ⇝ 0.53ms @ 282,070,472,486.85 op/s 1456 | fastjs.some ⇝ 0.53ms @ 281,611,871,254.56 op/s 1457 | lodash.some ⇝ 0.79ms @ 190,444,026,596.14 op/s 1458 | 1459 | Array(10000) 1460 | native ⇝ 1.50ms @ 200,438,023,894.88 op/s 1461 | @arr/some ⇝ 0.53ms @ 563,353,833,153.37 op/s 1462 | fastjs.some ⇝ 0.53ms @ 563,481,867,153.52 op/s 1463 | lodash.some ⇝ 0.79ms @ 380,922,390,872.08 op/s 1464 | ``` 1465 |
1466 | 1467 |
1468 | :white_check_mark: ↝ Objects 1469 | 1470 | ``` 1471 | Array(100) 1472 | native ⇝ 2.03ms @ 1,476,674,450.38 op/s 1473 | @arr/some ⇝ 0.54ms @ 5,537,711,817.48 op/s 1474 | fastjs.some ⇝ 0.55ms @ 5,425,916,346.84 op/s 1475 | lodash.some ⇝ 0.81ms @ 3,723,206,872.54 op/s 1476 | 1477 | Array(500) 1478 | native ⇝ 1.74ms @ 8,620,139,749.71 op/s 1479 | @arr/some ⇝ 0.59ms @ 25,430,625,254.31 op/s 1480 | fastjs.some ⇝ 0.60ms @ 25,091,206,535.76 op/s 1481 | lodash.some ⇝ 0.89ms @ 16,817,368,978.68 op/s 1482 | 1483 | Array(1000) 1484 | native ⇝ 1.59ms @ 18,898,447,303.57 op/s 1485 | @arr/some ⇝ 0.58ms @ 51,468,923,064.25 op/s 1486 | fastjs.some ⇝ 0.58ms @ 51,675,224,658.04 op/s 1487 | lodash.some ⇝ 0.82ms @ 36,792,841,584.74 op/s 1488 | 1489 | Array(5000) 1490 | native ⇝ 1.50ms @ 100,122,750,492.10 op/s 1491 | @arr/some ⇝ 0.54ms @ 275,359,711,569.88 op/s 1492 | fastjs.some ⇝ 0.55ms @ 272,130,070,917.10 op/s 1493 | lodash.some ⇝ 0.81ms @ 186,007,983,462.65 op/s 1494 | 1495 | Array(10000) 1496 | native ⇝ 1.48ms @ 202,454,285,822.26 op/s 1497 | @arr/some ⇝ 0.54ms @ 553,801,849,698.18 op/s 1498 | fastjs.some ⇝ 0.56ms @ 532,997,899,988.27 op/s 1499 | lodash.some ⇝ 0.81ms @ 372,445,027,114.00 op/s 1500 | ``` 1501 | 1502 | 1503 | 1504 | ## unique 1505 | 1506 |
1507 | :wavy_dash: ↝ Strings 1508 | 1509 | ``` 1510 | Array(5) 1511 | @arr/unique ⇝ 10.37ms @ 14,462,269.67 op/s 1512 | arr-uniq ⇝ 36.06ms @ 4,159,256.03 op/s 1513 | array-unique ⇝ 8.14ms @ 18,435,658.20 op/s 1514 | lodash.uniq ⇝ 12.32ms @ 12,175,036.11 op/s 1515 | ramda.uniq ⇝ 65.89ms @ 2,276,522.93 op/s 1516 | 1517 | Array(10) 1518 | @arr/unique ⇝ 15.42ms @ 19,451,983.17 op/s 1519 | arr-uniq ⇝ 84.52ms @ 3,549,516.31 op/s 1520 | array-unique ⇝ 14.25ms @ 21,055,088.74 op/s 1521 | lodash.uniq ⇝ 21.89ms @ 13,705,665.71 op/s 1522 | ramda.uniq ⇝ 131.97ms @ 2,273,280.70 op/s 1523 | 1524 | Array(100) 1525 | @arr/unique ⇝ 998.74ms @ 3,003,798.75 op/s 1526 | arr-uniq ⇝ 3,430.27ms @ 874,567.08 op/s 1527 | array-unique ⇝ 1,303.98ms @ 2,300,656.21 op/s 1528 | lodash.uniq ⇝ 1,029.80ms @ 2,913,194.87 op/s 1529 | ramda.uniq ⇝ 818.79ms @ 3,663,960.96 op/s 1530 | 1531 | Array(500) 1532 | @arr/unique ⇝ 24,819.65ms @ 604,359.88 op/s 1533 | arr-uniq ⇝ 78,680.13ms @ 190,645.34 op/s 1534 | array-unique ⇝ 32,085.84ms @ 467,495.89 op/s 1535 | lodash.uniq ⇝ 4,902.48ms @ 3,059,673.57 op/s 1536 | ramda.uniq ⇝ 3,847.64ms @ 3,898,489.16 op/s 1537 | ``` 1538 |
1539 | 1540 |
1541 | :wavy_dash: ↝ Numbers 1542 | 1543 | ``` 1544 | Array(5) 1545 | @arr/unique ⇝ 6.50ms @ 23,065,830.19 op/s 1546 | arr-uniq ⇝ 31.12ms @ 4,820,503.41 op/s 1547 | array-unique ⇝ 3.22ms @ 46,596,845.95 op/s 1548 | lodash.uniq ⇝ 7.63ms @ 19,657,482.78 op/s 1549 | ramda.uniq ⇝ 32.56ms @ 4,607,405.86 op/s 1550 | 1551 | Array(10) 1552 | @arr/unique ⇝ 9.34ms @ 32,104,700.71 op/s 1553 | arr-uniq ⇝ 62.03ms @ 4,836,148.08 op/s 1554 | array-unique ⇝ 7.44ms @ 40,343,158.91 op/s 1555 | lodash.uniq ⇝ 11.60ms @ 25,863,261.80 op/s 1556 | ramda.uniq ⇝ 46.26ms @ 6,484,663.77 op/s 1557 | 1558 | Array(100) 1559 | @arr/unique ⇝ 176.16ms @ 17,030,379.66 op/s 1560 | arr-uniq ⇝ 2,473.84ms @ 1,212,690.60 op/s 1561 | array-unique ⇝ 538.29ms @ 5,573,152.79 op/s 1562 | lodash.uniq ⇝ 322.75ms @ 9,295,004.06 op/s 1563 | ramda.uniq ⇝ 328.42ms @ 9,134,553.07 op/s 1564 | 1565 | Array(500) 1566 | @arr/unique ⇝ 3,613.77ms @ 4,150,791.51 op/s 1567 | arr-uniq ⇝ 56,159.63ms @ 267,095.79 op/s 1568 | array-unique ⇝ 12,502.84ms @ 1,199,727.12 op/s 1569 | lodash.uniq ⇝ 2,436.70ms @ 6,155,859.86 op/s 1570 | ramda.uniq ⇝ 1,487.51ms @ 10,083,947.81 op/s 1571 | ``` 1572 |
1573 | 1574 |
1575 | 1576 | > :white_check_mark: — Denotes function **is** faster than native
1577 | > :no_entry_sign: — Denotes function **is not** faster than native
1578 | > :mag: — Denotes function **is sometimes** faster than native
1579 | > :wavy_dash: — Denotes function has no native counterpart
1580 | 1581 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.0.0-rc.5", 3 | "version": "1.0.3", 4 | "packages": [ 5 | "packages/*" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Luke Edwards (https://lukeed.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "repository": "lukeed/arr", 4 | "homepage": "https://github.com/lukeed/arr", 5 | "license": "MIT", 6 | "author": { 7 | "name": "Luke Edwards", 8 | "email": "luke@lukeed.com", 9 | "url": "https://lukeed.com" 10 | }, 11 | "scripts": { 12 | "bench": "node benchmarks", 13 | "build": "taskr build", 14 | "prebench": "taskr build", 15 | "pretest": "taskr build", 16 | "test": "tape tests/* | tap-spec" 17 | }, 18 | "devDependencies": { 19 | "benchmark": "2.1.4", 20 | "cli-table2": "0.2.0", 21 | "gzip-size": "3.0.0", 22 | "lerna": "2.11.0", 23 | "pretty-bytes": "4.0.2", 24 | "tap-spec": "4.1.2", 25 | "tape": "4.9.1", 26 | "taskr": "^1.0.6", 27 | "terser": "3.10.12" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/every/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): boolean; 2 | -------------------------------------------------------------------------------- /packages/every/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, cb) { 2 | var i=0, len=arr.length; 3 | 4 | for (; i < len; i++) { 5 | if (!cb(arr[i], i, arr)) { 6 | return false; 7 | } 8 | } 9 | 10 | return true; 11 | } 12 | -------------------------------------------------------------------------------- /packages/every/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/every", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.every", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.every", 22 | "Array.prototype.every", 23 | "performance", 24 | "native", 25 | "every" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/every/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/every 2 | 3 | > A tiny, faster alternative to native `Array.prototype.every` 4 | 5 | :warning: Unlike native, `@arr/every` does _not_ support the optional `thisArg` parameter! 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install --save @arr/every 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | import every from '@arr/every'; 17 | 18 | const isBigEnough = val => val >= 10; 19 | 20 | every([12, 5, 8, 130, 44], isBigEnough); 21 | //=> false 22 | every([12, 54, 18, 130, 44], isBigEnough); 23 | //=> true 24 | ``` 25 | 26 | ## API 27 | 28 | ### every(arr, callback) 29 | 30 | #### arr 31 | Type: `Array`
32 | The array to iterate upon. 33 | 34 | #### callback(value[, index, array]) 35 | Type: `Function`
36 | Function to test for each element, taking three arguments: 37 | 38 | * **value** (required) -- The current element being processed in the array. 39 | * **index** (optional) -- The index of the current element being processed in the array. 40 | * **array** (optional) -- The array `every` was called upon. 41 | 42 | 43 | ## License 44 | 45 | MIT © [Luke Edwards](http://lukeed.com) 46 | -------------------------------------------------------------------------------- /packages/filter.mutate/module.d.ts: -------------------------------------------------------------------------------- 1 | declare function filter(arr: T[], callback: (val: T, idx: number, arr: T[]) => val is S): S[]; 2 | declare function filter(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): T[]; 3 | export default filter; 4 | -------------------------------------------------------------------------------- /packages/filter.mutate/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, cb) { 2 | var len = arr.length; 3 | 4 | while (len--) { 5 | cb(arr[len], len, arr) || arr.splice(len, 1); 6 | } 7 | 8 | return arr; 9 | } 10 | -------------------------------------------------------------------------------- /packages/filter.mutate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/filter.mutate", 3 | "version": "1.0.2", 4 | "repository": "lukeed/arr", 5 | "description": "Fastest Array.filter alternative --- mutates original array!", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.filter", 22 | "Array.prototype.filter", 23 | "performance", 24 | "mutator", 25 | "mutate", 26 | "native", 27 | "filter" 28 | ], 29 | "publishConfig": { 30 | "access": "public" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/filter.mutate/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/filter.mutate 2 | 3 | > Fastest `Array.filter` alternative --- mutates original array! 4 | 5 | :exclamation: Unlike native, `@arr/filter.mutate` **mutates** the original array! Use [`@arr/filter`](/packages/filter) for a non-mutating version. 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install --save @arr/filter.mutate 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | import filter from '@arr/filter.mutate'; 17 | 18 | const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; 19 | 20 | filter(words, str => str.length > 6); 21 | //=> ['exuberant', 'destruction', 'present'] 22 | 23 | console.log(words); 24 | //=> ['exuberant', 'destruction', 'present'] 25 | ``` 26 | 27 | ## API 28 | 29 | ### filter(arr, callback) 30 | 31 | #### arr 32 | Type: `Array`
33 | The array to iterate upon. 34 | 35 | #### callback(value[, index, array]) 36 | Type: `Function`
37 | Function to test for each element, taking three arguments: 38 | 39 | * **value** (required) -- The current element being processed in the array. 40 | * **index** (optional) -- The index of the current element being processed in the array. 41 | * **array** (optional) -- The array `filter.mutate` was called upon. 42 | 43 | 44 | ## License 45 | 46 | MIT © [Luke Edwards](http://lukeed.com) 47 | -------------------------------------------------------------------------------- /packages/filter/module.d.ts: -------------------------------------------------------------------------------- 1 | declare function filter(arr: T[], callback: (val: T, idx: number, arr: T[]) => val is S): S[]; 2 | declare function filter(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): T[]; 3 | export default filter; 4 | -------------------------------------------------------------------------------- /packages/filter/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, cb) { 2 | var i=0, len=arr.length, res=[]; 3 | for (; i < len; i++) { 4 | if (cb(arr[i], i, arr)) { 5 | res.push(arr[i]); 6 | } 7 | } 8 | return res; 9 | } 10 | -------------------------------------------------------------------------------- /packages/filter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/filter", 3 | "version": "1.0.2", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.filter", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.filter", 22 | "Array.prototype.filter", 23 | "performance", 24 | "native", 25 | "filter" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/filter/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/filter 2 | 3 | > A tiny, faster alternative to native `Array.prototype.filter` 4 | 5 | :warning: Unlike native, `@arr/filter` does _not_ support the optional `thisArg` parameter! 6 | 7 | If you are okay with mutating the original, check out [`@arr/filter.mutate`](/packages/filter.mutate) for an **extremely fast** `filter` alternative! 8 | 9 | ## Install 10 | 11 | ``` 12 | $ npm install --save @arr/filter 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | import filter from '@arr/filter'; 19 | 20 | const words = ['foo', 'bar', 'baz', 'foobar', 'hello', 'world']; 21 | 22 | filter(words, str => str.length > 3); 23 | //=> ['foobar', 'hello', 'world'] 24 | 25 | console.log(words); 26 | //=> ['foo', 'bar', 'baz', 'foobar', 'hello', 'world'] 27 | ``` 28 | 29 | ## API 30 | 31 | ### filter(arr, callback) 32 | 33 | #### arr 34 | Type: `Array`
35 | The array to iterate upon. 36 | 37 | #### callback(value[, index, array]) 38 | Type: `Function`
39 | Function to test for each element, taking three arguments: 40 | 41 | * **value** (required) -- The current element being processed in the array. 42 | * **index** (optional) -- The index of the current element being processed in the array. 43 | * **array** (optional) -- The array `filter` was called upon. 44 | 45 | 46 | ## License 47 | 48 | MIT © [Luke Edwards](http://lukeed.com) 49 | -------------------------------------------------------------------------------- /packages/find/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): T | undefined; 2 | -------------------------------------------------------------------------------- /packages/find/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, cb) { 2 | var cur, i=0, len=arr.length; 3 | 4 | for (; i < len; i++) { 5 | cur = arr[i]; 6 | if (cb(cur, i, arr)) { 7 | return cur; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/find/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/find", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.find", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.find", 22 | "Array.prototype.find", 23 | "performance", 24 | "native", 25 | "find" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/find/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/find 2 | 3 | > A tiny, faster alternative to native `Array.prototype.find` 4 | 5 | :warning: Unlike native, `@arr/find` does _not_ support the optional `thisArg` parameter! 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install --save @arr/find 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | import find from '@arr/find'; 17 | 18 | find([12, 5, 8, 130, 44], val => val > 15); 19 | //=> 130 20 | ``` 21 | 22 | ## API 23 | 24 | ### find(arr, callback) 25 | 26 | #### arr 27 | Type: `Array`
28 | The array to iterate upon. 29 | 30 | #### callback(value[, index, array]) 31 | Type: `Function`
32 | Function to test for each element, taking three arguments: 33 | 34 | * **value** (required) -- The current element being processed in the array. 35 | * **index** (optional) -- The index of the current element being processed in the array. 36 | * **array** (optional) -- The array `find` was called upon. 37 | 38 | 39 | ## License 40 | 41 | MIT © [Luke Edwards](http://lukeed.com) 42 | -------------------------------------------------------------------------------- /packages/findIndex/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): number; 2 | -------------------------------------------------------------------------------- /packages/findIndex/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, cb) { 2 | var i=0, len=arr.length; 3 | 4 | for (; i < len; i++) { 5 | if (cb(arr[i], i, arr)) { 6 | return i; 7 | } 8 | } 9 | 10 | return -1; 11 | } 12 | -------------------------------------------------------------------------------- /packages/findIndex/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/findindex", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.findIndex", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.findIndex", 22 | "Array.prototype.findIndex", 23 | "performance", 24 | "native", 25 | "findindex" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/findIndex/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/findindex 2 | 3 | > A tiny, faster alternative to native `Array.prototype.findIndex` 4 | 5 | :warning: Unlike native, `@arr/findindex` does _not_ support the optional `thisArg` parameter! 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install --save @arr/findindex 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | import findIndex from '@arr/findindex'; 17 | 18 | findIndex([12, 5, 8, 130, 44], val => val > 15); 19 | //=> 3 20 | ``` 21 | 22 | ## API 23 | 24 | ### findIndex(arr, callback) 25 | 26 | #### arr 27 | Type: `Array`
28 | The array to iterate upon. 29 | 30 | #### callback(value[, index, array]) 31 | Type: `Function`
32 | Function to test for each element, taking three arguments: 33 | 34 | * **value** (required) -- The current element being processed in the array. 35 | * **index** (optional) -- The index of the current element being processed in the array. 36 | * **array** (optional) -- The array `findIndex` was called upon. 37 | 38 | 39 | ## License 40 | 41 | MIT © [Luke Edwards](http://lukeed.com) 42 | -------------------------------------------------------------------------------- /packages/flatten/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[]): T[]; 2 | -------------------------------------------------------------------------------- /packages/flatten/module.js: -------------------------------------------------------------------------------- 1 | function flat(arr, res) { 2 | var i=0, cur, len=arr.length; 3 | for (; i < len; i++) { 4 | cur = arr[i]; 5 | Array.isArray(cur) ? flat(cur, res) : res.push(cur); 6 | } 7 | return res; 8 | } 9 | 10 | export default function (arr) { 11 | return flat(arr, []); 12 | } 13 | -------------------------------------------------------------------------------- /packages/flatten/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/flatten", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny (139B) & fast utility to recursively flatten an array of arrays!", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.flatten", 22 | "Array.prototype.flatten", 23 | "performance", 24 | "recursive", 25 | "recurse", 26 | "nested", 27 | "flatten" 28 | ], 29 | "publishConfig": { 30 | "access": "public" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/flatten/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/flatten 2 | 3 | > Tiny (139B) & fast utility to recursively flatten an array of arrays! 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @arr/flatten 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import flatten from '@arr/flatten'; 15 | 16 | flatten(['a', ['b', ['c']], 'd', ['e', [['f']]]]); 17 | //=> ['a', 'b', 'c', 'd', 'e', 'f'] 18 | ``` 19 | 20 | ## API 21 | 22 | ### flatten(arr) 23 | 24 | #### arr 25 | Type: `Array`
26 | The array to iterate upon. 27 | 28 | ## License 29 | 30 | MIT © [Luke Edwards](http://lukeed.com) 31 | -------------------------------------------------------------------------------- /packages/forEach.spec/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, fn) { 2 | var i; 3 | for (i in arr) { 4 | fn(arr[i], +i, arr); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/forEach.spec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@arr/foreach.spec", 4 | "version": "1.0.0", 5 | "repository": "lukeed/arr", 6 | "description": "A tiny, faster alternative to native Array.prototype.forEach", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "scripts": { 19 | "bench": "node bench", 20 | "test": "tape test/*.js | tap-spec" 21 | }, 22 | "files": [ 23 | "*.js" 24 | ], 25 | "keywords": [ 26 | "arr", 27 | "array", 28 | "Array.forEach", 29 | "Array.prototype.forEach", 30 | "performance", 31 | "forEach.spec", 32 | "native", 33 | "spec" 34 | ], 35 | "publishConfig": { 36 | "access": "public" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/forEach/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): void; 2 | -------------------------------------------------------------------------------- /packages/forEach/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, fn) { 2 | var i=0, len=arr.length; 3 | 4 | for (; i < len; i++) { 5 | fn(arr[i], i, arr); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/forEach/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/foreach", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.forEach", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.forEach", 22 | "Array.prototype.forEach", 23 | "performance", 24 | "native", 25 | "foreach" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/forEach/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/foreach 2 | 3 | > A tiny, faster alternative to native `Array.prototype.forEach` 4 | 5 | :warning: Unlike native, `@arr/foreach` does _not_ support the optional `thisArg` parameter! 6 | 7 | ## Install 8 | 9 | ``` 10 | $ npm install --save @arr/foreach 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | import forEach from '@arr/foreach'; 17 | 18 | forEach(['a', 'b', 'c'], val => { 19 | console.log(val); 20 | }); 21 | //=> a 22 | //=> b 23 | //=> c 24 | ``` 25 | 26 | ## API 27 | 28 | ### forEach(arr, callback) 29 | 30 | #### arr 31 | Type: `Array`
32 | The array to iterate upon. 33 | 34 | #### callback(value[, index, array]) 35 | Type: `Function`
36 | Function to test for each element, taking three arguments: 37 | 38 | * **value** (required) -- The current element being processed in the array. 39 | * **index** (optional) -- The index of the current element being processed in the array. 40 | * **array** (optional) -- The array `forEach` was called upon. 41 | 42 | 43 | ## License 44 | 45 | MIT © [Luke Edwards](http://lukeed.com) 46 | -------------------------------------------------------------------------------- /packages/includes/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], val: T, fromIndex?: number): boolean; 2 | -------------------------------------------------------------------------------- /packages/includes/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, val, idx) { 2 | var i=idx|0, len=arr.length; 3 | 4 | for (; i < len; i++) { 5 | if (arr[i] === val) { 6 | return true; 7 | } 8 | } 9 | 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /packages/includes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/includes", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.includes", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.includes", 22 | "Array.prototype.includes", 23 | "performance", 24 | "native", 25 | "includes" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/includes/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/includes 2 | 3 | > A tiny, faster alternative to native `Array.prototype.includes` 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @arr/includes 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import includes from '@arr/includes'; 15 | 16 | const foo = ['a', 'b', 'c', 'd']; 17 | 18 | includes(foo, 'c'); 19 | //=> true 20 | includes(foo, 'g'); 21 | //=> false 22 | includes(foo, 'b', 2); 23 | //=> false 24 | ``` 25 | 26 | ## API 27 | 28 | ### includes(arr, item[, fromIndex]) 29 | 30 | #### arr 31 | Type: `Array`
32 | The array to iterate upon. 33 | 34 | #### item 35 | Type: `Mixed`
36 | The element to search for. 37 | 38 | #### fromIndex 39 | Type: `Integer`
40 | Default: `0`
41 | The position in the `arr` at which to begin searching. 42 | 43 | 44 | ## License 45 | 46 | MIT © [Luke Edwards](http://lukeed.com) 47 | -------------------------------------------------------------------------------- /packages/map.spec/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, fn) { 2 | if (arr == null) { 3 | return []; 4 | } 5 | 6 | var i, out=new Array(arr.length); 7 | 8 | for (i in arr) { 9 | out[i] = fn(arr[i], +i, arr); 10 | } 11 | 12 | return out; 13 | } 14 | -------------------------------------------------------------------------------- /packages/map.spec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@arr/map.spec", 4 | "version": "1.0.0", 5 | "repository": "lukeed/arr", 6 | "description": "A tiny, faster alternative to native Array.prototype.map", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "scripts": { 19 | "bench": "node bench", 20 | "test": "tape test/*.js | tap-spec" 21 | }, 22 | "files": [ 23 | "*.js" 24 | ], 25 | "keywords": [ 26 | "arr", 27 | "array", 28 | "Array.map", 29 | "Array.prototype.map", 30 | "performance", 31 | "map.spec", 32 | "native", 33 | "spec" 34 | ], 35 | "publishConfig": { 36 | "access": "public" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/map/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], callback: (val: T, idx: number, arr: T[]) => U): U[]; 2 | -------------------------------------------------------------------------------- /packages/map/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, fn) { 2 | if (arr == null) { 3 | return []; 4 | } 5 | 6 | var i=0, len=arr.length, out=new Array(len); 7 | 8 | for (; i < len; i++) { 9 | out[i] = fn(arr[i], i, arr); 10 | } 11 | 12 | return out; 13 | } 14 | -------------------------------------------------------------------------------- /packages/map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/map", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.map", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.map", 22 | "Array.prototype.map", 23 | "performance", 24 | "native", 25 | "map" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/map/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/map 2 | 3 | > A tiny, faster alternative to native `Array.prototype.map` 4 | 5 | :warning: Unlike native, `@arr/map` does _not_ support the optional `thisArg` parameter! 6 | 7 | :warning: Unlike native, `@arr/map` does _not_ respect [Array holes](http://2ality.com/2015/09/holes-arrays-es6.html) -- you probably never needed this... :thinking: 8 | 9 | ## Install 10 | 11 | ``` 12 | $ npm install --save @arr/map 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | import map from '@arr/map'; 19 | 20 | const nums = [1, 5, 10, 15]; 21 | const doubles = map(nums, x => x * 2); 22 | //=> doubles is: [2, 10, 20, 30] 23 | //=> numbers is: [1, 5, 10, 15] 24 | ``` 25 | 26 | ## API 27 | 28 | ### map(arr, callback) 29 | 30 | #### arr 31 | Type: `Array`
32 | The array to iterate upon. 33 | 34 | #### callback(value[, index, array]) 35 | Type: `Function`
36 | Function to test for each element, taking three arguments: 37 | 38 | * **value** (required) -- The current element being processed in the array. 39 | * **index** (optional) -- The index of the current element being processed in the array. 40 | * **array** (optional) -- The array `map` was called upon. 41 | 42 | 43 | ## License 44 | 45 | MIT © [Luke Edwards](http://lukeed.com) 46 | -------------------------------------------------------------------------------- /packages/reduce/module.d.ts: -------------------------------------------------------------------------------- 1 | export type Reducer = ( 2 | previous: R, 3 | current: T, 4 | index: number, 5 | arr: T[] 6 | ) => R; 7 | 8 | export default function ( 9 | arr: ArrayItemType[], 10 | callback: Reducer, 11 | initialValue?: ReturnType 12 | ): ReturnType; 13 | -------------------------------------------------------------------------------- /packages/reduce/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, fn, val) { 2 | if (arr == null) { 3 | return []; 4 | } 5 | 6 | var i=0, len=arr.length, out=val; 7 | 8 | if (out === void 0) { 9 | out = arr[0]; 10 | i = 1; 11 | } 12 | 13 | for (; i < len; i++) { 14 | out = fn(out, arr[i], i, arr); 15 | } 16 | 17 | return out; 18 | } 19 | -------------------------------------------------------------------------------- /packages/reduce/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/reduce", 3 | "version": "1.0.3", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.reduce", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.reduce", 22 | "Array.prototype.reduce", 23 | "performance", 24 | "native", 25 | "reduce" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/reduce/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/reduce 2 | 3 | > A tiny, faster alternative to native `Array.prototype.reduce` 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @arr/reduce 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import reduce from '@arr/reduce'; 15 | 16 | const total = reduce([0, 1, 2, 3], (sum, value) => sum + value); 17 | //=> 6 18 | 19 | const flattened = reduce([[0, 1], [2, 3], [4, 5]], (a, b) => a.concat(b), []); 20 | //=> [0, 1, 2, 3, 4, 5] 21 | ``` 22 | 23 | ## API 24 | 25 | ### reduce(arr, callback[, initialValue]) 26 | 27 | #### arr 28 | Type: `Array`
29 | The array to iterate upon. 30 | 31 | #### callback(accumulator, value, index, array) 32 | Type: `Function`
33 | Function to test for each element, taking four arguments: 34 | 35 | * **accumulator** -- The accumulator accumulates the callback's return values. 36 | * **value** -- The current element being processed in the array. 37 | * **index** -- The index of the current element being processed in the array. 38 | * **array** -- The array `reduce` was called upon. 39 | 40 | #### initialValue 41 | Type: `Mixed`
42 | Default: `arr[0]`
43 | The `value` to use as the first argument to the first call of the `callback`. If no initial value is supplied, the first element in the array will be used. 44 | 45 | 46 | ## License 47 | 48 | MIT © [Luke Edwards](http://lukeed.com) 49 | -------------------------------------------------------------------------------- /packages/reduceRight/module.d.ts: -------------------------------------------------------------------------------- 1 | export type Reducer = ( 2 | previous: R, 3 | item: T, 4 | index: number, 5 | arr: T[] 6 | ) => R; 7 | 8 | export default function ( 9 | arr: ArrayItemType[], 10 | callback: Reducer, 11 | initialValue?: ReturnType 12 | ): ReturnType; 13 | -------------------------------------------------------------------------------- /packages/reduceRight/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, fn, val) { 2 | if (arr == null) { 3 | return []; 4 | } 5 | 6 | var i=arr.length, out=val; 7 | 8 | if (out === void 0) { 9 | i--; 10 | out = arr[i]; 11 | } 12 | 13 | while (i--) { 14 | out = fn(out, arr[i], i, arr); 15 | } 16 | 17 | return out; 18 | } 19 | -------------------------------------------------------------------------------- /packages/reduceRight/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/reduceright", 3 | "version": "1.0.3", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.reduceRight", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.reduceRight", 22 | "Array.prototype.reduceRight", 23 | "performance", 24 | "native", 25 | "reduceRight" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/reduceRight/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/reduceright 2 | 3 | > A tiny, faster alternative to native `Array.prototype.reduceRight` 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @arr/reduceright 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import reduceRight from '@arr/reduceright'; 15 | 16 | reduceRight([[0, 1], [2, 3], [4, 5]], (a, b) => a.concat(b), []); 17 | //=> [4, 5, 2, 3, 0, 1] 18 | ``` 19 | 20 | ## API 21 | 22 | ### reduceRight(arr, callback[, initialValue]) 23 | 24 | #### arr 25 | Type: `Array`
26 | The array to iterate upon. 27 | 28 | #### callback(accumulator, value, index, array) 29 | Type: `Function`
30 | Function to test for each element, taking four arguments: 31 | 32 | * **accumulator** -- The value previously returned in the last invocation of the callback, or initialValue, if supplied. 33 | * **value** -- The current element being processed in the array. 34 | * **index** -- The index of the current element being processed in the array. 35 | * **array** -- The array `reduceRight` was called upon. 36 | 37 | #### initialValue 38 | Type: `Mixed`
39 | Default: `arr[-1]`
40 | The `value` to use as the first argument to the first call of the `callback`. If no initial value is supplied, the last element in the array will be used. 41 | 42 | 43 | ## License 44 | 45 | MIT © [Luke Edwards](http://lukeed.com) 46 | -------------------------------------------------------------------------------- /packages/reverse/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[]): T[]; 2 | -------------------------------------------------------------------------------- /packages/reverse/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr) { 2 | if (arr == null) { 3 | return []; 4 | } 5 | 6 | var i=0, len=arr.length, j=len-1; 7 | var k, tmp, mid=len/2|0; // same as Math.floor 8 | 9 | for (; i < mid; i++) { 10 | tmp = arr[i]; 11 | k = j - i; 12 | arr[i] = arr[k]; 13 | arr[k] = tmp; 14 | } 15 | 16 | return arr; 17 | } 18 | -------------------------------------------------------------------------------- /packages/reverse/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/reverse", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.reverse", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.reverse", 22 | "Array.prototype.reverse", 23 | "performance", 24 | "native", 25 | "reverse" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/reverse/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/reverse 2 | 3 | > A tiny, faster alternative to native `Array.prototype.reverse` 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @arr/reverse 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import reverse from '@arr/reverse'; 15 | 16 | let a = ['one', 'two', 'three']; 17 | let reversed = reverse(a); 18 | 19 | console.log(a); 20 | //=> ['three', 'two', 'one'] 21 | console.log(reversed); 22 | //=> ['three', 'two', 'one'] 23 | ``` 24 | 25 | ## API 26 | 27 | ### reverse(arr) 28 | 29 | #### arr 30 | Type: `Array`
31 | The array to iterate upon. 32 | 33 | 34 | ## License 35 | 36 | MIT © [Luke Edwards](http://lukeed.com) 37 | -------------------------------------------------------------------------------- /packages/some/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[], callback: (val: T, idx: number, arr: T[]) => unknown): boolean; 2 | -------------------------------------------------------------------------------- /packages/some/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr, cb) { 2 | var i=0, len=arr.length; 3 | 4 | for (; i < len; i++) { 5 | if (cb(arr[i], i, arr)) { 6 | return true; 7 | } 8 | } 9 | 10 | return false; 11 | } 12 | -------------------------------------------------------------------------------- /packages/some/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/some", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny, faster alternative to native Array.prototype.some", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.some", 22 | "Array.prototype.some", 23 | "performance", 24 | "native", 25 | "some" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/some/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/some 2 | 3 | > A tiny, faster alternative to native `Array.prototype.some` 4 | 5 | :warning: Unlike native, `@arr/some` does _not_ support the optional `thisArg` parameter! 6 | 7 | 8 | ## Install 9 | 10 | ``` 11 | $ npm install --save @arr/some 12 | ``` 13 | 14 | ## Usage 15 | 16 | ```js 17 | import some from '@arr/some'; 18 | 19 | const isBiggerThan10 = val => val > 10; 20 | 21 | some([2, 5, 8, 1, 4], isBiggerThan10); 22 | //=> false 23 | some([12, 5, 8, 1, 4], isBiggerThan10); 24 | //=> true 25 | ``` 26 | 27 | ## API 28 | 29 | ### some(arr, callback) 30 | 31 | #### arr 32 | Type: `Array`
33 | The array to iterate upon. 34 | 35 | #### callback(value[, index, array]) 36 | Type: `Function`
37 | Function to test for each element, taking three arguments: 38 | 39 | * **value** (required) -- The current element being processed in the array. 40 | * **index** (optional) -- The index of the current element being processed in the array. 41 | * **array** (optional) -- The array `some` was called upon. 42 | 43 | 44 | ## License 45 | 46 | MIT © [Luke Edwards](http://lukeed.com) 47 | -------------------------------------------------------------------------------- /packages/unique/module.d.ts: -------------------------------------------------------------------------------- 1 | export default function(arr: T[]): T[]; 2 | -------------------------------------------------------------------------------- /packages/unique/module.js: -------------------------------------------------------------------------------- 1 | export default function (arr) { 2 | var i=0, j, len=arr.length, out=[]; 3 | 4 | for (; i < len; i++) { 5 | j = arr[i]; 6 | if (out.indexOf(j) === -1) { 7 | out.push(j); 8 | } 9 | } 10 | 11 | return out; 12 | } 13 | -------------------------------------------------------------------------------- /packages/unique/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@arr/unique", 3 | "version": "1.0.1", 4 | "repository": "lukeed/arr", 5 | "description": "A tiny (111B) & fast utility to retrieve all unique values from an Array", 6 | "types": "module.d.ts", 7 | "module": "module.js", 8 | "main": "index.js", 9 | "license": "MIT", 10 | "author": { 11 | "name": "Luke Edwards", 12 | "email": "luke.edwards05@gmail.com", 13 | "url": "https://lukeed.com" 14 | }, 15 | "engines": { 16 | "node": ">=4" 17 | }, 18 | "keywords": [ 19 | "arr", 20 | "array", 21 | "Array.unique", 22 | "Array.prototype.unique", 23 | "performance", 24 | "native", 25 | "unique" 26 | ], 27 | "publishConfig": { 28 | "access": "public" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/unique/readme.md: -------------------------------------------------------------------------------- 1 | # @arr/unique 2 | 3 | > Tiny (111B) & fast utility to retrieve all unique values from an Array. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm install --save @arr/unique 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | import unique from '@arr/unique'; 15 | 16 | unique([1, 1, 2, 3, 3]); 17 | //=> [1, 2, 3] 18 | 19 | unique(['foo', 'foo', 'bar', 'foo']); 20 | //=> ['foo', 'bar'] 21 | ``` 22 | 23 | ## API 24 | 25 | ### unique(arr) 26 | 27 | #### arr 28 | Type: `Array`
29 | The array to iterate upon. 30 | 31 | 32 | ## License 33 | 34 | MIT © [Luke Edwards](http://lukeed.com) 35 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # arr [![Build Status](https://travis-ci.org/lukeed/arr.svg?branch=master)](https://travis-ci.org/lukeed/arr) 2 | 3 | > A collection of tiny, highly performant `Array.prototype` alternatives and extra utilities. 4 | 5 | All exports are offered as CommonJS and ES6 modules. Additionally, every entry is ES3 code, which means that each package is ready for & compatible with any Browser or Node version! 6 | 7 | Please view each package's readme for Usage and important information! :pray: 8 | 9 | > :warning: **Note:** Most functions have _slight differences_ from the native built-ins! 10 | 11 | To view extensive benchmark results, visit the [Benchmarks section](/benchmarks). 12 | 13 | | Package | Version | Minified | Node 4 | Node 6 | Node 7 | Node 8 | Node 10 | Node 12 | 14 | |---------|:-------:|:-----:|:------:|:------:|:------:|:------:|:------:|:------:| 15 | | [`every`](/packages/every) | [![npm](https://img.shields.io/npm/v/@arr/every.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/every) | 95 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | 16 | | [`filter`](/packages/filter) | [![npm](https://img.shields.io/npm/v/@arr/filter.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/filter) | 101 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | 17 | | [`filter.mutate`](/packages/filter.mutate) | [![npm](https://img.shields.io/npm/v/@arr/filter.mutate.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/filter.mutate) | 90 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | 18 | | [`find`](/packages/find) | [![npm](https://img.shields.io/npm/v/@arr/find.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/find) | 91 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :mag: | :mag: | 19 | | [`findIndex`](/packages/findIndex) | [![npm](https://img.shields.io/npm/v/@arr/findindex.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/findindex) | 94 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :mag: | :no_entry_sign: | 20 | | [`flatten`](/packages/flatten) | [![npm](https://img.shields.io/npm/v/@arr/flatten.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/flatten) | 151 B | :wavy_dash: | :wavy_dash: | :wavy_dash: | :wavy_dash: | :wavy_dash: | :white_check_mark: | 21 | | [`forEach`](/packages/forEach) | [![npm](https://img.shields.io/npm/v/@arr/foreach.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/foreach) | 73 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :mag: | 22 | | [`includes`](/packages/includes) | [![npm](https://img.shields.io/npm/v/@arr/includes.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/includes) | 95 B | :wavy_dash: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | 23 | | [`map`](/packages/map) | [![npm](https://img.shields.io/npm/v/@arr/map.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/map) | 122 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | 24 | | [`reduce`](/packages/reduce) | [![npm](https://img.shields.io/npm/v/@arr/reduce.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/reduce) | 137 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | 25 | | [`reduceRight`](/packages/reduceRight) | [![npm](https://img.shields.io/npm/v/@arr/reduceright.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/reduceright) | 130 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | 26 | | [`reverse`](/packages/reverse) | [![npm](https://img.shields.io/npm/v/@arr/reverse.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/reverse) | 136 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | 27 | | [`some`](/packages/some) | [![npm](https://img.shields.io/npm/v/@arr/some.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/some) | 94 B | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :mag: | 28 | | [`unique`](/packages/unique) | [![npm](https://img.shields.io/npm/v/@arr/unique.svg?maxAge=86400)](https://www.npmjs.com/package/@arr/unique) | 111 B | :wavy_dash: | :wavy_dash: | :wavy_dash: | :mag: | :mag: | :mag: | 29 | 30 | > :white_check_mark: — Denotes function **is** faster than native
31 | > :no_entry_sign: — Denotes function **is not** faster than native
32 | > :mag: — Denotes function **is sometimes** faster than native
33 | > :wavy_dash: — Denotes function has no native counterpart
34 | 35 | ## License 36 | 37 | MIT © [Luke Edwards](http://lukeed.com) 38 | -------------------------------------------------------------------------------- /taskfile.js: -------------------------------------------------------------------------------- 1 | const size = require('gzip-size'); 2 | const Table = require('cli-table2'); 3 | const bytes = require('pretty-bytes'); 4 | const minify = require('terser').minify; 5 | 6 | const out = {}; 7 | const tbl = new Table({ head:['Package', 'Minified', 'Gzipped'] }); 8 | 9 | exports.build = function * (task) { 10 | yield task.source('packages/*/module.js').run({}, function * (file) { 11 | const data = file.data.toString().replace('export default', 'module.exports ='); 12 | file.base = 'index.js'; 13 | file.data = data; 14 | const min = minify(data, { toplevel:true }).code; 15 | out[file.dir] = { min:bytes(min.length), gzip:bytes(size.sync(min)) }; 16 | }).target('packages'); 17 | 18 | for (const k in out) { 19 | tbl.push([k, out[k].min, out[k].gzip]); 20 | } 21 | 22 | console.log(tbl.toString()); 23 | } 24 | -------------------------------------------------------------------------------- /tests/every.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/every'); 4 | 5 | const foo = [12, 5, 8, 130, 44]; 6 | const bar = [12, 54, 18, 130, 44]; 7 | const isBigEnough = val => val >= 10; 8 | 9 | test('@arr/every', t => { 10 | const a = fn(foo, isBigEnough); 11 | t.equal(a, foo.every(isBigEnough), 'matches native output'); 12 | t.equal(a, false, 'is expected output'); 13 | 14 | const b = fn(bar, isBigEnough); 15 | t.equal(b, bar.every(isBigEnough), 'matches native output'); 16 | t.equal(b, true, 'is expected output'); 17 | t.end(); 18 | }); 19 | 20 | test('@arr/every - callback', t => { 21 | fn(foo, (val, idx, arr) => { 22 | t.equal(val, 12, 'receives current value as 1st param'); 23 | t.equal(idx, 0, 'receives current index as 2nd param'); 24 | t.deepEqual(arr, foo, 'receives array as 3rd param'); 25 | return false; // early exit 26 | }); 27 | t.end(); 28 | }); 29 | -------------------------------------------------------------------------------- /tests/filter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/filter'); 4 | 5 | const foo = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; 6 | 7 | test('@arr/filter', t => { 8 | const bar = foo.slice(); 9 | const a = fn(bar, str => str > 3); 10 | const b = bar.filter(str => str > 3); 11 | t.deepEqual(a, b, 'matches native output'); 12 | t.deepEqual(a, [4,5,6,7,8,9], 'filters correct output'); 13 | t.deepEqual(bar, foo, 'does NOT mutate the original array!'); 14 | t.notDeepEqual(a, bar, 'output differs from original'); 15 | t.end(); 16 | }); 17 | 18 | test('@arr/filter - callback', t => { 19 | const bar = [4, 5, 6]; 20 | let x=0, y=bar[x]; 21 | fn(bar, (val, idx, arr) => { 22 | t.equal(val, y, 'receives current value as 1st param (left-right)'); 23 | t.equal(idx, x, 'receives current index as 2nd param (head-first)'); 24 | t.deepEqual(arr, bar, 'receives array as 3rd param'); 25 | x++; y++; 26 | }); 27 | t.end(); 28 | }); 29 | -------------------------------------------------------------------------------- /tests/filter.mutate.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/filter.mutate'); 4 | 5 | const foo = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; 6 | 7 | test('@arr/filter.mutate', t => { 8 | const bar = foo.slice(); 9 | const a = fn(bar, str => str > 3); 10 | const b = bar.filter(str => str > 3); 11 | t.deepEqual(a, b, 'matches native output'); 12 | t.deepEqual(a, [4,5,6,7,8,9], 'filters correct output'); 13 | t.notDeepEqual(bar, foo, 'mutates the original array!'); 14 | t.deepEqual(a, bar, 'verifies the mutated output'); 15 | t.end(); 16 | }); 17 | 18 | test('@arr/filter.mutate - callback', t => { 19 | const bar = [4, 5, 6]; 20 | let x=6, y=2; 21 | fn(bar, (val, idx, arr) => { 22 | t.equal(val, x, 'receives current value as 1st param (right-left)'); 23 | t.equal(idx, y, 'receives current index as 2nd param (tail-first)'); 24 | t.deepEqual(arr, bar, 'receives array as 3rd param'); 25 | x--; y--; 26 | }); 27 | t.end(); 28 | }); 29 | -------------------------------------------------------------------------------- /tests/find.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/find'); 4 | 5 | const cb = x => x > 15; 6 | const foo = [12, 5, 8, 130, 44]; 7 | 8 | test('@arr/find', t => { 9 | const a = fn(foo, cb); 10 | t.equal(a, foo.find(cb), 'matches native output'); 11 | t.equal(a, 130, 'is expected output'); 12 | t.end(); 13 | }); 14 | 15 | test('@arr/find - callback', t => { 16 | fn(foo, (val, idx, arr) => { 17 | t.equal(val, 12, 'receives current value as 1st param'); 18 | t.equal(idx, 0, 'receives current index as 2nd param'); 19 | t.deepEqual(arr, foo, 'receives array as 3rd param'); 20 | return true; // early exit 21 | }); 22 | t.end(); 23 | }); 24 | -------------------------------------------------------------------------------- /tests/findIndex.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/findIndex'); 4 | 5 | const cb = x => x > 15; 6 | const foo = [12, 5, 8, 130, 44]; 7 | 8 | test('@arr/findIndex', t => { 9 | const a = fn(foo, cb); 10 | t.equal(a, foo.findIndex(cb), 'matches native output'); 11 | t.equal(a, 3, 'is expected output'); 12 | t.end(); 13 | }); 14 | 15 | test('@arr/findIndex - callback', t => { 16 | fn(foo, (val, idx, arr) => { 17 | t.equal(val, 12, 'receives current value as 1st param'); 18 | t.equal(idx, 0, 'receives current index as 2nd param'); 19 | t.deepEqual(arr, foo, 'receives array as 3rd param'); 20 | return true; // early exit 21 | }); 22 | t.end(); 23 | }); 24 | -------------------------------------------------------------------------------- /tests/flatten.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/flatten'); 4 | 5 | const foo = ['a', 'b', ['c'], 'd', ['e']]; 6 | const bar = ['a', [[[[[[[['b', [['c']]]]]]], 'd']]], 'e']; 7 | const baz = ['a', 'b', ['c'], 'd', ['e']]; 8 | const bat = [['a', ['b', ['k', ['a', ['b', ['c'], [['a', [['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]], ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]], ['a', ['x', ['c'], ['a', ['x', ['k']], [['a', ['b', ['k', ['a', ['b', ['c']], ['a', ['x', ['c'], ['a', ['x', ['k']]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]], ['d', ['z']]]], ['d', ['m']]], ['d', ['e']]]]], ['d', ['e']]]; 9 | 10 | test('@arr/flatten', t => { 11 | t.deepEqual(fn(foo), ['a', 'b', 'c', 'd', 'e']); 12 | t.deepEqual(fn(bar), ['a', 'b', 'c', 'd', 'e']); 13 | t.deepEqual(fn(baz), ['a', 'b', 'c', 'd', 'e']); 14 | t.deepEqual(fn(bat), [ 'a', 'b', 'k', 'a', 'b', 'c', 'a', 'a', 'b', 'k', 'a', 'b', 'c', 'a', 'x', 'c', 'a', 'x', 'k', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e', 'b', 'k', 'a', 'b', 'c', 'a', 'x', 'c', 'a', 'x', 'k', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e', 'a', 'x', 'c', 'a', 'x', 'k', 'a', 'b', 'k', 'a', 'b', 'c', 'a', 'x', 'c', 'a', 'x', 'k', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e', 'd', 'z', 'd', 'm', 'd', 'e', 'd', 'e' ]); 15 | t.end(); 16 | }); 17 | -------------------------------------------------------------------------------- /tests/forEach.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/forEach'); 4 | 5 | const foo = ['a', 'b', 'c']; 6 | const bar = ['a', undefined, void 0, , 'b']; 7 | 8 | test('@arr/forEach', t => { 9 | let x='', y=''; 10 | 11 | fn(foo, (val, idx, arr) => { 12 | x += `${val}-${idx}-${arr.length}`; 13 | }); 14 | 15 | foo.forEach((val, idx, arr) => { 16 | y += `${val}-${idx}-${arr.length}`; 17 | }); 18 | 19 | t.equal(x, y, 'matches native output'); 20 | t.equal(x, 'a-0-3b-1-3c-2-3', 'is expected output'); 21 | 22 | let a = 0; 23 | fn(bar, _ => a++); 24 | t.equal(a, bar.length, 'iterates thru all slots; incl `undefined` & holes'); 25 | 26 | let b = 0; 27 | bar.forEach(_ => b++); 28 | t.notEqual(b, a, 'does not match native behavior; re: holes & undefined'); 29 | t.equal(b, 4, 'native iterates all except holes'); 30 | 31 | t.end(); 32 | }); 33 | 34 | test('@arr/forEach - callback', t => { 35 | let i = 0; 36 | fn(foo, (val, idx, arr) => { 37 | t.equal(val, foo[i], 'receives current value as 1st param'); 38 | t.equal(idx, i, 'receives current index as 2nd param'); 39 | t.deepEqual(arr, foo, 'receives array as 3rd param'); 40 | i++; 41 | }); 42 | t.end(); 43 | }); 44 | -------------------------------------------------------------------------------- /tests/includes.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/includes'); 4 | 5 | const isRecent = parseFloat(process.version.substr(1)) > 6; 6 | 7 | const foo = ['a', 'b', 'c', 'd']; 8 | 9 | test('@arr/includes', t => { 10 | const a = fn(foo, 'c'); 11 | const b = fn(foo, 'g'); 12 | const c = fn(foo, 'b', 2); 13 | 14 | t.is(a, true, 'is expected output'); 15 | t.is(b, false, 'is expected output'); 16 | t.is(c, false, 'respects `fromIndex` param'); 17 | 18 | if (isRecent) { 19 | t.equal(a, foo.includes('c'), 'matches native output'); 20 | t.equal(b, foo.includes('g'), 'matches native output'); 21 | t.equal(c, foo.includes('b', 2), 'matches native output'); 22 | } 23 | 24 | t.end(); 25 | }); 26 | 27 | -------------------------------------------------------------------------------- /tests/map.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/map'); 4 | 5 | const dbl = x => x * 2; 6 | const foo = [1, 5, 10, 15]; 7 | const bar = ['a', undefined, void 0, , 'b']; 8 | 9 | test('@arr/map', t => { 10 | const a = fn(foo, dbl); 11 | const b = foo.map(dbl); 12 | t.deepEqual(a, b, 'matches native output'); 13 | t.deepEqual(a, [2,10,20,30], 'is expected output'); 14 | t.deepEqual(foo, [1,5,10,15], 'original array remains'); 15 | 16 | let x = 0; 17 | fn(bar, _ => x++); 18 | t.equal(x, bar.length, 'iterates thru all slots; incl `undefined` & holes'); 19 | 20 | let y = 0; 21 | bar.map(_ => y++); 22 | t.notEqual(b, a, 'does not match native behavior; re: holes & undefined'); 23 | t.equal(y, 4, 'native iterates all except holes'); 24 | 25 | t.end(); 26 | }); 27 | 28 | test('@arr/map - callback', t => { 29 | const cb = (val, idx, arr) => `${val}-${idx}-${arr.length}`; 30 | const x = fn(foo, cb); 31 | const y = foo.map(cb); 32 | t.deepEqual(x, y, 'callback string matches'); 33 | t.deepEqual(x, ['1-0-4', '5-1-4', '10-2-4', '15-3-4'], 'is expected output'); 34 | 35 | let i = 0; 36 | fn(foo, (val, idx, arr) => { 37 | t.equal(val, foo[i], 'receives current value as 1st param'); 38 | t.equal(idx, i, 'receives current index as 2nd param'); 39 | t.deepEqual(arr, foo, 'receives array as 3rd param'); 40 | i++; 41 | }); 42 | t.end(); 43 | }); 44 | -------------------------------------------------------------------------------- /tests/reduce.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/reduce'); 4 | 5 | const foo = [0, 1, 2, 3]; 6 | const bar = [[0, 1], [2, 3], [4, 5]]; 7 | 8 | test('@arr/reduce', t => { 9 | const a = fn(foo, (x,y) => x + y); 10 | const b = foo.reduce((x,y) => x + y); 11 | t.equal(a, b, 'matches native output'); 12 | t.equal(a, 6, 'is expected output'); 13 | 14 | const x = fn(bar, (j,k) => j.concat(k), []); 15 | const y = bar.reduce((j,k) => j.concat(k), []); 16 | t.deepEqual(x, y, 'matches native output'); 17 | t.deepEqual(x, [0,1,2,3,4,5], 'is expected output'); 18 | t.end(); 19 | }); 20 | 21 | test('@arr/reduce - callback', t => { 22 | let i=1, sum=0; 23 | fn(foo, (acc, val, idx, arr) => { 24 | if (sum === 0) { 25 | t.equal(acc, foo[0], 'accumulator defaults to first item in array if not defined'); 26 | } 27 | t.equal(acc, sum, 'receives the accumulator as 1st param'); 28 | t.equal(val, foo[i], 'receives the current value as 2nd param'); 29 | t.equal(idx, i, 'receives the current index as 3rd param'); 30 | t.deepEqual(arr, foo, 'receives the array as 4th param'); 31 | i++; sum += val; 32 | return acc + val; 33 | }); 34 | t.end(); 35 | }); 36 | -------------------------------------------------------------------------------- /tests/reduceRight.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/reduceRight'); 4 | 5 | const foo = [0, 1, 2, 3]; 6 | const bar = [[0, 1], [2, 3], [4, 5]]; 7 | 8 | test('@arr/reduceRight', t => { 9 | const a = fn(foo, (x,y) => x + y); 10 | const b = foo.reduceRight((x,y) => x + y); 11 | t.equal(a, b, 'matches native output'); 12 | t.equal(a, 6, 'is expected output'); 13 | 14 | const x = fn(bar, (j,k) => j.concat(k), []); 15 | const y = bar.reduceRight((j,k) => j.concat(k), []); 16 | t.deepEqual(x, y, 'matches native output'); 17 | t.deepEqual(x, [4,5,2,3,0,1], 'is expected output'); 18 | t.end(); 19 | }); 20 | 21 | test('@arr/reduceRight - callback', t => { 22 | let i=foo.length - 2, sum=3; 23 | fn(foo, (acc, val, idx, arr) => { 24 | if (sum === 0) { 25 | t.equal(acc, 3, 'accumulator defaults to last item in array if not defined'); 26 | } 27 | t.equal(acc, sum, 'receives the accumulator as 1st param'); 28 | t.equal(val, foo[i], 'receives the current value as 2nd param'); 29 | t.equal(idx, i, 'receives the current index as 3rd param'); 30 | t.deepEqual(arr, foo, 'receives the array as 4th param'); 31 | i--; sum += val; 32 | return acc + val; 33 | }); 34 | t.end(); 35 | }); 36 | -------------------------------------------------------------------------------- /tests/reverse.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/reverse'); 4 | 5 | const foo = [5, 6, 7, 8, 9]; 6 | 7 | test('@arr/reverse', t => { 8 | const a = foo.slice(); 9 | const b = foo.slice(); 10 | 11 | const x = fn(a); 12 | const y = b.reverse(); 13 | 14 | t.deepEqual(x, y, 'matches native output'); 15 | t.deepEqual(x, [9,8,7,6,5], 'is expected output'); 16 | t.deepEqual(a, x, 'mutates the original array'); 17 | t.deepEqual(b, y, 'native also mutates orig'); 18 | 19 | t.end(); 20 | }); 21 | -------------------------------------------------------------------------------- /tests/some.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/some'); 4 | 5 | const isBiggerThan10 = x => x > 10; 6 | const foo = [12, 5, 8, 1, 4]; 7 | const bar = [2, 5, 8, 1, 4]; 8 | 9 | test('@arr/some', t => { 10 | const a = fn(foo, isBiggerThan10); 11 | t.equal(a, foo.some(isBiggerThan10), 'matches native output'); 12 | t.equal(a, true, 'is expected output'); 13 | 14 | const b = fn(bar, isBiggerThan10); 15 | t.equal(b, bar.some(isBiggerThan10), 'matches native output'); 16 | t.equal(b, false, 'is expected output'); 17 | 18 | t.end(); 19 | }); 20 | 21 | test('@arr/some - callback', t => { 22 | let i = 0; 23 | fn(foo, (val, idx, arr) => { 24 | t.equal(val, foo[i], 'receives current value as 1st param'); 25 | t.equal(idx, i, 'receives current index as 2nd param'); 26 | t.deepEqual(arr, foo, 'receives array as 3rd param'); 27 | i++; 28 | }); 29 | t.end(); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/unique.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('tape'); 3 | const fn = require('../packages/unique'); 4 | 5 | const foo = ['a', 'b', 'c', 'a', 'b', 'd']; 6 | const bar = [1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 7, 2, 8]; 7 | 8 | test('@arr/unique', t => { 9 | t.deepEqual(fn(foo), ['a', 'b', 'c', 'd']); 10 | t.deepEqual(fn(bar), [1, 2, 3, 4, 5, 6, 7, 8]); 11 | t.end(); 12 | }); 13 | --------------------------------------------------------------------------------