Skip to content

Commit

Permalink
docs: add buf-compare replacement (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
stramel authored Nov 13, 2024
1 parent 928dbe8 commit 7dea6e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ESLint plugin.

- [`@jsdevtools/ez-spawn`](./process-exec.md)
- [`bluebird` / `q`](./bluebird-q.md)
- [`buf-compare`](./buf-compare.md)
- [`buffer-equal` / `buffer-equals`](./buffer-equal.md)
- [`cpx`](./cpx.md)
- [`deep-equal`](./deep-equal.md)
Expand Down
21 changes: 21 additions & 0 deletions docs/modules/buf-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# buf-compare

[`buf-compare`](https://github.com/sindresorhus/buf-compare) recommends that you switch to native `Buffer.compare()` which has been available since Node.js v0.12.0

# Alternatives

## NodeJS

```js
import {Buffer} from 'node:buffer';

const buf1 = Buffer.from('1234');
const buf2 = Buffer.from('0123');
const arr = [buf1, buf2];

console.log(arr.sort(Buffer.compare));
// Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]
// (This result is equal to: [buf2, buf1].)
```

[Node.js Docs](https://nodejs.org/api/buffer.html#static-method-buffercomparebuf1-buf2)
6 changes: 6 additions & 0 deletions manifests/preferred.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"docPath": "bluebird-q",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "buf-compare",
"docPath": "buf-compare",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "buffer-equal",
Expand Down

0 comments on commit 7dea6e8

Please sign in to comment.