Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anonrig/fast-array-join
61% faster array join for JavaScript.
https://github.com/anonrig/fast-array-join
array javascript
Last synced: 27 days ago
JSON representation
61% faster array join for JavaScript.
- Host: GitHub
- URL: https://github.com/anonrig/fast-array-join
- Owner: anonrig
- License: mit
- Created: 2022-11-24T19:04:18.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-25T19:20:36.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T05:54:43.258Z (6 months ago)
- Topics: array, javascript
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fast-array-join
[![NPM version](https://img.shields.io/npm/v/fast-array-join.svg?style=flat)](https://www.npmjs.com/package/fast-array-join)
`fast-array-join` is a %61 faster array join function compared to `Array.prototype.join`.
Taken from [Node.js repository](https://github.com/nodejs/node/blob/main/lib/internal/util.js#L388) and authored by [@BridgeAR](http://github.com/BridgeAR)
### Installation
```
npm i fast-array-join
```### Usage
```javascript
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 % ║
╚══════════════════════╧═════════╧══════════════════╧═══════════╝```
```