Add comprehensive installation and setup documentation

- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
This commit is contained in:
Dorian
2026-01-27 17:18:21 +00:00
parent a81f655133
commit 0d073fa89e
22658 changed files with 4494151 additions and 6 deletions
File diff suppressed because one or more lines are too long
+12
View File
@@ -0,0 +1,12 @@
/**
* Returns a `Uint8Array` of the requested size. Referenced memory will
* be initialized to 0.
*/
export declare function alloc(size?: number): Uint8Array;
/**
* Where possible returns a Uint8Array of the requested size that references
* uninitialized memory. Only use if you are certain you will immediately
* overwrite every value in the returned `Uint8Array`.
*/
export declare function allocUnsafe(size?: number): Uint8Array;
//# sourceMappingURL=alloc.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"alloc.d.ts","sourceRoot":"","sources":["../../src/alloc.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,KAAK,CAAE,IAAI,GAAE,MAAU,GAAG,UAAU,CAMnD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAE,IAAI,GAAE,MAAU,GAAG,UAAU,CAMzD"}
+23
View File
@@ -0,0 +1,23 @@
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns a `Uint8Array` of the requested size. Referenced memory will
* be initialized to 0.
*/
export function alloc(size = 0) {
if (globalThis.Buffer?.alloc != null) {
return asUint8Array(globalThis.Buffer.alloc(size));
}
return new Uint8Array(size);
}
/**
* Where possible returns a Uint8Array of the requested size that references
* uninitialized memory. Only use if you are certain you will immediately
* overwrite every value in the returned `Uint8Array`.
*/
export function allocUnsafe(size = 0) {
if (globalThis.Buffer?.allocUnsafe != null) {
return asUint8Array(globalThis.Buffer.allocUnsafe(size));
}
return new Uint8Array(size);
}
//# sourceMappingURL=alloc.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"alloc.js","sourceRoot":"","sources":["../../src/alloc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAE,OAAe,CAAC;IACrC,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACrC,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAE,OAAe,CAAC;IAC3C,IAAI,UAAU,CAAC,MAAM,EAAE,WAAW,IAAI,IAAI,EAAE,CAAC;QAC3C,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1D,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Can be used with Array.sort to sort and array with Uint8Array entries
*/
export declare function compare(a: Uint8Array, b: Uint8Array): number;
//# sourceMappingURL=compare.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/compare.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,OAAO,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,MAAM,CAwB7D"}
+24
View File
@@ -0,0 +1,24 @@
/**
* Can be used with Array.sort to sort and array with Uint8Array entries
*/
export function compare(a, b) {
if (globalThis.Buffer != null) {
return globalThis.Buffer.compare(a, b);
}
for (let i = 0; i < a.byteLength; i++) {
if (a[i] < b[i]) {
return -1;
}
if (a[i] > b[i]) {
return 1;
}
}
if (a.byteLength > b.byteLength) {
return 1;
}
if (a.byteLength < b.byteLength) {
return -1;
}
return 0;
}
//# sourceMappingURL=compare.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/compare.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,OAAO,CAAE,CAAa,EAAE,CAAa;IACnD,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC,CAAA;QACX,CAAC;QAED,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO,CAAC,CAAA;QACV,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,CAAA;IACV,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
*/
export declare function concat(arrays: Array<ArrayLike<number>>, length?: number): Uint8Array;
//# sourceMappingURL=concat.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../src/concat.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,MAAM,CAAE,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAcrF"}
+18
View File
@@ -0,0 +1,18 @@
import { allocUnsafe } from './alloc.js';
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
*/
export function concat(arrays, length) {
if (length == null) {
length = arrays.reduce((acc, curr) => acc + curr.length, 0);
}
const output = allocUnsafe(length);
let offset = 0;
for (const arr of arrays) {
output.set(arr, offset);
offset += arr.length;
}
return asUint8Array(output);
}
//# sourceMappingURL=concat.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../src/concat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,MAAgC,EAAE,MAAe;IACvE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACvB,MAAM,IAAI,GAAG,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Returns true if the two passed Uint8Arrays have the same content
*/
export declare function equals(a: Uint8Array, b: Uint8Array): boolean;
//# sourceMappingURL=equals.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../src/equals.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAgB7D"}
+18
View File
@@ -0,0 +1,18 @@
/**
* Returns true if the two passed Uint8Arrays have the same content
*/
export function equals(a, b) {
if (a === b) {
return true;
}
if (a.byteLength !== b.byteLength) {
return false;
}
for (let i = 0; i < a.byteLength; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
//# sourceMappingURL=equals.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"equals.js","sourceRoot":"","sources":["../../src/equals.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,CAAa,EAAE,CAAa;IAClD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAClB,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
+11
View File
@@ -0,0 +1,11 @@
import { type SupportedEncodings } from './util/bases.js';
export type { SupportedEncodings };
/**
* Create a `Uint8Array` from the passed string
*
* Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export declare function fromString(string: string, encoding?: SupportedEncodings): Uint8Array;
//# sourceMappingURL=from-string.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"from-string.d.ts","sourceRoot":"","sources":["../../src/from-string.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEhE,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,kBAA2B,GAAG,UAAU,CAa7F"}
+21
View File
@@ -0,0 +1,21 @@
import { asUint8Array } from './util/as-uint8array.js';
import bases, {} from './util/bases.js';
/**
* Create a `Uint8Array` from the passed string
*
* Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export function fromString(string, encoding = 'utf8') {
const base = bases[encoding];
if (base == null) {
throw new Error(`Unsupported encoding "${encoding}"`);
}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return asUint8Array(globalThis.Buffer.from(string, 'utf-8'));
}
// add multibase prefix
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
}
//# sourceMappingURL=from-string.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"from-string.js","sourceRoot":"","sources":["../../src/from-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,EAA2B,MAAM,iBAAiB,CAAA;AAIhE;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAE,MAAc,EAAE,WAA+B,MAAM;IAC/E,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE5B,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,GAAG,CAAC,CAAA;IACvD,CAAC;IAED,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACjH,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,uBAAuB;IACvB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA,CAAC,uEAAuE;AAC/H,CAAC"}
+153
View File
@@ -0,0 +1,153 @@
/**
* @packageDocumentation
*
* `Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.
*
* This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.
*
* Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.
*
* ## alloc(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* ### Example
*
* ```js
* import { alloc } from 'uint8arrays/alloc'
*
* const buf = alloc(100)
* ```
*
* ## allocUnsafe(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.
*
* ### Example
*
* ```js
* import { allocUnsafe } from 'uint8arrays/alloc'
*
* const buf = allocUnsafe(100)
* ```
*
* ## compare(a, b)
*
* Compare two `Uint8Arrays`
*
* ### Example
*
* ```js
* import { compare } from 'uint8arrays/compare'
*
* const arrays = [
* Uint8Array.from([3, 4, 5]),
* Uint8Array.from([0, 1, 2])
* ]
*
* const sorted = arrays.sort(compare)
*
* console.info(sorted)
* // [
* // Uint8Array[0, 1, 2]
* // Uint8Array[3, 4, 5]
* // ]
* ```
*
* ## concat(arrays, \[length])
*
* Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.
*
* If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.
*
* ### Example
*
* ```js
* import { concat } from 'uint8arrays/concat'
*
* const arrays = [
* Uint8Array.from([0, 1, 2]),
* Uint8Array.from([3, 4, 5])
* ]
*
* const all = concat(arrays, 6)
*
* console.info(all)
* // Uint8Array[0, 1, 2, 3, 4, 5]
* ```
*
* ## equals(a, b)
*
* Returns true if the two arrays are the same array or if they have the same length and contents.
*
* ### Example
*
* ```js
* import { equals } from 'uint8arrays/equals'
*
* const a = Uint8Array.from([0, 1, 2])
* const b = Uint8Array.from([3, 4, 5])
* const c = Uint8Array.from([0, 1, 2])
*
* console.info(equals(a, b)) // false
* console.info(equals(a, c)) // true
* console.info(equals(a, a)) // true
* ```
*
* ## fromString(string, encoding = 'utf8')
*
* Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { fromString } from 'uint8arrays/from-string'
*
* console.info(fromString('hello world')) // Uint8Array[104, 101 ...
* console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...
* console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...
* console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...
* ```
*
* ## toString(array, encoding = 'utf8')
*
* Returns a string created from the passed `Uint8Array` in the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { toString } from 'uint8arrays/to-string'
*
* console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'
* console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'
* ```
*
* ## xor(a, b)
*
* Returns a `Uint8Array` containing `a` and `b` xored together.
*
* ### Example
*
* ```js
* import { xor } from 'uint8arrays/xor'
*
* console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]
* ```
*/
import { compare } from './compare.js';
import { concat } from './concat.js';
import { equals } from './equals.js';
import { fromString } from './from-string.js';
import { toString } from './to-string.js';
import { xor } from './xor.js';
export { compare, concat, equals, fromString, toString, xor };
export type { SupportedEncodings } from './util/bases.js';
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,GAAG,EACJ,CAAA;AAED,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA"}
+152
View File
@@ -0,0 +1,152 @@
/**
* @packageDocumentation
*
* `Uint8Array`s bring memory-efficient(ish) byte handling to browsers - they are similar to Node.js `Buffer`s but lack a lot of the utility methods present on that class.
*
* This module exports a number of function that let you do common operations - joining Uint8Arrays together, seeing if they have the same contents etc.
*
* Since Node.js `Buffer`s are also `Uint8Array`s, it falls back to `Buffer` internally where it makes sense for performance reasons.
*
* ## alloc(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* ### Example
*
* ```js
* import { alloc } from 'uint8arrays/alloc'
*
* const buf = alloc(100)
* ```
*
* ## allocUnsafe(size)
*
* Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
*
* On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.
*
* ### Example
*
* ```js
* import { allocUnsafe } from 'uint8arrays/alloc'
*
* const buf = allocUnsafe(100)
* ```
*
* ## compare(a, b)
*
* Compare two `Uint8Arrays`
*
* ### Example
*
* ```js
* import { compare } from 'uint8arrays/compare'
*
* const arrays = [
* Uint8Array.from([3, 4, 5]),
* Uint8Array.from([0, 1, 2])
* ]
*
* const sorted = arrays.sort(compare)
*
* console.info(sorted)
* // [
* // Uint8Array[0, 1, 2]
* // Uint8Array[3, 4, 5]
* // ]
* ```
*
* ## concat(arrays, \[length])
*
* Concatenate one or more `Uint8Array`s and return a `Uint8Array` with their contents.
*
* If you know the length of the arrays, pass it as a second parameter, otherwise it will be calculated by traversing the list of arrays.
*
* ### Example
*
* ```js
* import { concat } from 'uint8arrays/concat'
*
* const arrays = [
* Uint8Array.from([0, 1, 2]),
* Uint8Array.from([3, 4, 5])
* ]
*
* const all = concat(arrays, 6)
*
* console.info(all)
* // Uint8Array[0, 1, 2, 3, 4, 5]
* ```
*
* ## equals(a, b)
*
* Returns true if the two arrays are the same array or if they have the same length and contents.
*
* ### Example
*
* ```js
* import { equals } from 'uint8arrays/equals'
*
* const a = Uint8Array.from([0, 1, 2])
* const b = Uint8Array.from([3, 4, 5])
* const c = Uint8Array.from([0, 1, 2])
*
* console.info(equals(a, b)) // false
* console.info(equals(a, c)) // true
* console.info(equals(a, a)) // true
* ```
*
* ## fromString(string, encoding = 'utf8')
*
* Returns a new `Uint8Array` created from the passed string and interpreted as the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { fromString } from 'uint8arrays/from-string'
*
* console.info(fromString('hello world')) // Uint8Array[104, 101 ...
* console.info(fromString('00010203aabbcc', 'base16')) // Uint8Array[0, 1 ...
* console.info(fromString('AAECA6q7zA', 'base64')) // Uint8Array[0, 1 ...
* console.info(fromString('01234', 'ascii')) // Uint8Array[48, 49 ...
* ```
*
* ## toString(array, encoding = 'utf8')
*
* Returns a string created from the passed `Uint8Array` in the passed encoding.
*
* Supports `utf8` and any of the [multibase encodings](https://github.com/multiformats/multibase/blob/master/multibase.csv) as implemented by the [multiformats module](https://www.npmjs.com/package/multiformats).
*
* ### Example
*
* ```js
* import { toString } from 'uint8arrays/to-string'
*
* console.info(toString(Uint8Array.from([104, 101...]))) // 'hello world'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base16')) // '00010203aabbcc'
* console.info(toString(Uint8Array.from([0, 1, 2...]), 'base64')) // 'AAECA6q7zA'
* console.info(toString(Uint8Array.from([48, 49, 50...]), 'ascii')) // '01234'
* ```
*
* ## xor(a, b)
*
* Returns a `Uint8Array` containing `a` and `b` xored together.
*
* ### Example
*
* ```js
* import { xor } from 'uint8arrays/xor'
*
* console.info(xor(Uint8Array.from([1, 0]), Uint8Array.from([0, 1]))) // Uint8Array[1, 1]
* ```
*/
import { compare } from './compare.js';
import { concat } from './concat.js';
import { equals } from './equals.js';
import { fromString } from './from-string.js';
import { toString } from './to-string.js';
import { xor } from './xor.js';
export { compare, concat, equals, fromString, toString, xor };
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,GAAG,EACJ,CAAA"}
+11
View File
@@ -0,0 +1,11 @@
import { type SupportedEncodings } from './util/bases.js';
export type { SupportedEncodings };
/**
* Turns a `Uint8Array` into a string.
*
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export declare function toString(array: Uint8Array, encoding?: SupportedEncodings): string;
//# sourceMappingURL=to-string.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"to-string.d.ts","sourceRoot":"","sources":["../../src/to-string.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEhE,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,GAAE,kBAA2B,GAAG,MAAM,CAa1F"}
+20
View File
@@ -0,0 +1,20 @@
import bases, {} from './util/bases.js';
/**
* Turns a `Uint8Array` into a string.
*
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
export function toString(array, encoding = 'utf8') {
const base = bases[encoding];
if (base == null) {
throw new Error(`Unsupported encoding "${encoding}"`);
}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString('utf8');
}
// strip multibase prefix
return base.encoder.encode(array).substring(1);
}
//# sourceMappingURL=to-string.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"to-string.js","sourceRoot":"","sources":["../../src/to-string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA2B,MAAM,iBAAiB,CAAA;AAIhE;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAE,KAAiB,EAAE,WAA+B,MAAM;IAChF,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE5B,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,GAAG,CAAC,CAAA;IACvD,CAAC;IAED,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;QACjH,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAClG,CAAC;IAED,yBAAyB;IACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC"}
@@ -0,0 +1,6 @@
/**
* To guarantee Uint8Array semantics, convert nodejs Buffers
* into vanilla Uint8Arrays
*/
export declare function asUint8Array(buf: Uint8Array): Uint8Array;
//# sourceMappingURL=as-uint8array.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"as-uint8array.d.ts","sourceRoot":"","sources":["../../../src/util/as-uint8array.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,YAAY,CAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAMzD"}
+11
View File
@@ -0,0 +1,11 @@
/**
* To guarantee Uint8Array semantics, convert nodejs Buffers
* into vanilla Uint8Arrays
*/
export function asUint8Array(buf) {
if (globalThis.Buffer != null) {
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
}
return buf;
}
//# sourceMappingURL=as-uint8array.js.map
@@ -0,0 +1 @@
{"version":3,"file":"as-uint8array.js","sourceRoot":"","sources":["../../../src/util/as-uint8array.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAE,GAAe;IAC3C,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;IACnE,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
+6
View File
@@ -0,0 +1,6 @@
import { bases } from 'multiformats/basics';
import type { MultibaseCodec } from 'multiformats';
export type SupportedEncodings = 'utf8' | 'utf-8' | 'hex' | 'latin1' | 'ascii' | 'binary' | keyof typeof bases;
declare const BASES: Record<SupportedEncodings, MultibaseCodec<any>>;
export default BASES;
//# sourceMappingURL=bases.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"bases.d.ts","sourceRoot":"","sources":["../../../src/util/bases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AA2ClD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,OAAO,KAAK,CAAA;AAE9G,QAAA,MAAM,KAAK,EAAE,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,GAAG,CAAC,CAS1D,CAAA;AAED,eAAe,KAAK,CAAA"}
+48
View File
@@ -0,0 +1,48 @@
import { bases } from 'multiformats/basics';
import { allocUnsafe } from '../alloc.js';
function createCodec(name, prefix, encode, decode) {
return {
name,
prefix,
encoder: {
name,
prefix,
encode
},
decoder: {
decode
}
};
}
const string = createCodec('utf8', 'u', (buf) => {
const decoder = new TextDecoder('utf8');
return 'u' + decoder.decode(buf);
}, (str) => {
const encoder = new TextEncoder();
return encoder.encode(str.substring(1));
});
const ascii = createCodec('ascii', 'a', (buf) => {
let string = 'a';
for (let i = 0; i < buf.length; i++) {
string += String.fromCharCode(buf[i]);
}
return string;
}, (str) => {
str = str.substring(1);
const buf = allocUnsafe(str.length);
for (let i = 0; i < str.length; i++) {
buf[i] = str.charCodeAt(i);
}
return buf;
});
const BASES = {
utf8: string,
'utf-8': string,
hex: bases.base16,
latin1: ascii,
ascii,
binary: ascii,
...bases
};
export default BASES;
//# sourceMappingURL=bases.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"bases.js","sourceRoot":"","sources":["../../../src/util/bases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAGzC,SAAS,WAAW,CAAE,IAAY,EAAE,MAAc,EAAE,MAAmC,EAAE,MAAmC;IAC1H,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO,EAAE;YACP,IAAI;YACJ,MAAM;YACN,MAAM;SACP;QACD,OAAO,EAAE;YACP,MAAM;SACP;KACF,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;IAC9C,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;IACvC,OAAO,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAClC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;IACT,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;IACjC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;AACzC,CAAC,CAAC,CAAA;AAEF,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;IAC9C,IAAI,MAAM,GAAG,GAAG,CAAA;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;IACT,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACtB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAC,CAAA;AAIF,MAAM,KAAK,GAAoD;IAC7D,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,KAAK,CAAC,MAAM;IACjB,MAAM,EAAE,KAAK;IACb,KAAK;IACL,MAAM,EAAE,KAAK;IAEb,GAAG,KAAK;CACT,CAAA;AAED,eAAe,KAAK,CAAA"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Returns the xor distance between two arrays
*/
export declare function xor(a: Uint8Array, b: Uint8Array): Uint8Array;
//# sourceMappingURL=xor.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"xor.d.ts","sourceRoot":"","sources":["../../src/xor.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAY7D"}
+16
View File
@@ -0,0 +1,16 @@
import { allocUnsafe } from './alloc.js';
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns the xor distance between two arrays
*/
export function xor(a, b) {
if (a.length !== b.length) {
throw new Error('Inputs should have the same length');
}
const result = allocUnsafe(a.length);
for (let i = 0; i < a.length; i++) {
result[i] = a[i] ^ b[i];
}
return asUint8Array(result);
}
//# sourceMappingURL=xor.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"xor.js","sourceRoot":"","sources":["../../src/xor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;GAEG;AACH,MAAM,UAAU,GAAG,CAAE,CAAa,EAAE,CAAa;IAC/C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAEpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC"}
+18
View File
@@ -0,0 +1,18 @@
{
"alloc": "https://achingbrain.github.io/uint8arrays/functions/alloc.alloc.html",
"./alloc:alloc": "https://achingbrain.github.io/uint8arrays/functions/alloc.alloc.html",
"allocUnsafe": "https://achingbrain.github.io/uint8arrays/functions/alloc.allocUnsafe.html",
"./alloc:allocUnsafe": "https://achingbrain.github.io/uint8arrays/functions/alloc.allocUnsafe.html",
"compare": "https://achingbrain.github.io/uint8arrays/functions/compare.compare.html",
"./compare:compare": "https://achingbrain.github.io/uint8arrays/functions/compare.compare.html",
"concat": "https://achingbrain.github.io/uint8arrays/functions/concat.concat.html",
"./concat:concat": "https://achingbrain.github.io/uint8arrays/functions/concat.concat.html",
"equals": "https://achingbrain.github.io/uint8arrays/functions/equals.equals.html",
"./equals:equals": "https://achingbrain.github.io/uint8arrays/functions/equals.equals.html",
"fromString": "https://achingbrain.github.io/uint8arrays/functions/from_string.fromString.html",
"./from-string:fromString": "https://achingbrain.github.io/uint8arrays/functions/from_string.fromString.html",
"SupportedEncodings": "https://achingbrain.github.io/uint8arrays/types/index.SupportedEncodings.html",
"./to-string:toString": "https://achingbrain.github.io/uint8arrays/functions/to_string.toString.html",
"xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html",
"./xor:xor": "https://achingbrain.github.io/uint8arrays/functions/xor.xor.html"
}