Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/uint8array/index.js>compare

A JavaScript extension package for building strong and modern applications.
Latest
function compare
import { compare } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/uint8array/index.js";

Like Buffer.compare but for native Uint8Array.

Examples

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

Parameters

arr1
arr2