strtok3 7.0.0-alpha.9 → 7.0.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 +13 -7
- package/lib/AbstractTokenizer.d.ts +1 -1
- package/lib/AbstractTokenizer.js +1 -1
- package/lib/FsPromise.d.ts +2 -1
- package/lib/ReadStreamTokenizer.d.ts +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/types.d.ts +1 -1
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -30,6 +30,12 @@ It can read from:
|
|
|
30
30
|
npm install strtok3
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
### Compatibility
|
|
34
|
+
|
|
35
|
+
Module: version 7 migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
|
36
|
+
JavaScript is compliant with [ECMAScript 2019 (ES10)](https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019).
|
|
37
|
+
Requires Node.js ≥ 14.16 engine.
|
|
38
|
+
|
|
33
39
|
## API
|
|
34
40
|
|
|
35
41
|
Use one of the methods to instantiate an [*abstract tokenizer*](#tokenizer):
|
|
@@ -53,8 +59,8 @@ All of the strtok3 methods return a [*tokenizer*](#tokenizer), either directly o
|
|
|
53
59
|
Returns, via a promise, a [*tokenizer*](#tokenizer) which can be used to parse a file.
|
|
54
60
|
|
|
55
61
|
```js
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
import * as strtok3 from 'strtok3';
|
|
63
|
+
import * as Token from 'token-types';
|
|
58
64
|
|
|
59
65
|
(async () => {
|
|
60
66
|
|
|
@@ -81,8 +87,8 @@ Create [*tokenizer*](#tokenizer) from a node.js [readable stream](https://nodejs
|
|
|
81
87
|
Returns a [*tokenizer*](#tokenizer), via a Promise, which can be used to parse a buffer.
|
|
82
88
|
|
|
83
89
|
```js
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
import strtok3 from 'strtok3';
|
|
91
|
+
import * as Token from 'token-types';
|
|
86
92
|
|
|
87
93
|
strtok3.fromStream(stream).then(tokenizer => {
|
|
88
94
|
return tokenizer.readToken(Token.UINT8).then(myUint8Number => {
|
|
@@ -101,7 +107,7 @@ strtok3.fromStream(stream).then(tokenizer => {
|
|
|
101
107
|
Returns a [*tokenizer*](#tokenizer) which can be used to parse the provided buffer.
|
|
102
108
|
|
|
103
109
|
```js
|
|
104
|
-
|
|
110
|
+
import * as strtok3 from 'strtok3';
|
|
105
111
|
|
|
106
112
|
const tokenizer = strtok3.fromBuffer(buffer);
|
|
107
113
|
|
|
@@ -274,8 +280,8 @@ To convert a [Web-API readable stream](https://developer.mozilla.org/en-US/docs/
|
|
|
274
280
|
|
|
275
281
|
Example submodule-import:
|
|
276
282
|
```js
|
|
277
|
-
|
|
278
|
-
|
|
283
|
+
import * as strtok3core from 'strtok3/core'; // Submodule-import to prevent Node.js specific dependencies
|
|
284
|
+
import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
|
|
279
285
|
|
|
280
286
|
(async () => {
|
|
281
287
|
|
|
@@ -58,7 +58,7 @@ export declare abstract class AbstractTokenizer implements ITokenizer {
|
|
|
58
58
|
*/
|
|
59
59
|
peekNumber(token: IToken<number>): Promise<number>;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Ignore number of bytes, advances the pointer in under tokenizer-stream.
|
|
62
62
|
* @param length - Number of bytes to ignore
|
|
63
63
|
* @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
|
|
64
64
|
*/
|
package/lib/AbstractTokenizer.js
CHANGED
|
@@ -61,7 +61,7 @@ export class AbstractTokenizer {
|
|
|
61
61
|
return token.get(this.numBuffer, 0);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* Ignore number of bytes, advances the pointer in under tokenizer-stream.
|
|
65
65
|
* @param length - Number of bytes to ignore
|
|
66
66
|
* @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
|
|
67
67
|
*/
|
package/lib/FsPromise.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Module convert fs functions to promise based functions
|
|
3
3
|
*/
|
|
4
|
-
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
5
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
5
6
|
import fs from 'node:fs';
|
|
6
7
|
export interface IReadResult {
|
|
7
8
|
bytesRead: number;
|
package/lib/core.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strtok3",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "A promise based streaming tokenizer",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
@@ -22,12 +22,11 @@
|
|
|
22
22
|
"fix": "eslint lib test --ext .ts --ignore-pattern *.d.ts --fix",
|
|
23
23
|
"test": "mocha",
|
|
24
24
|
"test-coverage": "c8 npm run test",
|
|
25
|
-
"send-coveralls": "c8 report | coveralls",
|
|
26
25
|
"send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
|
|
27
26
|
"start": "npm run compile && npm run lint && npm run cover-test"
|
|
28
27
|
},
|
|
29
28
|
"engines": {
|
|
30
|
-
"node": "
|
|
29
|
+
"node": ">=14.16"
|
|
31
30
|
},
|
|
32
31
|
"repository": {
|
|
33
32
|
"type": "git",
|
|
@@ -51,31 +50,32 @@
|
|
|
51
50
|
"url": "https://github.com/Borewit/strtok3/issues"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@types/chai": "^4.3.
|
|
53
|
+
"@types/chai": "^4.3.1",
|
|
55
54
|
"@types/debug": "^4.1.7",
|
|
56
|
-
"@types/mocha": "^9.
|
|
57
|
-
"@types/node": "^
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
59
|
-
"@typescript-eslint/
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"eslint": "^
|
|
66
|
-
"eslint-plugin-import": "^2.
|
|
67
|
-
"eslint-plugin-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
55
|
+
"@types/mocha": "^9.1.0",
|
|
56
|
+
"@types/node": "^18.6.3",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
|
58
|
+
"@typescript-eslint/parser": "^5.32.0",
|
|
59
|
+
"c8": "^7.12.0",
|
|
60
|
+
"chai": "^4.3.6",
|
|
61
|
+
"del-cli": "^5.0.0",
|
|
62
|
+
"eslint": "^8.21.0",
|
|
63
|
+
"eslint-config-prettier": "^8.5.0",
|
|
64
|
+
"eslint-import-resolver-typescript": "^3.4.0",
|
|
65
|
+
"eslint-plugin-import": "^2.26.0",
|
|
66
|
+
"eslint-plugin-jsdoc": "^39.3.4",
|
|
67
|
+
"eslint-plugin-node": "^11.1.0",
|
|
68
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
|
69
|
+
"mocha": "^10.0.0",
|
|
70
|
+
"remark-cli": "^11.0.0",
|
|
70
71
|
"remark-preset-lint-recommended": "^6.1.2",
|
|
71
|
-
"token-types": "^
|
|
72
|
-
"ts-node": "^10.
|
|
73
|
-
"
|
|
74
|
-
"typescript": "^4.5.3"
|
|
72
|
+
"token-types": "^5.0.0",
|
|
73
|
+
"ts-node": "^10.9.1",
|
|
74
|
+
"typescript": "^4.7.4"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@tokenizer/token": "^0.3.0",
|
|
78
|
-
"peek-readable": "^5.0.0
|
|
78
|
+
"peek-readable": "^5.0.0"
|
|
79
79
|
},
|
|
80
80
|
"keywords": [
|
|
81
81
|
"tokenizer",
|