ordered-binary 1.2.3 → 1.2.4

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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/index.d.ts +19 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -32,3 +32,8 @@ The main module exports these functions:
32
32
  `toBufferKey(jsPrimitive)` - This accepts a string, number, or boolean as the argument, and returns a `Buffer`.
33
33
 
34
34
  `fromBufferKey(bufferKey, multiple)` - This accepts a Buffer and returns a JavaScript primitive value. This can also parse buffers that hold multiple values delimited by a byte `30`, by setting the second argument to true (in which case it will return an array).
35
+
36
+ And these constants:
37
+
38
+ `MINIMUM_KEY` - The minimum key supported (`null`, which is represented as single zero byte)
39
+ `MAXIMUM_KEY` - A maximum key larger than any supported primitive (single 0xff byte)
package/index.d.ts ADDED
@@ -0,0 +1,19 @@
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
+ /** 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 */
7
+ export function compareKeys(a: Key, b: Key): number;
8
+ /** The minimum key, with the "first" binary representation (one byte of zero) */
9
+ export const MINIMUM_KEY: null
10
+ /** A maximum key, with a binary representation after all other JS primitives (one byte of 0xff) */
11
+ export const MAXIMUM_KEY: Uint8Array
12
+ /** 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 */
13
+ export function enableNullTermination(): void;
14
+ /** An object that holds the functions for encapsulation as a single encoder */
15
+ export const encoder: {
16
+ writeKey: typeof writeKey,
17
+ readKey: typeof readKey,
18
+ enableNullTermination: typeof enableNullTermination,
19
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ordered-binary",
3
3
  "author": "Kris Zyp",
4
- "version": "1.2.3",
4
+ "version": "1.2.4",
5
5
  "description": "Conversion of JavaScript primitives to and from Buffer with binary order matching natural primitive order",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@types/node": "latest",
33
33
  "chai": "^4",
34
- "mocha": "^9.1.3",
34
+ "mocha": "^9.2.0",
35
35
  "rollup": "^2.61.1"
36
36
  }
37
37
  }