@thi.ng/binary 3.2.3 → 3.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/CHANGELOG.md +7 -1
- package/count.d.ts +8 -0
- package/count.js +15 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-
|
|
3
|
+
- **Last updated**: 2022-07-19T15:36:12Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/binary@3.3.0) (2022-07-19)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add popCountArray() ([d59e0c4](https://github.com/thi-ng/umbrella/commit/d59e0c4))
|
|
17
|
+
|
|
12
18
|
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/binary@3.2.0) (2022-03-11)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/count.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ import type { FnN, FnN2 } from "@thi.ng/api";
|
|
|
5
5
|
* @param x -
|
|
6
6
|
*/
|
|
7
7
|
export declare const popCount: FnN;
|
|
8
|
+
/**
|
|
9
|
+
* Returns number of set bits (1's) in the given array (index range).
|
|
10
|
+
*
|
|
11
|
+
* @param data -
|
|
12
|
+
* @param start -
|
|
13
|
+
* @param n -
|
|
14
|
+
*/
|
|
15
|
+
export declare const popCountArray: (data: Uint32Array, start?: number, n?: number) => number;
|
|
8
16
|
/**
|
|
9
17
|
* Returns number of bit changes between `x` and `y`.
|
|
10
18
|
*
|
package/count.js
CHANGED
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
export const popCount = (x) => ((x = x - ((x >>> 1) & 0x55555555)),
|
|
7
7
|
(x = (x & 0x33333333) + ((x >>> 2) & 0x33333333)),
|
|
8
8
|
(((x + (x >>> 4)) & 0xf0f0f0f) * 0x1010101) >>> 24);
|
|
9
|
+
/**
|
|
10
|
+
* Returns number of set bits (1's) in the given array (index range).
|
|
11
|
+
*
|
|
12
|
+
* @param data -
|
|
13
|
+
* @param start -
|
|
14
|
+
* @param n -
|
|
15
|
+
*/
|
|
16
|
+
export const popCountArray = (data, start = 0, n = data.length) => {
|
|
17
|
+
let num = 0;
|
|
18
|
+
for (let end = start + n; start < end; start++) {
|
|
19
|
+
const x = data[start];
|
|
20
|
+
x > 0 && (num += popCount(x));
|
|
21
|
+
}
|
|
22
|
+
return num;
|
|
23
|
+
};
|
|
9
24
|
/**
|
|
10
25
|
* Returns number of bit changes between `x` and `y`.
|
|
11
26
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/binary",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "100+ assorted binary / bitwise operations, conversions, utilities, lookup tables",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
37
|
+
"@thi.ng/api": "^8.3.8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@microsoft/api-extractor": "^7.25.0",
|
|
41
|
-
"@thi.ng/testament": "^0.2.
|
|
41
|
+
"@thi.ng/testament": "^0.2.9",
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"tools": "^0.0.1",
|
|
44
44
|
"typedoc": "^0.22.17",
|
|
45
|
-
"typescript": "^4.7.
|
|
45
|
+
"typescript": "^4.7.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": "108a6357b77d457912d30681d7cc5603ae995209\n"
|
|
133
133
|
}
|