@thi.ng/bitstream 1.1.42 → 2.0.2
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 +31 -23
- package/README.md +20 -5
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/input.js +2 -1
- package/output.d.ts +1 -1
- package/output.js +2 -2
- package/package.json +39 -22
- package/lib/index.js +0 -228
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [
|
|
6
|
+
## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@2.0.1...@thi.ng/bitstream@2.0.2) (2021-10-15)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @thi.ng/bitstream
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
## [
|
|
14
|
+
## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@2.0.0...@thi.ng/bitstream@2.0.1) (2021-10-13)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @thi.ng/bitstream
|
|
17
17
|
|
|
@@ -19,47 +19,55 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.1.43...@thi.ng/bitstream@2.0.0) (2021-10-12)
|
|
23
23
|
|
|
24
|
-
**Note:** Version bump only for package @thi.ng/bitstream
|
|
25
24
|
|
|
25
|
+
### Build System
|
|
26
26
|
|
|
27
|
+
* major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
### BREAKING CHANGES
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
* discontinue CommonJS & UMD versions
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
- only ESM modules will be published from now on
|
|
35
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
36
|
+
- i.e. launch NodeJS via:
|
|
37
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
38
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
39
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
33
40
|
|
|
41
|
+
Also:
|
|
42
|
+
- normalize/restructure/reorg all package.json files
|
|
43
|
+
- cleanup all build scripts, remove obsolete
|
|
44
|
+
- switch from mocha to @thi.ng/testament for all tests
|
|
34
45
|
|
|
35
46
|
|
|
36
47
|
|
|
37
48
|
|
|
38
|
-
# [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.0.6...@thi.ng/bitstream@1.1.0) (2019-07-07)
|
|
39
49
|
|
|
40
|
-
### Features
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
# [1.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@1.0.6...@thi.ng/bitstream@1.1.0) (2019-07-07)
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
### Features
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
- **bitstream:** enable TS strict compiler flags (refactor) ([ab18310](https://github.com/thi-ng/umbrella/commit/ab18310))
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
# [1.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@0.4.21...@thi.ng/bitstream@1.0.0) (2019-01-21)
|
|
49
58
|
|
|
50
|
-
###
|
|
59
|
+
### Build System
|
|
60
|
+
|
|
61
|
+
- update package build scripts & outputs, imports in ~50 packages ([b54b703](https://github.com/thi-ng/umbrella/commit/b54b703))
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
### BREAKING CHANGES
|
|
53
64
|
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
- all imports MUST be updated to only refer to package level
|
|
57
|
-
(not individual files anymore). tree shaking in user land will get rid of
|
|
58
|
-
all unused imported symbols.
|
|
65
|
+
- enabled multi-outputs (ES6 modules, CJS, UMD)
|
|
66
|
+
- build scripts now first build ES6 modules in package root, then call `scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
67
|
+
- all imports MUST be updated to only refer to package level (not individual files anymore). tree shaking in user land will get rid of all unused imported symbols.
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
# [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@0.3.7...@thi.ng/bitstream@0.4.0) (2018-03-21)
|
|
69
|
+
# [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/bitstream@0.3.7...@thi.ng/bitstream@0.4.0) (2018-03-21)
|
|
62
70
|
|
|
63
|
-
###
|
|
71
|
+
### Features
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
- **bitstream:** update error handling, add [@thi](https://github.com/thi).ng/atom dep ([0fc1038](https://github.com/thi-ng/umbrella/commit/0fc1038))
|
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ This project is part of the
|
|
|
11
11
|
|
|
12
12
|
- [About](#about)
|
|
13
13
|
- [Status](#status)
|
|
14
|
+
- [Related packages](#related-packages)
|
|
14
15
|
- [Installation](#installation)
|
|
15
16
|
- [Dependencies](#dependencies)
|
|
16
17
|
- [API](#api)
|
|
@@ -29,21 +30,35 @@ ES6 iterator based read/write bit streams with support for variable word widths.
|
|
|
29
30
|
|
|
30
31
|
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bbitstream%5D+in%3Atitle)
|
|
31
32
|
|
|
33
|
+
### Related packages
|
|
34
|
+
|
|
35
|
+
- [@thi.ng/range-coder](https://github.com/thi-ng/umbrella/tree/develop/packages/range-coder) - Binary data range encoder / decoder
|
|
36
|
+
- [@thi.ng/rle-pack](https://github.com/thi-ng/umbrella/tree/develop/packages/rle-pack) - Binary run-length encoding packer w/ flexible repeat bit widths
|
|
37
|
+
|
|
32
38
|
## Installation
|
|
33
39
|
|
|
34
40
|
```bash
|
|
35
41
|
yarn add @thi.ng/bitstream
|
|
36
42
|
```
|
|
37
43
|
|
|
44
|
+
ES module import:
|
|
45
|
+
|
|
38
46
|
```html
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
<script type="module" src="https://cdn.skypack.dev/@thi.ng/bitstream"></script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
[Skypack documentation](https://docs.skypack.dev/)
|
|
51
|
+
|
|
52
|
+
For Node.js REPL:
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
# with flag only for < v16
|
|
56
|
+
node --experimental-repl-await
|
|
41
57
|
|
|
42
|
-
|
|
43
|
-
<script src="https://unpkg.com/@thi.ng/bitstream/lib/index.umd.js" crossorigin></script>
|
|
58
|
+
> const bitstream = await import("@thi.ng/bitstream");
|
|
44
59
|
```
|
|
45
60
|
|
|
46
|
-
Package sizes (gzipped, pre-treeshake): ESM: 1.
|
|
61
|
+
Package sizes (gzipped, pre-treeshake): ESM: 1.11 KB
|
|
47
62
|
|
|
48
63
|
## Dependencies
|
|
49
64
|
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./input";
|
|
2
|
-
export * from "./output";
|
|
1
|
+
export * from "./input.js";
|
|
2
|
+
export * from "./output.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./input";
|
|
2
|
-
export * from "./output";
|
|
1
|
+
export * from "./input.js";
|
|
2
|
+
export * from "./output.js";
|
package/input.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { illegalArgs
|
|
1
|
+
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
2
|
+
import { illegalState } from "@thi.ng/errors/illegal-state";
|
|
2
3
|
const U32 = Math.pow(2, 32);
|
|
3
4
|
export class BitInputStream {
|
|
4
5
|
constructor(buffer, offset = 0, limit = buffer.length << 3) {
|
package/output.d.ts
CHANGED
package/output.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { illegalArgs } from "@thi.ng/errors";
|
|
2
|
-
import { BitInputStream } from "./input";
|
|
1
|
+
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
2
|
+
import { BitInputStream } from "./input.js";
|
|
3
3
|
const DEFAULT_BUF_SIZE = 0x10;
|
|
4
4
|
const U32 = Math.pow(2, 32);
|
|
5
5
|
export class BitOutputStream {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/bitstream",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "ES6 iterator based read/write bit streams with support for variable word widths",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"module": "./index.js",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"umd:main": "./lib/index.umd.js",
|
|
8
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
@@ -24,27 +24,21 @@
|
|
|
24
24
|
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn clean &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"build:test": "rimraf build && tsc -p test/tsconfig.json",
|
|
31
|
-
"build:check": "tsc --isolatedModules --noEmit",
|
|
32
|
-
"test": "mocha test",
|
|
33
|
-
"cover": "nyc mocha test && nyc report --reporter=lcov",
|
|
34
|
-
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
|
|
35
|
-
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
|
|
36
|
-
"doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf *.js *.d.ts *.map doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
37
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
|
|
38
|
-
"
|
|
31
|
+
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
|
|
32
|
+
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
|
|
33
|
+
"pub": "yarn build && yarn publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
39
35
|
},
|
|
40
36
|
"dependencies": {
|
|
41
|
-
"@thi.ng/errors": "^
|
|
37
|
+
"@thi.ng/errors": "^2.0.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@thi.ng/testament": "^0.1.2"
|
|
42
41
|
},
|
|
43
|
-
"files": [
|
|
44
|
-
"*.js",
|
|
45
|
-
"*.d.ts",
|
|
46
|
-
"lib"
|
|
47
|
-
],
|
|
48
42
|
"keywords": [
|
|
49
43
|
"binary",
|
|
50
44
|
"datastructure",
|
|
@@ -55,6 +49,29 @@
|
|
|
55
49
|
"publishConfig": {
|
|
56
50
|
"access": "public"
|
|
57
51
|
},
|
|
58
|
-
"
|
|
59
|
-
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=12.7"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"*.js",
|
|
57
|
+
"*.d.ts"
|
|
58
|
+
],
|
|
59
|
+
"exports": {
|
|
60
|
+
".": {
|
|
61
|
+
"import": "./index.js"
|
|
62
|
+
},
|
|
63
|
+
"./input": {
|
|
64
|
+
"import": "./input.js"
|
|
65
|
+
},
|
|
66
|
+
"./output": {
|
|
67
|
+
"import": "./output.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"thi.ng": {
|
|
71
|
+
"related": [
|
|
72
|
+
"range-coder",
|
|
73
|
+
"rle-pack"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"gitHead": "3c5f903104da150588946a94bb118ad559ad395d"
|
|
60
77
|
}
|
package/lib/index.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var errors = require('@thi.ng/errors');
|
|
6
|
-
|
|
7
|
-
const U32$1 = Math.pow(2, 32);
|
|
8
|
-
class BitInputStream {
|
|
9
|
-
constructor(buffer, offset = 0, limit = buffer.length << 3) {
|
|
10
|
-
this.buffer = buffer;
|
|
11
|
-
this.start = offset;
|
|
12
|
-
this.limit = limit;
|
|
13
|
-
this.seek(offset);
|
|
14
|
-
}
|
|
15
|
-
*[Symbol.iterator]() {
|
|
16
|
-
let j = this.start;
|
|
17
|
-
let i = j >>> 3;
|
|
18
|
-
let b = 7 - (j & 0x7);
|
|
19
|
-
while (j < this.limit) {
|
|
20
|
-
yield (this.buffer[i] >>> b) & 1;
|
|
21
|
-
if (--b < 0) {
|
|
22
|
-
i++;
|
|
23
|
-
b = 7;
|
|
24
|
-
}
|
|
25
|
-
j++;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
get length() {
|
|
29
|
-
return this.limit;
|
|
30
|
-
}
|
|
31
|
-
get position() {
|
|
32
|
-
return this.bitPos;
|
|
33
|
-
}
|
|
34
|
-
seek(pos) {
|
|
35
|
-
if (pos < this.start || pos >= this.limit) {
|
|
36
|
-
errors.illegalArgs(`seek pos out of bounds: ${pos}`);
|
|
37
|
-
}
|
|
38
|
-
this.pos = pos >>> 3;
|
|
39
|
-
this.bit = 8 - (pos & 0x7);
|
|
40
|
-
this.bitPos = pos;
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
read(wordSize = 1) {
|
|
44
|
-
if (wordSize > 32) {
|
|
45
|
-
return this.read(wordSize - 32) * U32$1 + this.read(32);
|
|
46
|
-
}
|
|
47
|
-
else if (wordSize > 8) {
|
|
48
|
-
let out = 0;
|
|
49
|
-
let n = wordSize & -8;
|
|
50
|
-
let msb = wordSize - n;
|
|
51
|
-
if (msb > 0) {
|
|
52
|
-
out = this._read(msb);
|
|
53
|
-
}
|
|
54
|
-
while (n > 0) {
|
|
55
|
-
out = ((out << 8) | this._read(8)) >>> 0;
|
|
56
|
-
n -= 8;
|
|
57
|
-
}
|
|
58
|
-
return out;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
return this._read(wordSize);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
readFields(fields) {
|
|
65
|
-
return fields.map((word) => this.read(word));
|
|
66
|
-
}
|
|
67
|
-
readWords(n, wordSize = 8) {
|
|
68
|
-
let out = [];
|
|
69
|
-
while (--n >= 0) {
|
|
70
|
-
out.push(this.read(wordSize));
|
|
71
|
-
}
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
readStruct(fields) {
|
|
75
|
-
return fields.reduce((acc, [id, word]) => {
|
|
76
|
-
return (acc[id] = this.read(word)), acc;
|
|
77
|
-
}, {});
|
|
78
|
-
}
|
|
79
|
-
readBit() {
|
|
80
|
-
this.checkLimit(1);
|
|
81
|
-
this.bit--;
|
|
82
|
-
this.bitPos++;
|
|
83
|
-
let out = (this.buffer[this.pos] >>> this.bit) & 1;
|
|
84
|
-
if (this.bit === 0) {
|
|
85
|
-
this.pos++;
|
|
86
|
-
this.bit = 8;
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
90
|
-
_read(wordSize) {
|
|
91
|
-
this.checkLimit(wordSize);
|
|
92
|
-
let l = this.bit - wordSize, out;
|
|
93
|
-
if (l >= 0) {
|
|
94
|
-
this.bit = l;
|
|
95
|
-
out = (this.buffer[this.pos] >>> l) & ((1 << wordSize) - 1);
|
|
96
|
-
if (l === 0) {
|
|
97
|
-
this.pos++;
|
|
98
|
-
this.bit = 8;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
out = (this.buffer[this.pos++] & ((1 << this.bit) - 1)) << -l;
|
|
103
|
-
this.bit = 8 + l;
|
|
104
|
-
out = out | (this.buffer[this.pos] >>> this.bit);
|
|
105
|
-
}
|
|
106
|
-
this.bitPos += wordSize;
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
checkLimit(requested) {
|
|
110
|
-
if (this.bitPos + requested > this.limit) {
|
|
111
|
-
errors.illegalState(`can't read past EOF`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const DEFAULT_BUF_SIZE = 0x10;
|
|
117
|
-
const U32 = Math.pow(2, 32);
|
|
118
|
-
class BitOutputStream {
|
|
119
|
-
constructor(buffer, offset = 0) {
|
|
120
|
-
this.buffer =
|
|
121
|
-
typeof buffer === "undefined"
|
|
122
|
-
? new Uint8Array(DEFAULT_BUF_SIZE)
|
|
123
|
-
: typeof buffer === "number"
|
|
124
|
-
? new Uint8Array(buffer)
|
|
125
|
-
: buffer;
|
|
126
|
-
this.start = offset;
|
|
127
|
-
this.seek(offset);
|
|
128
|
-
this.buffer[this.pos] &= ~((1 << this.bit) - 1);
|
|
129
|
-
}
|
|
130
|
-
get position() {
|
|
131
|
-
return this.bitPos;
|
|
132
|
-
}
|
|
133
|
-
seek(pos) {
|
|
134
|
-
if (pos < this.start || pos >= this.buffer.length << 3) {
|
|
135
|
-
errors.illegalArgs(`seek pos out of bounds: ${pos}`);
|
|
136
|
-
}
|
|
137
|
-
this.pos = pos >>> 3;
|
|
138
|
-
this.bit = 8 - (pos & 0x7);
|
|
139
|
-
this.bitPos = pos;
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
bytes() {
|
|
143
|
-
return this.buffer.slice(0, this.pos + (this.bit & 7 ? 1 : 0));
|
|
144
|
-
}
|
|
145
|
-
reader(from = 0) {
|
|
146
|
-
return new BitInputStream(this.buffer, from, this.position);
|
|
147
|
-
}
|
|
148
|
-
write(x, wordSize = 1) {
|
|
149
|
-
if (wordSize > 32) {
|
|
150
|
-
let hi = Math.floor(x / U32);
|
|
151
|
-
this.write(hi, wordSize - 32);
|
|
152
|
-
this.write(x - hi * U32, 32);
|
|
153
|
-
}
|
|
154
|
-
else if (wordSize > 8) {
|
|
155
|
-
let n = wordSize & -8;
|
|
156
|
-
let msb = wordSize - n;
|
|
157
|
-
if (msb > 0) {
|
|
158
|
-
this._write(x >>> n, msb);
|
|
159
|
-
}
|
|
160
|
-
n -= 8;
|
|
161
|
-
while (n >= 0) {
|
|
162
|
-
this._write(x >>> n, 8);
|
|
163
|
-
n -= 8;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
this._write(x, wordSize);
|
|
168
|
-
}
|
|
169
|
-
return this;
|
|
170
|
-
}
|
|
171
|
-
writeWords(input, wordSize = 8) {
|
|
172
|
-
let iter = input[Symbol.iterator]();
|
|
173
|
-
let v;
|
|
174
|
-
while (((v = iter.next()), !v.done)) {
|
|
175
|
-
this.write(v.value, wordSize);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
writeBit(x) {
|
|
179
|
-
this.bit--;
|
|
180
|
-
this.buffer[this.pos] =
|
|
181
|
-
(this.buffer[this.pos] & ~(1 << this.bit)) | (x << this.bit);
|
|
182
|
-
if (this.bit === 0) {
|
|
183
|
-
this.ensureSize();
|
|
184
|
-
this.bit = 8;
|
|
185
|
-
}
|
|
186
|
-
this.bitPos++;
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
_write(x, wordSize) {
|
|
190
|
-
x &= (1 << wordSize) - 1;
|
|
191
|
-
let buf = this.buffer;
|
|
192
|
-
let pos = this.pos;
|
|
193
|
-
let bit = this.bit;
|
|
194
|
-
let b = bit - wordSize;
|
|
195
|
-
let m = bit < 8 ? ~((1 << bit) - 1) : 0;
|
|
196
|
-
if (b >= 0) {
|
|
197
|
-
m |= (1 << b) - 1;
|
|
198
|
-
buf[pos] = (buf[pos] & m) | ((x << b) & ~m);
|
|
199
|
-
if (b === 0) {
|
|
200
|
-
this.ensureSize();
|
|
201
|
-
this.bit = 8;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
this.bit = b;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
this.bit = bit = 8 + b;
|
|
209
|
-
buf[pos] = (buf[pos] & m) | ((x >>> -b) & ~m);
|
|
210
|
-
this.ensureSize();
|
|
211
|
-
this.buffer[this.pos] =
|
|
212
|
-
(this.buffer[this.pos] & ((1 << bit) - 1)) |
|
|
213
|
-
((x << bit) & 0xff);
|
|
214
|
-
}
|
|
215
|
-
this.bitPos += wordSize;
|
|
216
|
-
return this;
|
|
217
|
-
}
|
|
218
|
-
ensureSize() {
|
|
219
|
-
if (++this.pos === this.buffer.length) {
|
|
220
|
-
let b = new Uint8Array(this.buffer.length << 1);
|
|
221
|
-
b.set(this.buffer);
|
|
222
|
-
this.buffer = b;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
exports.BitInputStream = BitInputStream;
|
|
228
|
-
exports.BitOutputStream = BitOutputStream;
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../input.js","../output.js"],"sourcesContent":null,"names":["U32","illegalArgs","illegalState"],"mappings":";;;;;;AACA,MAAMA,KAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,C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,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AACzD,qBAAqB,CAAC,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC;AACxC,SAAS;AACT,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC;AAChC,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,UAAU,GAAG;AACjB,QAAQ,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;AAC/C,YAAY,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAC5D,YAAY,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B,YAAY,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5B,SAAS;AACT,KAAK;AACL;;;;;"}
|
package/lib/index.umd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@thi.ng/errors")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/errors"],i):i(((t="undefined"!=typeof globalThis?globalThis:t||self).thi=t.thi||{},t.thi.ng=t.thi.ng||{},t.thi.ng.bitstream={}),t.thi.ng.errors)}(this,(function(t,i){"use strict";const s=Math.pow(2,32);class e{constructor(t,i=0,s=t.length<<3){this.buffer=t,this.start=i,this.limit=s,this.seek(i)}*[Symbol.iterator](){let t=this.start,i=t>>>3,s=7-(7&t);for(;t<this.limit;)yield this.buffer[i]>>>s&1,--s<0&&(i++,s=7),t++}get length(){return this.limit}get position(){return this.bitPos}seek(t){return(t<this.start||t>=this.limit)&&i.illegalArgs(`seek pos out of bounds: ${t}`),this.pos=t>>>3,this.bit=8-(7&t),this.bitPos=t,this}read(t=1){if(t>32)return this.read(t-32)*s+this.read(32);if(t>8){let i=0,s=-8&t,e=t-s;for(e>0&&(i=this._read(e));s>0;)i=(i<<8|this._read(8))>>>0,s-=8;return i}return this._read(t)}readFields(t){return t.map((t=>this.read(t)))}readWords(t,i=8){let s=[];for(;--t>=0;)s.push(this.read(i));return s}readStruct(t){return t.reduce(((t,[i,s])=>(t[i]=this.read(s),t)),{})}readBit(){this.checkLimit(1),this.bit--,this.bitPos++;let t=this.buffer[this.pos]>>>this.bit&1;return 0===this.bit&&(this.pos++,this.bit=8),t}_read(t){this.checkLimit(t);let i,s=this.bit-t;return s>=0?(this.bit=s,i=this.buffer[this.pos]>>>s&(1<<t)-1,0===s&&(this.pos++,this.bit=8)):(i=(this.buffer[this.pos++]&(1<<this.bit)-1)<<-s,this.bit=8+s,i|=this.buffer[this.pos]>>>this.bit),this.bitPos+=t,i}checkLimit(t){this.bitPos+t>this.limit&&i.illegalState("can't read past EOF")}}const r=Math.pow(2,32);t.BitInputStream=e,t.BitOutputStream=class{constructor(t,i=0){this.buffer=void 0===t?new Uint8Array(16):"number"==typeof t?new Uint8Array(t):t,this.start=i,this.seek(i),this.buffer[this.pos]&=~((1<<this.bit)-1)}get position(){return this.bitPos}seek(t){return(t<this.start||t>=this.buffer.length<<3)&&i.illegalArgs(`seek pos out of bounds: ${t}`),this.pos=t>>>3,this.bit=8-(7&t),this.bitPos=t,this}bytes(){return this.buffer.slice(0,this.pos+(7&this.bit?1:0))}reader(t=0){return new e(this.buffer,t,this.position)}write(t,i=1){if(i>32){let s=Math.floor(t/r);this.write(s,i-32),this.write(t-s*r,32)}else if(i>8){let s=-8&i,e=i-s;for(e>0&&this._write(t>>>s,e),s-=8;s>=0;)this._write(t>>>s,8),s-=8}else this._write(t,i);return this}writeWords(t,i=8){let s,e=t[Symbol.iterator]();for(;s=e.next(),!s.done;)this.write(s.value,i)}writeBit(t){return this.bit--,this.buffer[this.pos]=this.buffer[this.pos]&~(1<<this.bit)|t<<this.bit,0===this.bit&&(this.ensureSize(),this.bit=8),this.bitPos++,this}_write(t,i){t&=(1<<i)-1;let s=this.buffer,e=this.pos,r=this.bit,h=r-i,o=r<8?~((1<<r)-1):0;return h>=0?(o|=(1<<h)-1,s[e]=s[e]&o|t<<h&~o,0===h?(this.ensureSize(),this.bit=8):this.bit=h):(this.bit=r=8+h,s[e]=s[e]&o|t>>>-h&~o,this.ensureSize(),this.buffer[this.pos]=this.buffer[this.pos]&(1<<r)-1|t<<r&255),this.bitPos+=i,this}ensureSize(){if(++this.pos===this.buffer.length){let t=new Uint8Array(this.buffer.length<<1);t.set(this.buffer),this.buffer=t}}},Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/lib/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../input.js","../output.js"],"sourcesContent":null,"names":["U32","illegalArgs","illegalState"],"mappings":";;;;;;IACA,MAAMA,KAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrB,MAAM,cAAc,CAAC;IAC5B,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;IAChE,QAAQ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;IAC5B,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC3B,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,KAAK;IACL,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG;IACzB,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3B,QAAQ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;IAC9B,QAAQ,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE;IAC/B,YAAY,MA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