Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add buf-compare replacement #181

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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