import { compare } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/bytes/index.js";
Like Buffer.compare
but for native Uint8Array
.
Examples
Example 1
Example 1
import { compare } from "@ayonli/jsext/bytes";
const arr1 = new Uint8Array([1, 2, 3]);
const arr2 = new Uint8Array([1, 2, 4]);
const arr3 = new Uint8Array([1, 2, 3, 4]);
const arr4 = new Uint8Array([1, 2, 3]);
const arr5 = new Uint8Array([1, 2]);
console.log(compare(arr1, arr2)); // -1
console.log(compare(arr1, arr3)); // -1
console.log(compare(arr1, arr4)); // 0
console.log(compare(arr1, arr5)); // 1