Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 579 Bytes

buf-compare.md

File metadata and controls

21 lines (14 loc) · 579 Bytes

buf-compare

buf-compare recommends that you switch to native Buffer.compare() which has been available since Node.js v0.12.0

Alternatives

NodeJS

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