extra-bit.web 2.0.2 → 2.0.3
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 +47 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
The [bit] is a basic unit of information in information theory, computing.
|
|
2
2
|
This package includes [bit twiddling hacks] by Sean Eron Anderson and many others.<br>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
:scroll: [Files](https://unpkg.com/extra-bit.web/),
|
|
9
|
-
:newspaper: [JSDoc](https://nodef.github.io/extra-bit/),
|
|
10
|
-
:blue_book: [Wiki](https://github.com/nodef/extra-bit/wiki/).
|
|
3
|
+
📦 [Node.js](https://www.npmjs.com/package/extra-bit),
|
|
4
|
+
🌐 [Web](https://www.npmjs.com/package/extra-bit.web),
|
|
5
|
+
📜 [Files](https://unpkg.com/extra-bit.web/),
|
|
6
|
+
📰 [Docs](https://nodef.github.io/extra-bit/).
|
|
7
|
+
📘 [Wiki](https://github.com/nodef/extra-bit/wiki/).
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
This package is available in *Node.js* and *Web* formats. The web format
|
|
10
|
+
is exposed as `extra_bit` standalone variable and can be loaded from
|
|
11
|
+
[jsDelivr CDN].
|
|
12
|
+
|
|
13
|
+
> Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).
|
|
14
|
+
|
|
15
|
+
[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-bit.web/index.js
|
|
13
16
|
|
|
14
17
|
<br>
|
|
15
18
|
|
|
16
19
|
```javascript
|
|
17
|
-
const bit = require(
|
|
20
|
+
const bit = require('extra-bit');
|
|
18
21
|
// import * as bit from "extra-bit";
|
|
19
22
|
// import * as bit from "https://unpkg.com/extra-bit@1.0.50/index.mjs"; (deno)
|
|
20
23
|
|
|
@@ -40,20 +43,24 @@ bit.signExtend(15, 4);
|
|
|
40
43
|
|
|
41
44
|
## Index
|
|
42
45
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
| [get]
|
|
46
|
-
| [
|
|
47
|
-
| [
|
|
48
|
-
| [
|
|
49
|
-
| [
|
|
50
|
-
| [
|
|
51
|
-
| [
|
|
52
|
-
| [
|
|
53
|
-
| [
|
|
54
|
-
| [
|
|
55
|
-
| [
|
|
56
|
-
| [
|
|
46
|
+
| Property | Description |
|
|
47
|
+
| ---- | ---- |
|
|
48
|
+
| [get] | Get a bit. |
|
|
49
|
+
| [getAs] | Get bits as per mask. |
|
|
50
|
+
| [set] | Set a bit. |
|
|
51
|
+
| [setAs] | Set bits as per mask. |
|
|
52
|
+
| [toggle] | Toggle a bit. |
|
|
53
|
+
| [toggleAs] | Toggle bits as per mask. |
|
|
54
|
+
| [swap] | Swap bit sequences. |
|
|
55
|
+
| [scan] | Find index of first set bit from LSB. |
|
|
56
|
+
| [scanReverse] | Find index of first set bit from MSB. |
|
|
57
|
+
| [count] | Count bits set. |
|
|
58
|
+
| [parity] | Find n-bit parity. |
|
|
59
|
+
| [rotate] | Rotate bits. |
|
|
60
|
+
| [reverse] | Reverse all bits. |
|
|
61
|
+
| [merge] | Merge bits as per mask. |
|
|
62
|
+
| [interleave] | Interleave bits of two int16s. |
|
|
63
|
+
| [signExtend] | Sign extend variable bit-width integer. |
|
|
57
64
|
|
|
58
65
|
<br>
|
|
59
66
|
<br>
|
|
@@ -62,15 +69,19 @@ bit.signExtend(15, 4);
|
|
|
62
69
|
|
|
63
70
|
[bit]: https://en.wikipedia.org/wiki/Bit
|
|
64
71
|
[bit twiddling hacks]: https://graphics.stanford.edu/~seander/bithacks.html
|
|
65
|
-
[get]: https://github.
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[rotate]: https://github.
|
|
72
|
+
[get]: https://nodef.github.io/extra-bit/modules.html#get
|
|
73
|
+
[getAs]: https://nodef.github.io/extra-bit/modules.html#getAs
|
|
74
|
+
[set]: https://nodef.github.io/extra-bit/modules.html#set
|
|
75
|
+
[setAs]: https://nodef.github.io/extra-bit/modules.html#setAs
|
|
76
|
+
[toggle]: https://nodef.github.io/extra-bit/modules.html#toggle
|
|
77
|
+
[toggleAs]: https://nodef.github.io/extra-bit/modules.html#toggleAs
|
|
78
|
+
[swap]: https://nodef.github.io/extra-bit/modules.html#swap
|
|
79
|
+
[scan]: https://nodef.github.io/extra-bit/modules.html#scan
|
|
80
|
+
[scanReverse]: https://nodef.github.io/extra-bit/modules.html#scanReverse
|
|
81
|
+
[count]: https://nodef.github.io/extra-bit/modules.html#count
|
|
82
|
+
[parity]: https://nodef.github.io/extra-bit/modules.html#parity
|
|
83
|
+
[rotate]: https://nodef.github.io/extra-bit/modules.html#rotate
|
|
84
|
+
[reverse]: https://nodef.github.io/extra-bit/modules.html#reverse
|
|
85
|
+
[merge]: https://nodef.github.io/extra-bit/modules.html#merge
|
|
86
|
+
[interleave]: https://nodef.github.io/extra-bit/modules.html#interleave
|
|
87
|
+
[signExtend]: https://nodef.github.io/extra-bit/modules.html#signExtend
|