ordered-binary 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.cjs +352 -332
- package/index.d.ts +23 -0
- package/index.js +352 -332
- package/package.json +2 -2
- package/tests/test.js +128 -128
- package/uuid.js +110 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Key = Key[] | string | symbol | number | boolean | Uint8Array;
|
|
2
|
+
/** Writes a key (a primitive value) to the target buffer, starting at the given position */
|
|
3
|
+
export function writeKey(key: Key, target: Uint8Array, position: number, inSequence?: boolean): number;
|
|
4
|
+
/** Reads a key from the provided buffer, from the given range */
|
|
5
|
+
export function readKey(buffer: Uint8Array, start: number, end?: number, inSequence?: boolean): Key;
|
|
6
|
+
/** Converts key to a Buffer. This is generally much slower than using writeKey since it involves a full buffer allocation, and should be avoided for performance sensitive code. */
|
|
7
|
+
export function toBufferKey(key: Key): Buffer;
|
|
8
|
+
/** Converts Buffer to Key */
|
|
9
|
+
export function fromBufferKey(source: Buffer): Key;
|
|
10
|
+
/** Compares two keys, returning -1 if `a` comes before `b` in the ordered binary representation of the keys, or 1 if `a` comes after `b`, or 0 if they are equivalent */
|
|
11
|
+
export function compareKeys(a: Key, b: Key): number;
|
|
12
|
+
/** The minimum key, with the "first" binary representation (one byte of zero) */
|
|
13
|
+
export const MINIMUM_KEY: null
|
|
14
|
+
/** A maximum key, with a binary representation after all other JS primitives (one byte of 0xff) */
|
|
15
|
+
export const MAXIMUM_KEY: Uint8Array
|
|
16
|
+
/** Enables null termination, ensuring that writing keys to buffers will end with a padding of zeros at the end to complete the following 32-bit word */
|
|
17
|
+
export function enableNullTermination(): void;
|
|
18
|
+
/** An object that holds the functions for encapsulation as a single encoder */
|
|
19
|
+
export const encoder: {
|
|
20
|
+
writeKey: typeof writeKey,
|
|
21
|
+
readKey: typeof readKey,
|
|
22
|
+
enableNullTermination: typeof enableNullTermination,
|
|
23
|
+
}
|