strtok3 6.2.4 → 6.3.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/lib/core.js CHANGED
@@ -1,29 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromBuffer = exports.fromStream = exports.EndOfStreamError = void 0;
4
- const ReadStreamTokenizer_1 = require("./ReadStreamTokenizer");
5
- const BufferTokenizer_1 = require("./BufferTokenizer");
6
- var peek_readable_1 = require("peek-readable");
7
- Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return peek_readable_1.EndOfStreamError; } });
8
- /**
9
- * Construct ReadStreamTokenizer from given Stream.
10
- * Will set fileSize, if provided given Stream has set the .path property/
11
- * @param stream - Read from Node.js Stream.Readable
12
- * @param fileInfo - Pass the file information, like size and MIME-type of the correspnding stream.
13
- * @returns ReadStreamTokenizer
14
- */
15
- function fromStream(stream, fileInfo) {
16
- fileInfo = fileInfo ? fileInfo : {};
17
- return new ReadStreamTokenizer_1.ReadStreamTokenizer(stream, fileInfo);
18
- }
19
- exports.fromStream = fromStream;
20
- /**
21
- * Construct ReadStreamTokenizer from given Buffer.
22
- * @param uint8Array - Uint8Array to tokenize
23
- * @param fileInfo - Pass additional file information to the tokenizer
24
- * @returns BufferTokenizer
25
- */
26
- function fromBuffer(uint8Array, fileInfo) {
27
- return new BufferTokenizer_1.BufferTokenizer(uint8Array, fileInfo);
28
- }
29
- exports.fromBuffer = fromBuffer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromBuffer = exports.fromStream = exports.EndOfStreamError = void 0;
4
+ const ReadStreamTokenizer_1 = require("./ReadStreamTokenizer");
5
+ const BufferTokenizer_1 = require("./BufferTokenizer");
6
+ var peek_readable_1 = require("peek-readable");
7
+ Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return peek_readable_1.EndOfStreamError; } });
8
+ /**
9
+ * Construct ReadStreamTokenizer from given Stream.
10
+ * Will set fileSize, if provided given Stream has set the .path property/
11
+ * @param stream - Read from Node.js Stream.Readable
12
+ * @param fileInfo - Pass the file information, like size and MIME-type of the corresponding stream.
13
+ * @returns ReadStreamTokenizer
14
+ */
15
+ function fromStream(stream, fileInfo) {
16
+ fileInfo = fileInfo ? fileInfo : {};
17
+ return new ReadStreamTokenizer_1.ReadStreamTokenizer(stream, fileInfo);
18
+ }
19
+ exports.fromStream = fromStream;
20
+ /**
21
+ * Construct ReadStreamTokenizer from given Buffer.
22
+ * @param uint8Array - Uint8Array to tokenize
23
+ * @param fileInfo - Pass additional file information to the tokenizer
24
+ * @returns BufferTokenizer
25
+ */
26
+ function fromBuffer(uint8Array, fileInfo) {
27
+ return new BufferTokenizer_1.BufferTokenizer(uint8Array, fileInfo);
28
+ }
29
+ exports.fromBuffer = fromBuffer;
package/lib/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- /// <reference types="node" />
2
- import { Readable } from 'stream';
3
- import { ReadStreamTokenizer } from './ReadStreamTokenizer';
4
- import * as core from './core';
5
- export { fromFile } from './FileTokenizer';
6
- export { ITokenizer, EndOfStreamError, fromBuffer, IFileInfo } from './core';
7
- export { IToken, IGetToken } from '@tokenizer/token';
8
- /**
9
- * Construct ReadStreamTokenizer from given Stream.
10
- * Will set fileSize, if provided given Stream has set the .path property.
11
- * @param stream - Node.js Stream.Readable
12
- * @param fileInfo - Pass additional file information to the tokenizer
13
- * @returns Tokenizer
14
- */
15
- export declare function fromStream(stream: Readable, fileInfo?: core.IFileInfo): Promise<ReadStreamTokenizer>;
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ import { ReadStreamTokenizer } from './ReadStreamTokenizer';
4
+ import * as core from './core';
5
+ export { fromFile } from './FileTokenizer';
6
+ export { ITokenizer, EndOfStreamError, fromBuffer, IFileInfo } from './core';
7
+ export { IToken, IGetToken } from '@tokenizer/token';
8
+ /**
9
+ * Construct ReadStreamTokenizer from given Stream.
10
+ * Will set fileSize, if provided given Stream has set the .path property.
11
+ * @param stream - Node.js Stream.Readable
12
+ * @param fileInfo - Pass additional file information to the tokenizer
13
+ * @returns Tokenizer
14
+ */
15
+ export declare function fromStream(stream: Readable, fileInfo?: core.IFileInfo): Promise<ReadStreamTokenizer>;
package/lib/index.js CHANGED
@@ -1,27 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromStream = exports.fromBuffer = exports.EndOfStreamError = exports.fromFile = void 0;
4
- const fs = require("./FsPromise");
5
- const core = require("./core");
6
- var FileTokenizer_1 = require("./FileTokenizer");
7
- Object.defineProperty(exports, "fromFile", { enumerable: true, get: function () { return FileTokenizer_1.fromFile; } });
8
- var core_1 = require("./core");
9
- Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return core_1.EndOfStreamError; } });
10
- Object.defineProperty(exports, "fromBuffer", { enumerable: true, get: function () { return core_1.fromBuffer; } });
11
- /**
12
- * Construct ReadStreamTokenizer from given Stream.
13
- * Will set fileSize, if provided given Stream has set the .path property.
14
- * @param stream - Node.js Stream.Readable
15
- * @param fileInfo - Pass additional file information to the tokenizer
16
- * @returns Tokenizer
17
- */
18
- async function fromStream(stream, fileInfo) {
19
- fileInfo = fileInfo ? fileInfo : {};
20
- if (stream.path) {
21
- const stat = await fs.stat(stream.path);
22
- fileInfo.path = stream.path;
23
- fileInfo.size = stat.size;
24
- }
25
- return core.fromStream(stream, fileInfo);
26
- }
27
- exports.fromStream = fromStream;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromStream = exports.fromBuffer = exports.EndOfStreamError = exports.fromFile = void 0;
4
+ const fs = require("./FsPromise");
5
+ const core = require("./core");
6
+ var FileTokenizer_1 = require("./FileTokenizer");
7
+ Object.defineProperty(exports, "fromFile", { enumerable: true, get: function () { return FileTokenizer_1.fromFile; } });
8
+ var core_1 = require("./core");
9
+ Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return core_1.EndOfStreamError; } });
10
+ Object.defineProperty(exports, "fromBuffer", { enumerable: true, get: function () { return core_1.fromBuffer; } });
11
+ /**
12
+ * Construct ReadStreamTokenizer from given Stream.
13
+ * Will set fileSize, if provided given Stream has set the .path property.
14
+ * @param stream - Node.js Stream.Readable
15
+ * @param fileInfo - Pass additional file information to the tokenizer
16
+ * @returns Tokenizer
17
+ */
18
+ async function fromStream(stream, fileInfo) {
19
+ fileInfo = fileInfo ? fileInfo : {};
20
+ if (stream.path) {
21
+ const stat = await fs.stat(stream.path);
22
+ fileInfo.path = stream.path;
23
+ fileInfo.size = stat.size;
24
+ }
25
+ return core.fromStream(stream, fileInfo);
26
+ }
27
+ exports.fromStream = fromStream;
package/lib/types.d.ts CHANGED
@@ -1,103 +1,103 @@
1
- /// <reference types="node" />
2
- import { IGetToken } from '@tokenizer/token';
3
- export interface IFileInfo {
4
- /**
5
- * File size in bytes
6
- */
7
- size?: number;
8
- /**
9
- * MIME-type of file
10
- */
11
- mimeType?: string;
12
- /**
13
- * File path
14
- */
15
- path?: string;
16
- /**
17
- * File URL
18
- */
19
- url?: string;
20
- }
21
- export interface IReadChunkOptions {
22
- /**
23
- * The offset in the buffer to start writing at; default is 0
24
- */
25
- offset?: number;
26
- /**
27
- * Number of bytes to read.
28
- */
29
- length?: number;
30
- /**
31
- * Position where to begin reading from the file.
32
- * Default it is `tokenizer.position`.
33
- * Position may not be less then `tokenizer.position`.
34
- */
35
- position?: number;
36
- /**
37
- * If set, will not throw an EOF error if not all of the requested data could be read
38
- */
39
- mayBeLess?: boolean;
40
- }
41
- /**
42
- * The tokenizer allows us to read or peek from the tokenizer-stream.
43
- * The tokenizer-stream is an abstraction of a stream, file or Buffer.
44
- */
45
- export interface ITokenizer {
46
- /**
47
- * Provide access to information of the underlying information stream or file.
48
- */
49
- fileInfo: IFileInfo;
50
- /**
51
- * Offset in bytes (= number of bytes read) since beginning of file or stream
52
- */
53
- position: number;
54
- /**
55
- * Peek (read ahead) buffer from tokenizer
56
- * @param buffer - Target buffer to fill with data peek from the tokenizer-stream
57
- * @param options - Read behaviour options
58
- * @returns Promise with number of bytes read
59
- */
60
- peekBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>;
61
- /**
62
- * Peek (read ahead) buffer from tokenizer
63
- * @param buffer - Target buffer to fill with data peeked from the tokenizer-stream
64
- * @param options - Additional read options
65
- * @returns Promise with number of bytes read
66
- */
67
- readBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>;
68
- /**
69
- * Peek a token from the tokenizer-stream.
70
- * @param token - Token to peek from the tokenizer-stream.
71
- * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
72
- * @param maybeless - If set, will not throw an EOF error if the less then the requested length could be read.
73
- */
74
- peekToken<T>(token: IGetToken<T>, position?: number | null, maybeless?: boolean): Promise<T>;
75
- /**
76
- * Read a token from the tokenizer-stream.
77
- * @param token - Token to peek from the tokenizer-stream.
78
- * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
79
- */
80
- readToken<T>(token: IGetToken<T>, position?: number): Promise<T>;
81
- /**
82
- * Peek a numeric token from the stream
83
- * @param token - Numeric token
84
- * @returns Promise with number
85
- */
86
- peekNumber(token: IGetToken<number>): Promise<number>;
87
- /**
88
- * Read a numeric token from the stream
89
- * @param token - Numeric token
90
- * @returns Promise with number
91
- */
92
- readNumber(token: IGetToken<number>): Promise<number>;
93
- /**
94
- * Ignore given number of bytes
95
- * @param length - Number of bytes ignored
96
- */
97
- ignore(length: number): Promise<number>;
98
- /**
99
- * Clean up resources.
100
- * It does not close the stream for StreamReader, but is does close the file-descriptor.
101
- */
102
- close(): Promise<void>;
103
- }
1
+ /// <reference types="node" />
2
+ import { IGetToken } from '@tokenizer/token';
3
+ export interface IFileInfo {
4
+ /**
5
+ * File size in bytes
6
+ */
7
+ size?: number;
8
+ /**
9
+ * MIME-type of file
10
+ */
11
+ mimeType?: string;
12
+ /**
13
+ * File path
14
+ */
15
+ path?: string;
16
+ /**
17
+ * File URL
18
+ */
19
+ url?: string;
20
+ }
21
+ export interface IReadChunkOptions {
22
+ /**
23
+ * The offset in the buffer to start writing at; default is 0
24
+ */
25
+ offset?: number;
26
+ /**
27
+ * Number of bytes to read.
28
+ */
29
+ length?: number;
30
+ /**
31
+ * Position where to begin reading from the file.
32
+ * Default it is `tokenizer.position`.
33
+ * Position may not be less then `tokenizer.position`.
34
+ */
35
+ position?: number;
36
+ /**
37
+ * If set, will not throw an EOF error if not all of the requested data could be read
38
+ */
39
+ mayBeLess?: boolean;
40
+ }
41
+ /**
42
+ * The tokenizer allows us to read or peek from the tokenizer-stream.
43
+ * The tokenizer-stream is an abstraction of a stream, file or Buffer.
44
+ */
45
+ export interface ITokenizer {
46
+ /**
47
+ * Provide access to information of the underlying information stream or file.
48
+ */
49
+ fileInfo: IFileInfo;
50
+ /**
51
+ * Offset in bytes (= number of bytes read) since beginning of file or stream
52
+ */
53
+ position: number;
54
+ /**
55
+ * Peek (read ahead) buffer from tokenizer
56
+ * @param buffer - Target buffer to fill with data peek from the tokenizer-stream
57
+ * @param options - Read behaviour options
58
+ * @returns Promise with number of bytes read
59
+ */
60
+ peekBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>;
61
+ /**
62
+ * Peek (read ahead) buffer from tokenizer
63
+ * @param buffer - Target buffer to fill with data peeked from the tokenizer-stream
64
+ * @param options - Additional read options
65
+ * @returns Promise with number of bytes read
66
+ */
67
+ readBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>;
68
+ /**
69
+ * Peek a token from the tokenizer-stream.
70
+ * @param token - Token to peek from the tokenizer-stream.
71
+ * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
72
+ * @param maybeless - If set, will not throw an EOF error if the less then the requested length could be read.
73
+ */
74
+ peekToken<T>(token: IGetToken<T>, position?: number | null, maybeless?: boolean): Promise<T>;
75
+ /**
76
+ * Read a token from the tokenizer-stream.
77
+ * @param token - Token to peek from the tokenizer-stream.
78
+ * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.
79
+ */
80
+ readToken<T>(token: IGetToken<T>, position?: number): Promise<T>;
81
+ /**
82
+ * Peek a numeric token from the stream
83
+ * @param token - Numeric token
84
+ * @returns Promise with number
85
+ */
86
+ peekNumber(token: IGetToken<number>): Promise<number>;
87
+ /**
88
+ * Read a numeric token from the stream
89
+ * @param token - Numeric token
90
+ * @returns Promise with number
91
+ */
92
+ readNumber(token: IGetToken<number>): Promise<number>;
93
+ /**
94
+ * Ignore given number of bytes
95
+ * @param length - Number of bytes ignored
96
+ */
97
+ ignore(length: number): Promise<number>;
98
+ /**
99
+ * Clean up resources.
100
+ * It does not close the stream for StreamReader, but is does close the file-descriptor.
101
+ */
102
+ close(): Promise<void>;
103
+ }
package/lib/types.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,101 +1,103 @@
1
- {
2
- "name": "strtok3",
3
- "version": "6.2.4",
4
- "description": "A promise based streaming tokenizer",
5
- "author": {
6
- "name": "Borewit",
7
- "url": "https://github.com/Borewit"
8
- },
9
- "funding": {
10
- "type": "github",
11
- "url": "https://github.com/sponsors/Borewit"
12
- },
13
- "scripts": {
14
- "clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts test/**/*.js test/**/*.js.map",
15
- "compile-src": "tsc -p lib",
16
- "compile-test": "tsc -p test",
17
- "compile": "npm run compile-src && npm run compile-test",
18
- "build": "npm run clean && npm run compile",
19
- "eslint": "eslint lib test --ext .ts --ignore-pattern *.d.ts",
20
- "lint-md": "remark -u preset-lint-recommended .",
21
- "lint": "npm run lint-md && npm run eslint",
22
- "fix": "eslint lib test --ext .ts --ignore-pattern *.d.ts --fix",
23
- "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test.ts",
24
- "test-coverage": "nyc npm run test",
25
- "send-coveralls": "nyc report --reporter=text-lcov | coveralls",
26
- "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage",
27
- "start": "npm run compile && npm run lint && npm run cover-test"
28
- },
29
- "engines": {
30
- "node": ">=10"
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/Borewit/strtok3.git"
35
- },
36
- "license": "MIT",
37
- "main": "lib/index.js",
38
- "types": "lib/index.d.ts",
39
- "files": [
40
- "lib/**/*.js",
41
- "lib/**/*.d.ts"
42
- ],
43
- "bugs": {
44
- "url": "https://github.com/Borewit/strtok3/issues"
45
- },
46
- "devDependencies": {
47
- "@types/chai": "^4.2.21",
48
- "@types/debug": "^4.1.7",
49
- "@types/mocha": "^9.0.0",
50
- "@types/node": "^16.4.7",
51
- "@typescript-eslint/eslint-plugin": "^2.34.0",
52
- "@typescript-eslint/eslint-plugin-tslint": "^4.28.5",
53
- "@typescript-eslint/parser": "^2.34.0",
54
- "chai": "^4.3.4",
55
- "coveralls": "^3.1.1",
56
- "del-cli": "^4.0.1",
57
- "eslint": "^6.8.0",
58
- "eslint-plugin-import": "^2.23.4",
59
- "eslint-plugin-prefer-arrow": "^1.2.3",
60
- "mocha": "^9.0.3",
61
- "nyc": "^15.1.0",
62
- "remark-cli": "^9.0.0",
63
- "remark-preset-lint-recommended": "^5.0.0",
64
- "source-map-support": "^0.5.16",
65
- "token-types": "^4.1.0",
66
- "ts-node": "^10.1.0",
67
- "tslint": "^6.1.3",
68
- "typescript": "^4.3.5"
69
- },
70
- "dependencies": {
71
- "@tokenizer/token": "^0.3.0",
72
- "peek-readable": "^4.0.1"
73
- },
74
- "keywords": [
75
- "tokenizer",
76
- "reader",
77
- "token",
78
- "async",
79
- "promise",
80
- "parser",
81
- "decoder",
82
- "binary",
83
- "endian",
84
- "uint",
85
- "stream",
86
- "streaming"
87
- ],
88
- "nyc": {
89
- "check-coverage": false,
90
- "extension": [
91
- ".ts"
92
- ],
93
- "sourceMap": true,
94
- "instrument": true,
95
- "reporter": [
96
- "lcov",
97
- "text"
98
- ],
99
- "report-dir": "coverage"
100
- }
101
- }
1
+ {
2
+ "name": "strtok3",
3
+ "version": "6.3.0",
4
+ "description": "A promise based streaming tokenizer",
5
+ "author": {
6
+ "name": "Borewit",
7
+ "url": "https://github.com/Borewit"
8
+ },
9
+ "funding": {
10
+ "type": "github",
11
+ "url": "https://github.com/sponsors/Borewit"
12
+ },
13
+ "scripts": {
14
+ "clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts test/**/*.js test/**/*.js.map",
15
+ "compile-src": "tsc -p lib",
16
+ "compile-test": "tsc -p test",
17
+ "compile": "npm run compile-src && npm run compile-test",
18
+ "build": "npm run clean && npm run compile",
19
+ "eslint": "eslint lib test --ext .ts --ignore-pattern *.d.ts",
20
+ "lint-md": "remark -u preset-lint-recommended .",
21
+ "lint": "npm run lint-md && npm run eslint",
22
+ "fix": "eslint lib test --ext .ts --ignore-pattern *.d.ts --fix",
23
+ "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test.ts",
24
+ "test-coverage": "nyc npm run test",
25
+ "send-coveralls": "nyc report --reporter=text-lcov | coveralls",
26
+ "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage",
27
+ "start": "npm run compile && npm run lint && npm run cover-test"
28
+ },
29
+ "engines": {
30
+ "node": ">=10"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/Borewit/strtok3.git"
35
+ },
36
+ "license": "MIT",
37
+ "main": "lib/index.js",
38
+ "types": "lib/index.d.ts",
39
+ "files": [
40
+ "lib/**/*.js",
41
+ "lib/**/*.d.ts"
42
+ ],
43
+ "bugs": {
44
+ "url": "https://github.com/Borewit/strtok3/issues"
45
+ },
46
+ "devDependencies": {
47
+ "@types/chai": "^4.3.0",
48
+ "@types/debug": "^4.1.7",
49
+ "@types/mocha": "^9.1.0",
50
+ "@types/node": "^17.0.14",
51
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
52
+ "@typescript-eslint/parser": "^5.10.2",
53
+ "chai": "^4.3.6",
54
+ "coveralls": "^3.1.1",
55
+ "del-cli": "^4.0.1",
56
+ "eslint": "^8.8.0",
57
+ "eslint-config-prettier": "^8.3.0",
58
+ "eslint-import-resolver-typescript": "^2.5.0",
59
+ "eslint-plugin-import": "^2.25.4",
60
+ "eslint-plugin-jsdoc": "^37.7.1",
61
+ "eslint-plugin-node": "^11.1.0",
62
+ "eslint-plugin-unicorn": "^40.1.0",
63
+ "mocha": "^9.2.0",
64
+ "nyc": "^15.1.0",
65
+ "remark-cli": "^10.0.1",
66
+ "remark-preset-lint-recommended": "^6.1.2",
67
+ "source-map-support": "^0.5.21",
68
+ "token-types": "^4.1.1",
69
+ "ts-node": "^10.4.0",
70
+ "typescript": "^4.5.5"
71
+ },
72
+ "dependencies": {
73
+ "@tokenizer/token": "^0.3.0",
74
+ "peek-readable": "^4.1.0"
75
+ },
76
+ "keywords": [
77
+ "tokenizer",
78
+ "reader",
79
+ "token",
80
+ "async",
81
+ "promise",
82
+ "parser",
83
+ "decoder",
84
+ "binary",
85
+ "endian",
86
+ "uint",
87
+ "stream",
88
+ "streaming"
89
+ ],
90
+ "nyc": {
91
+ "check-coverage": false,
92
+ "extension": [
93
+ ".ts"
94
+ ],
95
+ "sourceMap": true,
96
+ "instrument": true,
97
+ "reporter": [
98
+ "lcov",
99
+ "text"
100
+ ],
101
+ "report-dir": "coverage"
102
+ }
103
+ }