strtok3 10.2.0 → 10.2.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/LICENSE.txt +21 -0
- package/README.md +8 -15
- package/lib/ReadStreamTokenizer.js +2 -2
- package/package.json +10 -8
- package/LICENSE +0 -15
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 Borewit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://github.com/Borewit/strtok3/actions/workflows/ci.yml)
|
|
2
2
|
[](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml)
|
|
3
3
|
[](https://npmjs.org/package/strtok3)
|
|
4
4
|
[](https://npmcharts.com/compare/strtok3,token-types?start=1200&interval=30)
|
|
@@ -35,7 +35,7 @@ npm install strtok3
|
|
|
35
35
|
Starting with version 7, the module has migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
|
36
36
|
The distributed JavaScript codebase is compliant with the [ECMAScript 2020 (11th Edition)](https://en.wikipedia.org/wiki/ECMAScript_version_history#11th_Edition_%E2%80%93_ECMAScript_2020) standard.
|
|
37
37
|
|
|
38
|
-
Requires a modern browser
|
|
38
|
+
Requires a modern browser, Node.js (V8) ≥ 18 engine or Bun (JavaScriptCore) ≥ 1.2.
|
|
39
39
|
|
|
40
40
|
For TypeScript CommonJs backward compatibility, you can use [load-esm](https://github.com/Borewit/load-esm).
|
|
41
41
|
|
|
@@ -57,12 +57,12 @@ If you find this project useful and would like to support its development, consi
|
|
|
57
57
|
### strtok3 methods
|
|
58
58
|
|
|
59
59
|
Use one of the methods to instantiate an [*abstract tokenizer*](#tokenizer-object):
|
|
60
|
-
- [fromFile](#fromfile-function)
|
|
61
|
-
- [fromStream](#fromstream-function)
|
|
60
|
+
- [fromFile](#fromfile-function)*
|
|
61
|
+
- [fromStream](#fromstream-function)*
|
|
62
62
|
- [fromWebStream](#fromwebstream-function)
|
|
63
63
|
- [fromBuffer](#frombuffer-function)
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
> **_NOTE:_** * `fromFile` and `fromStream` only available when importing this module with Node.js
|
|
66
66
|
|
|
67
67
|
All methods return a [`Tokenizer`](#tokenizer-object), either directly or via a promise.
|
|
68
68
|
|
|
@@ -362,23 +362,16 @@ import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
|
|
|
362
362
|
## Dependencies
|
|
363
363
|
|
|
364
364
|
The diagram below illustrates the primary dependencies of `strtok3`:
|
|
365
|
+
|
|
365
366
|
```mermaid
|
|
366
367
|
graph TD;
|
|
367
368
|
S(strtok3)-->P(peek-readable)
|
|
368
369
|
S(strtok3)-->TO("@tokenizer/token")
|
|
369
370
|
```
|
|
370
|
-
|
|
371
|
+
|
|
371
372
|
- [peek-readable](https://github.com/Borewit/peek-readable): Manages reading operations with peeking capabilities, allowing data to be previewed without advancing the read pointer.
|
|
372
373
|
- [@tokenizer/token](https://github.com/Borewit/tokenizer-token): Provides token definitions and utilities used by `strtok3` for interpreting binary data.
|
|
373
374
|
|
|
374
375
|
## Licence
|
|
375
376
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
Copyright (c) 2024 Borewit
|
|
379
|
-
|
|
380
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
381
|
-
|
|
382
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
383
|
-
|
|
384
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
377
|
+
This project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.
|
|
@@ -31,7 +31,7 @@ export class ReadStreamTokenizer extends AbstractTokenizer {
|
|
|
31
31
|
if (normOptions.length === 0) {
|
|
32
32
|
return 0;
|
|
33
33
|
}
|
|
34
|
-
const bytesRead = await this.streamReader.read(uint8Array
|
|
34
|
+
const bytesRead = await this.streamReader.read(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);
|
|
35
35
|
this.position += bytesRead;
|
|
36
36
|
if ((!options || !options.mayBeLess) && bytesRead < normOptions.length) {
|
|
37
37
|
throw new EndOfStreamError();
|
|
@@ -61,7 +61,7 @@ export class ReadStreamTokenizer extends AbstractTokenizer {
|
|
|
61
61
|
}
|
|
62
62
|
if (normOptions.length > 0) {
|
|
63
63
|
try {
|
|
64
|
-
bytesRead = await this.streamReader.peek(uint8Array
|
|
64
|
+
bytesRead = await this.streamReader.peek(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);
|
|
65
65
|
}
|
|
66
66
|
catch (err) {
|
|
67
67
|
if (options?.mayBeLess && err instanceof EndOfStreamError) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strtok3",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
4
4
|
"description": "A promise based streaming tokenizer",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"lint": "yarn run lint-md && yarn run lint-ts",
|
|
23
23
|
"fix": "yarn run biome lint --write",
|
|
24
24
|
"test": "mocha",
|
|
25
|
+
"bun:test": "bun run --bun test",
|
|
25
26
|
"test-coverage": "c8 yarn run test",
|
|
26
27
|
"send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
|
|
27
28
|
"start": "yarn run compile && yarn run lint && yarn run cover-test"
|
|
@@ -50,29 +51,30 @@
|
|
|
50
51
|
"bugs": {
|
|
51
52
|
"url": "https://github.com/Borewit/strtok3/issues"
|
|
52
53
|
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@tokenizer/token": "^0.3.0",
|
|
56
|
+
"peek-readable": "^7.0.0"
|
|
57
|
+
},
|
|
53
58
|
"devDependencies": {
|
|
54
59
|
"@biomejs/biome": "^1.9.4",
|
|
55
60
|
"@types/chai": "^5.0.1",
|
|
56
61
|
"@types/chai-as-promised": "^8.0.1",
|
|
57
62
|
"@types/debug": "^4.1.12",
|
|
58
63
|
"@types/mocha": "^10.0.10",
|
|
59
|
-
"@types/node": "^22.
|
|
64
|
+
"@types/node": "^22.13.8",
|
|
60
65
|
"c8": "^10.1.3",
|
|
61
|
-
"chai": "^5.
|
|
66
|
+
"chai": "^5.2.0",
|
|
62
67
|
"chai-as-promised": "^8.0.1",
|
|
63
68
|
"del-cli": "^6.0.0",
|
|
64
69
|
"mocha": "^11.1.0",
|
|
70
|
+
"node-readable-to-web-readable-stream": "^0.4.2",
|
|
65
71
|
"remark-cli": "^12.0.1",
|
|
66
72
|
"remark-preset-lint-recommended": "^7.0.1",
|
|
67
73
|
"token-types": "^6.0.0",
|
|
68
74
|
"ts-node": "^10.9.2",
|
|
69
|
-
"typescript": "^5.
|
|
75
|
+
"typescript": "^5.8.2",
|
|
70
76
|
"uint8array-extras": "^1.4.0"
|
|
71
77
|
},
|
|
72
|
-
"dependencies": {
|
|
73
|
-
"@tokenizer/token": "^0.3.0",
|
|
74
|
-
"peek-readable": "^6.1.0"
|
|
75
|
-
},
|
|
76
78
|
"keywords": [
|
|
77
79
|
"tokenizer",
|
|
78
80
|
"reader",
|
package/LICENSE
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2017, Borewit
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
-
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
6
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
7
|
-
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
10
|
-
Software.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
13
|
-
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
14
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
15
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|