ordered-binary 1.3.0 → 1.4.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.
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ordered-binary.iml" filepath="$PROJECT_DIR$/.idea/ordered-binary.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ <excludeFolder url="file://$MODULE_DIR$/.idea" />
9
+ <excludeFolder url="file://$MODULE_DIR$/dist" />
10
+ </content>
11
+ <orderEntry type="inheritedJdk" />
12
+ <orderEntry type="sourceFolder" forTests="false" />
13
+ </component>
14
+ </module>
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Kris Zyp
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Kris Zyp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,39 +1,39 @@
1
- [![npm version](https://img.shields.io/npm/dw/ordered-binary)](https://www.npmjs.org/package/ordered-binary)
2
- [![npm version](https://img.shields.io/npm/v/ordered-binary.svg?style=flat-square)](https://www.npmjs.org/package/ordered-binary)
3
- [![license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
4
- <a href="https://dev.doctorevidence.com/"><img src="./assets/powers-dre.png" width="203" /></a>
5
-
6
- The ordered-binary package provides a representation of JavaScript primitives, serialized into binary format (NodeJS Buffers or Uint8Arrays), such that the binary values are naturally ordered such that it matches the natural ordering or values. For example, since -2.0321 > -2.04, then `toBufferKey(-2.0321)` will be greater than `toBufferKey(-2.04)` as a binary representation, in left-to-right evaluation. This is particular useful for storing keys as binaries with something like LMDB or LevelDB, to avoid any custom sorting.
7
-
8
- The ordered-binary package supports strings, numbers, booleans, symbols, null, as well as an array of primitives. Here is an example of ordering of primitive values:
9
- ```
10
- Buffer.from([0]) // buffers are left unchanged, and this is the minimum value
11
- Symbol.for('even symbols')
12
- -10 // negative supported
13
- -1.1 // decimals supported
14
- 400
15
- 3E10
16
- 'Hello'
17
- ['Hello', 'World']
18
- 'World'
19
- 'hello'
20
- ['hello', 1, 'world']
21
- ['hello', 'world']
22
- Buffer.from([0xff])
23
- ```
24
-
25
-
26
- The main module exports these functions:
27
-
28
- `writeKey(key: string | number | boolean | null | Array, target: Buffer, position: integer, inSequence?: boolean)` - Writes the provide key to the target buffer
29
-
30
- `readKey(buffer, start, end, inSequence)` - Reads the key from the buffer, given the provided start and end, as a primitive value
31
-
32
- `toBufferKey(jsPrimitive)` - This accepts a string, number, or boolean as the argument, and returns a `Buffer`.
33
-
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)
1
+ [![npm version](https://img.shields.io/npm/dw/ordered-binary)](https://www.npmjs.org/package/ordered-binary)
2
+ [![npm version](https://img.shields.io/npm/v/ordered-binary.svg?style=flat-square)](https://www.npmjs.org/package/ordered-binary)
3
+ [![license](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
4
+ <a href="https://dev.doctorevidence.com/"><img src="./assets/powers-dre.png" width="203" /></a>
5
+
6
+ The ordered-binary package provides a representation of JavaScript primitives, serialized into binary format (NodeJS Buffers or Uint8Arrays), such that the binary values are naturally ordered such that it matches the natural ordering or values. For example, since -2.0321 > -2.04, then `toBufferKey(-2.0321)` will be greater than `toBufferKey(-2.04)` as a binary representation, in left-to-right evaluation. This is particular useful for storing keys as binaries with something like LMDB or LevelDB, to avoid any custom sorting.
7
+
8
+ The ordered-binary package supports strings, numbers, booleans, symbols, null, as well as an array of primitives. Here is an example of ordering of primitive values:
9
+ ```
10
+ Buffer.from([0]) // buffers are left unchanged, and this is the minimum value
11
+ Symbol.for('even symbols')
12
+ -10 // negative supported
13
+ -1.1 // decimals supported
14
+ 400
15
+ 3E10
16
+ 'Hello'
17
+ ['Hello', 'World']
18
+ 'World'
19
+ 'hello'
20
+ ['hello', 1, 'world']
21
+ ['hello', 'world']
22
+ Buffer.from([0xff])
23
+ ```
24
+
25
+
26
+ The main module exports these functions:
27
+
28
+ `writeKey(key: string | number | boolean | null | Array, target: Buffer, position: integer, inSequence?: boolean)` - Writes the provide key to the target buffer
29
+
30
+ `readKey(buffer, start, end, inSequence)` - Reads the key from the buffer, given the provided start and end, as a primitive value
31
+
32
+ `toBufferKey(jsPrimitive)` - This accepts a string, number, or boolean as the argument, and returns a `Buffer`.
33
+
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/dist/index.cjs CHANGED
@@ -43,7 +43,10 @@ function writeKey(key, target, position, inSequence) {
43
43
  let i, c2;
44
44
  for (i = 0; i < strLength; i++) {
45
45
  c1 = key.charCodeAt(i);
46
- if (c1 < 0x80) {
46
+ if (c1 <= 4) {
47
+ target[position++] = 4;
48
+ target[position++] = c1;
49
+ } else if (c1 < 0x80) {
47
50
  target[position++] = c1;
48
51
  } else if (c1 < 0x800) {
49
52
  target[position++] = c1 >> 6 | 0xc0;
@@ -254,10 +257,14 @@ function makeStringBuilder() {
254
257
  let v = fromCharCode((i & 0xf) + 97) + fromCharCode((i >> 4) + 97);
255
258
  stringBuildCode += `
256
259
  let ${v} = source[position++]
257
- if (!${v})
258
- return fromCharCode(${previous})
259
- else if (${v} >= 0x80)
260
- ${v} = finishUtf8(${v}, source)
260
+ if (${v} > 4) {
261
+ if (${v} >= 0x80) ${v} = finishUtf8(${v}, source)
262
+ } else {
263
+ if (${v} === 4)
264
+ ${v} = source[position++]
265
+ else
266
+ return fromCharCode(${previous})
267
+ }
261
268
  `;
262
269
  previous.push(v);
263
270
  if (i == 1000000) // this just exists to prevent rollup from doing dead code elimination on finishUtf8
package/index.d.ts CHANGED
@@ -1,23 +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,
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
23
  }
package/index.js CHANGED
@@ -39,7 +39,10 @@ export function writeKey(key, target, position, inSequence) {
39
39
  let i, c2
40
40
  for (i = 0; i < strLength; i++) {
41
41
  c1 = key.charCodeAt(i)
42
- if (c1 < 0x80) {
42
+ if (c1 <= 4) {
43
+ target[position++] = 4
44
+ target[position++] = c1
45
+ } else if (c1 < 0x80) {
43
46
  target[position++] = c1
44
47
  } else if (c1 < 0x800) {
45
48
  target[position++] = c1 >> 6 | 0xc0
@@ -250,10 +253,14 @@ function makeStringBuilder() {
250
253
  let v = fromCharCode((i & 0xf) + 97) + fromCharCode((i >> 4) + 97)
251
254
  stringBuildCode += `
252
255
  let ${v} = source[position++]
253
- if (!${v})
254
- return fromCharCode(${previous})
255
- else if (${v} >= 0x80)
256
- ${v} = finishUtf8(${v}, source)
256
+ if (${v} > 4) {
257
+ if (${v} >= 0x80) ${v} = finishUtf8(${v}, source)
258
+ } else {
259
+ if (${v} === 4)
260
+ ${v} = source[position++]
261
+ else
262
+ return fromCharCode(${previous})
263
+ }
257
264
  `
258
265
  previous.push(v)
259
266
  if (i == 1000000) // this just exists to prevent rollup from doing dead code elimination on finishUtf8
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "name": "ordered-binary",
3
- "author": "Kris Zyp",
4
- "version": "1.3.0",
5
- "description": "Conversion of JavaScript primitives to and from Buffer with binary order matching natural primitive order",
6
- "license": "MIT",
7
- "repository": {
8
- "type": "git",
9
- "url": "http://github.com/kriszyp/ordered-binary"
10
- },
11
- "scripts": {
12
- "build": "rollup -c",
13
- "prepare": "rollup -c",
14
- "test": "mocha tests -u tdd"
15
- },
16
- "type": "module",
17
- "main": "dist/index.cjs",
18
- "module": "index.js",
19
- "exports": {
20
- ".": {
21
- "require": "./dist/index.cjs",
22
- "import": "./index.js"
23
- },
24
- "./index.js": {
25
- "require": "./dist/index.cjs",
26
- "import": "./index.js"
27
- }
28
- },
29
- "typings": "./index.d.ts",
30
- "optionalDependencies": {},
31
- "devDependencies": {
32
- "@types/node": "latest",
33
- "chai": "^4",
34
- "mocha": "^9.2.0",
35
- "rollup": "^2.61.1"
36
- }
37
- }
1
+ {
2
+ "name": "ordered-binary",
3
+ "author": "Kris Zyp",
4
+ "version": "1.4.0",
5
+ "description": "Conversion of JavaScript primitives to and from Buffer with binary order matching natural primitive order",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "http://github.com/kriszyp/ordered-binary"
10
+ },
11
+ "scripts": {
12
+ "build": "rollup -c",
13
+ "prepare": "rollup -c",
14
+ "test": "mocha tests -u tdd"
15
+ },
16
+ "type": "module",
17
+ "main": "dist/index.cjs",
18
+ "module": "index.js",
19
+ "exports": {
20
+ ".": {
21
+ "require": "./dist/index.cjs",
22
+ "import": "./index.js"
23
+ },
24
+ "./index.js": {
25
+ "require": "./dist/index.cjs",
26
+ "import": "./index.js"
27
+ }
28
+ },
29
+ "typings": "./index.d.ts",
30
+ "optionalDependencies": {},
31
+ "devDependencies": {
32
+ "@types/node": "latest",
33
+ "chai": "^4",
34
+ "mocha": "^9.2.0",
35
+ "rollup": "^2.61.1"
36
+ }
37
+ }
package/rollup.config.js CHANGED
@@ -1,11 +1,11 @@
1
- export default [
2
- {
3
- input: "index.js",
4
- output: [
5
- {
6
- file: "dist/index.cjs",
7
- format: "cjs"
8
- }
9
- ]
10
- }
11
- ];
1
+ export default [
2
+ {
3
+ input: "index.js",
4
+ output: [
5
+ {
6
+ file: "dist/index.cjs",
7
+ format: "cjs"
8
+ }
9
+ ]
10
+ }
11
+ ];
package/tests/test.js CHANGED
@@ -44,6 +44,8 @@ suite('key buffers', () => {
44
44
  assert.strictEqual(fromBufferKey(toBufferKey('4')), '4')
45
45
  assert.strictEqual(fromBufferKey(toBufferKey('hello')), 'hello')
46
46
  assert.strictEqual(fromBufferKey(toBufferKey('')), '')
47
+ assert.strictEqual(fromBufferKey(toBufferKey('\x00')), '\x00')
48
+ assert.strictEqual(fromBufferKey(toBufferKey('\x03test\x01\x00')), '\x03test\x01\x00')
47
49
  })
48
50
  test('string comparison', () => {
49
51
  assertBufferComparison(toBufferKey('4'), toBufferKey('5'))
@@ -64,8 +66,8 @@ suite('key buffers', () => {
64
66
  ['hello', 5.25])
65
67
  assert.deepEqual(fromBufferKey(toBufferKey([true, 1503579323825])),
66
68
  [true, 1503579323825])
67
- assert.deepEqual(fromBufferKey(toBufferKey([-0.2525, 'second'])),
68
- [-0.2525, 'second'])
69
+ assert.deepEqual(fromBufferKey(toBufferKey([-0.2525, 'sec\x00nd'])),
70
+ [-0.2525, 'sec\x00nd'])
69
71
  assert.deepEqual(fromBufferKey(toBufferKey([-0.2525, '2nd', '3rd'])),
70
72
  [-0.2525, '2nd', '3rd'])
71
73
  })
package/uuid.js DELETED
@@ -1,110 +0,0 @@
1
-
2
-
3
- export function uuid3(uuid, target, position) {
4
- let int32 = target.int32
5
- if (!int32)
6
- int32 = target.int32 = new Int32Array(target.buffer, target.byteOffset, target.byteLength >> 2)
7
- let c
8
- let intPosition = position >> 2
9
- int32[intPosition] =
10
- (((c = uuid.charCodeAt(0)) > 90 ? (c - 87) : (c - 48)) << 4) |
11
- ((c = uuid.charCodeAt(1)) > 90 ? (c - 87) : (c - 48)) |
12
- (((c = uuid.charCodeAt(2)) > 90 ? (c - 87) : (c - 48)) << 12) |
13
- (((c = uuid.charCodeAt(3)) > 90 ? (c - 87) : (c - 48)) << 8) |
14
- (((c = uuid.charCodeAt(4)) > 90 ? (c - 87) : (c - 48)) << 20) |
15
- (((c = uuid.charCodeAt(5)) > 90 ? (c - 87) : (c - 48)) << 16) |
16
- (((c = uuid.charCodeAt(6)) > 90 ? (c - 87) : (c - 48)) << 28) |
17
- (((c = uuid.charCodeAt(7)) > 90 ? (c - 87) : (c - 48)) << 24)
18
- int32[intPosition + 1] =
19
- (((c = uuid.charCodeAt(9)) > 90 ? (c - 87) : (c - 48)) << 4) |
20
- ((c = uuid.charCodeAt(10)) > 90 ? (c - 87) : (c - 48)) |
21
- (((c = uuid.charCodeAt(11)) > 90 ? (c - 87) : (c - 48)) << 12) |
22
- (((c = uuid.charCodeAt(12)) > 90 ? (c - 87) : (c - 48)) << 8) |
23
- (((c = uuid.charCodeAt(14)) > 90 ? (c - 87) : (c - 48)) << 20) |
24
- (((c = uuid.charCodeAt(15)) > 90 ? (c - 87) : (c - 48)) << 16) |
25
- (((c = uuid.charCodeAt(16)) > 90 ? (c - 87) : (c - 48)) << 28) |
26
- (((c = uuid.charCodeAt(17)) > 90 ? (c - 87) : (c - 48)) << 24)
27
- int32[intPosition + 2] =
28
- (((c = uuid.charCodeAt(19)) > 90 ? (c - 87) : (c - 48)) << 4) |
29
- ((c = uuid.charCodeAt(20)) > 90 ? (c - 87) : (c - 48)) |
30
- (((c = uuid.charCodeAt(21)) > 90 ? (c - 87) : (c - 48)) << 12) |
31
- (((c = uuid.charCodeAt(22)) > 90 ? (c - 87) : (c - 48)) << 8) |
32
- (((c = uuid.charCodeAt(24)) > 90 ? (c - 87) : (c - 48)) << 20) |
33
- (((c = uuid.charCodeAt(25)) > 90 ? (c - 87) : (c - 48)) << 16) |
34
- (((c = uuid.charCodeAt(26)) > 90 ? (c - 87) : (c - 48)) << 28) |
35
- (((c = uuid.charCodeAt(27)) > 90 ? (c - 87) : (c - 48)) << 24)
36
- int32[intPosition + 3] =
37
- (((c = uuid.charCodeAt(28)) > 90 ? (c - 87) : (c - 48)) << 4) |
38
- ((c = uuid.charCodeAt(29)) > 90 ? (c - 87) : (c - 48)) |
39
- (((c = uuid.charCodeAt(30)) > 90 ? (c - 87) : (c - 48)) << 12) |
40
- (((c = uuid.charCodeAt(31)) > 90 ? (c - 87) : (c - 48)) << 8) |
41
- (((c = uuid.charCodeAt(32)) > 90 ? (c - 87) : (c - 48)) << 20) |
42
- (((c = uuid.charCodeAt(33)) > 90 ? (c - 87) : (c - 48)) << 16) |
43
- (((c = uuid.charCodeAt(34)) > 90 ? (c - 87) : (c - 48)) << 28) |
44
- (((c = uuid.charCodeAt(35)) > 90 ? (c - 87) : (c - 48)) << 24)
45
-
46
- return position + 16
47
- }
48
-
49
- export function uuid2(uuid, target, position) {
50
- let c
51
- target[0] =
52
- (((c = uuid.charCodeAt(0)) > 90 ? (c - 87) : (c - 48)) << 4) |
53
- ((c = uuid.charCodeAt(1)) > 90 ? (c - 87) : (c - 48))
54
- target[1] =
55
- (((c = uuid.charCodeAt(2)) > 90 ? (c - 87) : (c - 48)) << 4) |
56
- ((c = uuid.charCodeAt(3)) > 90 ? (c - 87) : (c - 48))
57
- target[2] =
58
- (((c = uuid.charCodeAt(4)) > 90 ? (c - 87) : (c - 48)) << 4) |
59
- ((c = uuid.charCodeAt(5)) > 90 ? (c - 87) : (c - 48))
60
- target[3] =
61
- (((c = uuid.charCodeAt(6)) > 90 ? (c - 87) : (c - 48)) << 4) |
62
- ((c = uuid.charCodeAt(7)) > 90 ? (c - 87) : (c - 48))
63
- target[4] =
64
- (((c = uuid.charCodeAt(9)) > 90 ? (c - 87) : (c - 48)) << 4) |
65
- ((c = uuid.charCodeAt(10)) > 90 ? (c - 87) : (c - 48))
66
- target[5] =
67
- (((c = uuid.charCodeAt(11)) > 90 ? (c - 87) : (c - 48)) << 4) |
68
- ((c = uuid.charCodeAt(12)) > 90 ? (c - 87) : (c - 48))
69
- target[6] =
70
- (((c = uuid.charCodeAt(14)) > 90 ? (c - 87) : (c - 48)) << 4) |
71
- ((c = uuid.charCodeAt(15)) > 90 ? (c - 87) : (c - 48))
72
- target[7] =
73
- (((c = uuid.charCodeAt(16)) > 90 ? (c - 87) : (c - 48)) << 4) |
74
- ((c = uuid.charCodeAt(17)) > 90 ? (c - 87) : (c - 48))
75
- target[8] =
76
- (((c = uuid.charCodeAt(19)) > 90 ? (c - 87) : (c - 48)) << 4) |
77
- ((c = uuid.charCodeAt(20)) > 90 ? (c - 87) : (c - 48))
78
- target[9] =
79
- (((c = uuid.charCodeAt(21)) > 90 ? (c - 87) : (c - 48)) << 4) |
80
- ((c = uuid.charCodeAt(22)) > 90 ? (c - 87) : (c - 48))
81
- target[10] =
82
- (((c = uuid.charCodeAt(24)) > 90 ? (c - 87) : (c - 48)) << 4) |
83
- ((c = uuid.charCodeAt(25)) > 90 ? (c - 87) : (c - 48))
84
- target[11] =
85
- (((c = uuid.charCodeAt(26)) > 90 ? (c - 87) : (c - 48)) << 4) |
86
- ((c = uuid.charCodeAt(27)) > 90 ? (c - 87) : (c - 48))
87
- target[12] =
88
- (((c = uuid.charCodeAt(28)) > 90 ? (c - 87) : (c - 48)) << 4) |
89
- ((c = uuid.charCodeAt(29)) > 90 ? (c - 87) : (c - 48))
90
- target[13] =
91
- (((c = uuid.charCodeAt(30)) > 90 ? (c - 87) : (c - 48)) << 4) |
92
- ((c = uuid.charCodeAt(31)) > 90 ? (c - 87) : (c - 48))
93
- target[14] =
94
- (((c = uuid.charCodeAt(32)) > 90 ? (c - 87) : (c - 48)) << 4) |
95
- ((c = uuid.charCodeAt(33)) > 90 ? (c - 87) : (c - 48))
96
- target[15] =
97
- (((c = uuid.charCodeAt(34)) > 90 ? (c - 87) : (c - 48)) << 4) |
98
- ((c = uuid.charCodeAt(35)) > 90 ? (c - 87) : (c - 48))
99
-
100
-
101
- return position + 16
102
- }
103
- export function uuidReadKey(buffer, start) {
104
- let c
105
- String.fromCharCode(
106
- (c = buffer[0]) < 160 ? ((c >> 4) + 48) : ((c >> 4) + 87),
107
- (c = c & 0xf) < 10 ? (c + 48) : (c + 87),
108
- ...
109
- 45)
110
- }