uint8arrays
Advanced tools
Comparing version 5.0.3 to 5.1.0
@@ -144,2 +144,22 @@ /** | ||
* ``` | ||
* | ||
* ## xorCompare(a, b) | ||
* | ||
* Compares the distances between two xor `Uint8Array`s. | ||
* | ||
* ### Example | ||
* | ||
* ```ts | ||
* import { xor } from 'uint8arrays/xor' | ||
* import { xorCompare } from 'uint8arrays/xor-compare' | ||
* | ||
* const target = Uint8Array.from([1, 1]) | ||
* const val1 = Uint8Array.from([1, 0]) | ||
* const xor1 = xor(target, val1) | ||
* | ||
* const val2 = Uint8Array.from([0, 1]) | ||
* const xor2 = xor(target, val2) | ||
* | ||
* console.info(xorCompare(xor1, xor2)) // -1 or 0 or 1 | ||
* ``` | ||
*/ | ||
@@ -146,0 +166,0 @@ import { equals } from './equals.js'; |
@@ -144,2 +144,22 @@ /** | ||
* ``` | ||
* | ||
* ## xorCompare(a, b) | ||
* | ||
* Compares the distances between two xor `Uint8Array`s. | ||
* | ||
* ### Example | ||
* | ||
* ```ts | ||
* import { xor } from 'uint8arrays/xor' | ||
* import { xorCompare } from 'uint8arrays/xor-compare' | ||
* | ||
* const target = Uint8Array.from([1, 1]) | ||
* const val1 = Uint8Array.from([1, 0]) | ||
* const xor1 = xor(target, val1) | ||
* | ||
* const val2 = Uint8Array.from([0, 1]) | ||
* const xor2 = xor(target, val2) | ||
* | ||
* console.info(xorCompare(xor1, xor2)) // -1 or 0 or 1 | ||
* ``` | ||
*/ | ||
@@ -146,0 +166,0 @@ import { equals } from './equals.js'; |
/** | ||
* Returns the xor distance between two arrays | ||
* Returns the xor distance between two Uint8Arrays | ||
*/ | ||
export declare function xor(a: Uint8Array, b: Uint8Array): Uint8Array; | ||
//# sourceMappingURL=xor.d.ts.map |
import { allocUnsafe } from '#alloc'; | ||
import { asUint8Array } from '#util/as-uint8array'; | ||
/** | ||
* Returns the xor distance between two arrays | ||
* Returns the xor distance between two Uint8Arrays | ||
*/ | ||
@@ -6,0 +6,0 @@ export function xor(a, b) { |
@@ -17,3 +17,5 @@ { | ||
"xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html", | ||
"./xor:xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html" | ||
"./xor:xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html", | ||
"xorCompare": "https://achingbrain.github.io/uint8arrays/functions/xor_compare.xorCompare.html", | ||
"./xor-compare:xorCompare": "https://achingbrain.github.io/uint8arrays/functions/xor_compare.xorCompare.html" | ||
} |
{ | ||
"name": "uint8arrays", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "Utility functions to make dealing with Uint8Arrays easier", | ||
@@ -80,2 +80,6 @@ "author": "Alex Potsides <alex@achingbrain.net>", | ||
"import": "./dist/src/xor.js" | ||
}, | ||
"./xor-compare": { | ||
"types": "./dist/src/xor-compare.d.ts", | ||
"import": "./dist/src/xor-compare.js" | ||
} | ||
@@ -82,0 +86,0 @@ }, |
@@ -0,1 +1,3 @@ | ||
# uint8arrays | ||
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/uint8arrays.svg?style=flat-square)](https://codecov.io/gh/achingbrain/uint8arrays) | ||
@@ -164,2 +166,22 @@ [![CI](https://img.shields.io/github/actions/workflow/status/achingbrain/uint8arrays/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/achingbrain/uint8arrays/actions/workflows/js-test-and-release.yml?query=branch%3Amain) | ||
## xorCompare(a, b) | ||
Compares the distances between two xor `Uint8Array`s. | ||
### Example | ||
```ts | ||
import { xor } from 'uint8arrays/xor' | ||
import { xorCompare } from 'uint8arrays/xor-compare' | ||
const target = Uint8Array.from([1, 1]) | ||
const val1 = Uint8Array.from([1, 0]) | ||
const xor1 = xor(target, val1) | ||
const val2 = Uint8Array.from([0, 1]) | ||
const xor2 = xor(target, val2) | ||
console.info(xorCompare(xor1, xor2)) // -1 or 0 or 1 | ||
``` | ||
# Install | ||
@@ -166,0 +188,0 @@ |
@@ -144,2 +144,22 @@ /** | ||
* ``` | ||
* | ||
* ## xorCompare(a, b) | ||
* | ||
* Compares the distances between two xor `Uint8Array`s. | ||
* | ||
* ### Example | ||
* | ||
* ```ts | ||
* import { xor } from 'uint8arrays/xor' | ||
* import { xorCompare } from 'uint8arrays/xor-compare' | ||
* | ||
* const target = Uint8Array.from([1, 1]) | ||
* const val1 = Uint8Array.from([1, 0]) | ||
* const xor1 = xor(target, val1) | ||
* | ||
* const val2 = Uint8Array.from([0, 1]) | ||
* const xor2 = xor(target, val2) | ||
* | ||
* console.info(xorCompare(xor1, xor2)) // -1 or 0 or 1 | ||
* ``` | ||
*/ | ||
@@ -146,0 +166,0 @@ |
@@ -5,3 +5,3 @@ import { allocUnsafe } from '#alloc' | ||
/** | ||
* Returns the xor distance between two arrays | ||
* Returns the xor distance between two Uint8Arrays | ||
*/ | ||
@@ -8,0 +8,0 @@ export function xor (a: Uint8Array, b: Uint8Array): Uint8Array { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
83335
90
1259
214