extra-bit 2.4.0 → 2.5.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/README.md +18 -17
- package/package.json +3 -2
- package/TODO +0 -33
- package/build.ts +0 -43
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@ The [bit] is a basic unit of information in information theory, computing.<br>
|
|
|
2
2
|
|
|
3
3
|
▌
|
|
4
4
|
📦 [JSR](https://jsr.io/@nodef/extra-bit),
|
|
5
|
-
📦 [NPM](https://www.npmjs.com/package/extra-bit),
|
|
5
|
+
📦 [NPM](https://www.npmjs.com/package/@nodef/extra-bit),
|
|
6
|
+
🌐 [Web](https://cdn.jsdelivr.net/npm/@nodef/extra-bit.web),
|
|
6
7
|
📰 [Docs](https://jsr.io/@nodef/extra-bit/doc).
|
|
7
8
|
|
|
8
9
|
The concept of a **bit**, which stands for *binary digit*, has been a
|
|
@@ -82,19 +83,19 @@ xbit.signExtend(15, 4);
|
|
|
82
83
|

|
|
83
84
|
|
|
84
85
|
|
|
85
|
-
[get]: https://jsr.io/@nodef/extra-
|
|
86
|
-
[getAs]: https://jsr.io/@nodef/extra-
|
|
87
|
-
[set]: https://jsr.io/@nodef/extra-
|
|
88
|
-
[setAs]: https://jsr.io/@nodef/extra-
|
|
89
|
-
[toggle]: https://jsr.io/@nodef/extra-
|
|
90
|
-
[toggleAs]: https://jsr.io/@nodef/extra-
|
|
91
|
-
[swap]: https://jsr.io/@nodef/extra-
|
|
92
|
-
[scan]: https://jsr.io/@nodef/extra-
|
|
93
|
-
[scanReverse]: https://jsr.io/@nodef/extra-
|
|
94
|
-
[count]: https://jsr.io/@nodef/extra-
|
|
95
|
-
[parity]: https://jsr.io/@nodef/extra-
|
|
96
|
-
[rotate]: https://jsr.io/@nodef/extra-
|
|
97
|
-
[reverse]: https://jsr.io/@nodef/extra-
|
|
98
|
-
[merge]: https://jsr.io/@nodef/extra-
|
|
99
|
-
[interleave]: https://jsr.io/@nodef/extra-
|
|
100
|
-
[signExtend]: https://jsr.io/@nodef/extra-
|
|
86
|
+
[get]: https://jsr.io/@nodef/extra-bit/doc/~/get
|
|
87
|
+
[getAs]: https://jsr.io/@nodef/extra-bit/doc/~/getAs
|
|
88
|
+
[set]: https://jsr.io/@nodef/extra-bit/doc/~/set
|
|
89
|
+
[setAs]: https://jsr.io/@nodef/extra-bit/doc/~/setAs
|
|
90
|
+
[toggle]: https://jsr.io/@nodef/extra-bit/doc/~/toggle
|
|
91
|
+
[toggleAs]: https://jsr.io/@nodef/extra-bit/doc/~/toggleAs
|
|
92
|
+
[swap]: https://jsr.io/@nodef/extra-bit/doc/~/swap
|
|
93
|
+
[scan]: https://jsr.io/@nodef/extra-bit/doc/~/scan
|
|
94
|
+
[scanReverse]: https://jsr.io/@nodef/extra-bit/doc/~/scanReverse
|
|
95
|
+
[count]: https://jsr.io/@nodef/extra-bit/doc/~/count
|
|
96
|
+
[parity]: https://jsr.io/@nodef/extra-bit/doc/~/parity
|
|
97
|
+
[rotate]: https://jsr.io/@nodef/extra-bit/doc/~/rotate
|
|
98
|
+
[reverse]: https://jsr.io/@nodef/extra-bit/doc/~/reverse
|
|
99
|
+
[merge]: https://jsr.io/@nodef/extra-bit/doc/~/merge
|
|
100
|
+
[interleave]: https://jsr.io/@nodef/extra-bit/doc/~/interleave
|
|
101
|
+
[signExtend]: https://jsr.io/@nodef/extra-bit/doc/~/signExtend
|
package/package.json
CHANGED
package/TODO
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
NIBBLES?
|
|
2
|
-
STRINGIFY
|
|
3
|
-
OTHERS
|
|
4
|
-
- fromInt64
|
|
5
|
-
- fromDouble
|
|
6
|
-
- fromSingle
|
|
7
|
-
- slice / getPart(x, i, n)
|
|
8
|
-
- deinterleave
|
|
9
|
-
- split
|
|
10
|
-
- reduce
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
https://www.npmjs.com/package/uupaa.bit.js
|
|
14
|
-
|
|
15
|
-
// count the number of contiguous 1 bits from Left-side or Right-side
|
|
16
|
-
Bit.cnl(0b11001110) // -> 2
|
|
17
|
-
Bit.cnr(0b11001110) // -> 3
|
|
18
|
-
|
|
19
|
-
// Number(Count) of Leading Zero
|
|
20
|
-
Bit.nlz(0x6) // -> 29
|
|
21
|
-
Bit.clz(0x6) // -> 29 (this function is an alias of Bit.nlz)
|
|
22
|
-
|
|
23
|
-
// Number(Count) of Training Zero
|
|
24
|
-
Bit.ntz(0x6) // -> 1
|
|
25
|
-
Bit.ctz(0x6) // -> 1 (this function is an alias of Bit.ntz)
|
|
26
|
-
|
|
27
|
-
// binary dump
|
|
28
|
-
Bit.dump(0x12345678, [4,4,8,4,4,8]);
|
|
29
|
-
// -> "0001, 0010, 00110100, 0101, 0110, 01111000"
|
|
30
|
-
|
|
31
|
-
// verbose dump
|
|
32
|
-
Bit.dump(0x12345678, bitPattern, true);
|
|
33
|
-
// -> "00010010001101000101011001111000(0x12345678), 0001(1,0x1), 0010(2,0x2), 00110100(52,0x34), 0101(5,0x5), 0110(6,0x6), 01111000(120,0x78)"
|
package/build.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {parseArgs} from "@std/cli/parse-args";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Run a command in a subprocess, with inherited stdio.
|
|
5
|
-
async function run(command: string, args: string[], cwd?: string) {
|
|
6
|
-
const cmd = new Deno.Command(command, {
|
|
7
|
-
args: args,
|
|
8
|
-
cwd: cwd,
|
|
9
|
-
stdin: 'inherit',
|
|
10
|
-
stdout: 'inherit',
|
|
11
|
-
stderr: 'inherit'
|
|
12
|
-
});
|
|
13
|
-
return await cmd.spawn().status;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Publish core package to npm.
|
|
18
|
-
async function publishCoreToNpm() {
|
|
19
|
-
const name = JSON.parse(await Deno.readTextFile('deno.json')).name.replace(/^@nodef\//, '');
|
|
20
|
-
console.log(`Publishing the ${name} package to npm...`);
|
|
21
|
-
await run('deno', ['pack', '--output', `${name}.tgz`, '--allow-dirty']);
|
|
22
|
-
Deno.mkdirSync('.temp-pack', {recursive: true});
|
|
23
|
-
await run('tar', ['-xzf', `${name}.tgz`, '-C', '.temp-pack']);
|
|
24
|
-
Deno.removeSync(`${name}.tgz`);
|
|
25
|
-
const meta = JSON.parse(await Deno.readTextFile('.temp-pack/package/package.json'));
|
|
26
|
-
meta.name = name;
|
|
27
|
-
await Deno.writeTextFile('.temp-pack/package/package.json', JSON.stringify(meta, null, 2));
|
|
28
|
-
await run('npm', ['publish', '--access', 'public'], '.temp-pack/package');
|
|
29
|
-
await Deno.remove('.temp-pack', {recursive: true});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Main function, of course.
|
|
34
|
-
async function main() {
|
|
35
|
-
const args = parseArgs(Deno.args, {
|
|
36
|
-
boolean: ['publish-core'],
|
|
37
|
-
default: {'publish-core': false}
|
|
38
|
-
});
|
|
39
|
-
if (args['publish-core']) {
|
|
40
|
-
await publishCoreToNpm();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
main();
|