1.0.0 • Published 1 year ago

fast-array-join v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

fast-array-join

NPM version

fast-array-join is a %61 faster array join function compared to Array.prototype.join.

Taken from Node.js repository and authored by @BridgeAR

Installation

npm i fast-array-join

Usage

const fastJoin = require('fast-array-join')

const input = ['hello', 'world']

console.log(fastJoin(input, ' '))
// "hello world"

Benchmark

> node benchmark/native-vs-js.mjs

╔══════════════════════╤═════════╤══════════════════╤═══════════╗
║ Slower tests         │ Samples │           Result │ Tolerance ║
╟──────────────────────┼─────────┼──────────────────┼───────────╢
║ Array.prototype.join │    4500 │  96622.01 op/sec │  ± 1.00 % ║
╟──────────────────────┼─────────┼──────────────────┼───────────╢
║ Fastest test         │ Samples │           Result │ Tolerance ║
╟──────────────────────┼─────────┼──────────────────┼───────────╢
║ fast-array-join      │   10000 │ 155072.20 op/sec │  ± 2.08 % ║
╚══════════════════════╧═════════╧══════════════════╧═══════════╝```