@thi.ng/binary 3.3.12 → 3.3.14
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/CHANGELOG.md +1 -1
- package/README.md +7 -10
- package/api.d.ts +6 -6
- package/count.d.ts +2 -2
- package/count.js +2 -2
- package/float.d.ts +6 -4
- package/float.js +6 -4
- package/gray.d.ts +9 -5
- package/gray.js +9 -5
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/binary)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -21,7 +21,7 @@ This project is part of the
|
|
|
21
21
|
|
|
22
22
|
## About
|
|
23
23
|
|
|
24
|
-
100+ assorted binary / bitwise operations, conversions, utilities, lookup tables
|
|
24
|
+
100+ assorted binary / bitwise operations, conversions, utilities, lookup tables
|
|
25
25
|
|
|
26
26
|
## Status
|
|
27
27
|
|
|
@@ -49,11 +49,8 @@ ES module import:
|
|
|
49
49
|
|
|
50
50
|
For Node.js REPL:
|
|
51
51
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
node --experimental-repl-await
|
|
55
|
-
|
|
56
|
-
> const binary = await import("@thi.ng/binary");
|
|
52
|
+
```js
|
|
53
|
+
const binary = await import("@thi.ng/binary");
|
|
57
54
|
```
|
|
58
55
|
|
|
59
56
|
Package sizes (brotli'd, pre-treeshake): ESM: 2.08 KB
|
|
@@ -82,7 +79,7 @@ TODO
|
|
|
82
79
|
|
|
83
80
|
## Authors
|
|
84
81
|
|
|
85
|
-
Karsten Schmidt
|
|
82
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
86
83
|
|
|
87
84
|
If this project contributes to an academic publication, please cite it as:
|
|
88
85
|
|
|
@@ -97,4 +94,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
97
94
|
|
|
98
95
|
## License
|
|
99
96
|
|
|
100
|
-
© 2016 - 2022 Karsten Schmidt // Apache
|
|
97
|
+
© 2016 - 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export type Lane16 = 0 | 1;
|
|
2
|
+
export type Lane8 = 0 | 1 | 2 | 3;
|
|
3
|
+
export type Lane4 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
4
|
+
export type Lane2 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
|
|
5
|
+
export type Bit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31;
|
|
6
|
+
export type Pow2 = 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x80 | 0x100 | 0x200 | 0x400 | 0x800 | 0x1000 | 0x2000 | 0x4000 | 0x8000 | 0x10000 | 0x20000 | 0x40000 | 0x80000 | 0x100000 | 0x200000 | 0x400000 | 0x800000 | 0x1000000 | 0x2000000 | 0x4000000 | 0x8000000 | 0x10000000 | 0x20000000 | 0x40000000 | 0x80000000;
|
|
7
7
|
//# sourceMappingURL=api.d.ts.map
|
package/count.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const popCountArray: (data: IntArray | UIntArray, start?: number,
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns number of bit changes between `x` and `y`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* https://en.wikipedia.org/wiki/Hamming_distance
|
|
20
20
|
*
|
|
21
21
|
* @param x -
|
|
22
22
|
* @param y -
|
|
@@ -25,7 +25,7 @@ export declare const hammingDist: FnN2;
|
|
|
25
25
|
/**
|
|
26
26
|
* Math.clz32() polyfill (corrected).
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32$revision/1426816
|
|
29
29
|
*
|
|
30
30
|
* @param x -
|
|
31
31
|
*/
|
package/count.js
CHANGED
|
@@ -24,7 +24,7 @@ export const popCountArray = (data, start = 0, n = data.length) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Returns number of bit changes between `x` and `y`.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* https://en.wikipedia.org/wiki/Hamming_distance
|
|
28
28
|
*
|
|
29
29
|
* @param x -
|
|
30
30
|
* @param y -
|
|
@@ -33,7 +33,7 @@ export const hammingDist = (x, y) => popCount(x ^ y);
|
|
|
33
33
|
/**
|
|
34
34
|
* Math.clz32() polyfill (corrected).
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32$revision/1426816
|
|
37
37
|
*
|
|
38
38
|
* @param x -
|
|
39
39
|
*/
|
package/float.d.ts
CHANGED
|
@@ -36,11 +36,13 @@ export declare const intBitsToFloat64: FnN2;
|
|
|
36
36
|
*/
|
|
37
37
|
export declare const uintBitsToFloat64: FnN2;
|
|
38
38
|
/**
|
|
39
|
-
* Converts given float (f32) into a sortable integer representation,
|
|
40
|
-
*
|
|
39
|
+
* Converts given float (f32) into a sortable integer representation, using raw
|
|
40
|
+
* bitwise conversion via {@link floatToIntBits}.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* References:
|
|
44
|
+
* - https://github.com/tzaeschke/phtree/blob/develop/PhTreeRevisited.pdf (page
|
|
45
|
+
* 3)
|
|
44
46
|
*
|
|
45
47
|
* @param x - value to convert
|
|
46
48
|
*/
|
package/float.js
CHANGED
|
@@ -45,11 +45,13 @@ export const uintBitsToFloat64 = (hi, lo) => {
|
|
|
45
45
|
return F64[0];
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
* Converts given float (f32) into a sortable integer representation,
|
|
49
|
-
*
|
|
48
|
+
* Converts given float (f32) into a sortable integer representation, using raw
|
|
49
|
+
* bitwise conversion via {@link floatToIntBits}.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* References:
|
|
53
|
+
* - https://github.com/tzaeschke/phtree/blob/develop/PhTreeRevisited.pdf (page
|
|
54
|
+
* 3)
|
|
53
55
|
*
|
|
54
56
|
* @param x - value to convert
|
|
55
57
|
*/
|
package/gray.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { FnN } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
|
-
* Converts 32bit unsigned int to Gray code (reflected binary). Gray
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Converts 32bit unsigned int to Gray code (reflected binary). Gray codes of
|
|
4
|
+
* successive values always have a Hamming distance of 1 (i.e. only 1 bit
|
|
5
|
+
* changes at a time).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Reference:
|
|
9
|
+
* - https://en.wikipedia.org/wiki/Gray_code
|
|
8
10
|
*
|
|
9
11
|
* @param x - u32
|
|
10
12
|
*/
|
|
@@ -12,7 +14,9 @@ export declare const encodeGray32: FnN;
|
|
|
12
14
|
/**
|
|
13
15
|
* Converts 32bit Gray code to binary / unsigned int.
|
|
14
16
|
*
|
|
15
|
-
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Reference:
|
|
19
|
+
* - https://en.wikipedia.org/wiki/Gray_code
|
|
16
20
|
*/
|
|
17
21
|
export declare const decodeGray32: FnN;
|
|
18
22
|
//# sourceMappingURL=gray.d.ts.map
|
package/gray.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts 32bit unsigned int to Gray code (reflected binary). Gray
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Converts 32bit unsigned int to Gray code (reflected binary). Gray codes of
|
|
3
|
+
* successive values always have a Hamming distance of 1 (i.e. only 1 bit
|
|
4
|
+
* changes at a time).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Reference:
|
|
8
|
+
* - https://en.wikipedia.org/wiki/Gray_code
|
|
7
9
|
*
|
|
8
10
|
* @param x - u32
|
|
9
11
|
*/
|
|
@@ -11,7 +13,9 @@ export const encodeGray32 = (x) => (x ^ (x >>> 1)) >>> 0;
|
|
|
11
13
|
/**
|
|
12
14
|
* Converts 32bit Gray code to binary / unsigned int.
|
|
13
15
|
*
|
|
14
|
-
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Reference:
|
|
18
|
+
* - https://en.wikipedia.org/wiki/Gray_code
|
|
15
19
|
*/
|
|
16
20
|
export const decodeGray32 = (x) => {
|
|
17
21
|
x = x ^ (x >>> 16);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/binary",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.14",
|
|
4
4
|
"description": "100+ assorted binary / bitwise operations, conversions, utilities, lookup tables",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
37
|
+
"@thi.ng/api": "^8.6.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@microsoft/api-extractor": "^7.33.
|
|
41
|
-
"@thi.ng/testament": "^0.3.
|
|
40
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
41
|
+
"@thi.ng/testament": "^0.3.7",
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"tools": "^0.0.1",
|
|
44
|
-
"typedoc": "^0.23.
|
|
45
|
-
"typescript": "^4.
|
|
44
|
+
"typedoc": "^0.23.22",
|
|
45
|
+
"typescript": "^4.9.4"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"align",
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"transducers-binary"
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
133
133
|
}
|