strtok3 10.3.2 → 10.3.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2025 Borewit
3
+ Copyright © 2026 Borewit
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -229,7 +229,7 @@ readBuffer(buffer: Uint8Array, options?: IReadChunkOptions): Promise<number>;
229
229
  | Parameter | Type | Description |
230
230
  |------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
231
231
  | buffer | [Buffer](https://nodejs.org/api/buffer.html) &#124; Uint8Array | Target buffer to write the data read to |
232
- | options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read |
232
+ | options | [IReadChunkOptions](#ireadchunkoptions-interface) | An integer specifying the number of bytes to read |
233
233
 
234
234
  Return promise with number of bytes read.
235
235
  The number of bytes read may be less than requested if the `mayBeLess` flag is set.
@@ -245,7 +245,7 @@ peekBuffer(uint8Array: Uint8Array, options?: IReadChunkOptions): Promise<number>
245
245
  | Parameter | Type | Description |
246
246
  |------------|-----------------------------------------|-----------------------------------------------------|
247
247
  | buffer | Buffer &#124; Uint8Array | Target buffer to write the data read (peeked) to. |
248
- | options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read. | |
248
+ | options | [IReadChunkOptions](#ireadchunkoptions-interface) | An integer specifying the number of bytes to read. | |
249
249
 
250
250
  Return value `Promise<number>` Promise with number of bytes read. The number of bytes read may be less if the `mayBeLess` flag was set.
251
251
 
@@ -65,7 +65,7 @@ export declare abstract class AbstractTokenizer implements ITokenizer {
65
65
  peekNumber(token: IToken<number>): Promise<number>;
66
66
  /**
67
67
  * Ignore number of bytes, advances the pointer in under tokenizer-stream.
68
- * @param length - Number of bytes to ignore
68
+ * @param length - Number of bytes to ignore. Must be ≥ 0.
69
69
  * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
70
70
  */
71
71
  ignore(length: number): Promise<number>;
@@ -71,10 +71,13 @@ export class AbstractTokenizer {
71
71
  }
72
72
  /**
73
73
  * Ignore number of bytes, advances the pointer in under tokenizer-stream.
74
- * @param length - Number of bytes to ignore
74
+ * @param length - Number of bytes to ignore. Must be ≥ 0.
75
75
  * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
76
76
  */
77
77
  async ignore(length) {
78
+ if (length < 0) {
79
+ throw new RangeError('ignore length must be ≥ 0 bytes');
80
+ }
78
81
  if (this.fileInfo.size !== undefined) {
79
82
  const bytesLeft = this.fileInfo.size - this.position;
80
83
  if (length > bytesLeft) {
@@ -24,6 +24,9 @@ export declare class ReadStreamTokenizer extends AbstractTokenizer {
24
24
  * @returns Promise with number of bytes peeked
25
25
  */
26
26
  peekBuffer(uint8Array: Uint8Array, options?: IReadChunkOptions): Promise<number>;
27
+ /**
28
+ * @param length Number of bytes to ignore. Must be ≥ 0.
29
+ */
27
30
  ignore(length: number): Promise<number>;
28
31
  abort(): Promise<void>;
29
32
  close(): Promise<void>;
@@ -75,8 +75,13 @@ export class ReadStreamTokenizer extends AbstractTokenizer {
75
75
  }
76
76
  return bytesRead;
77
77
  }
78
+ /**
79
+ * @param length Number of bytes to ignore. Must be ≥ 0.
80
+ */
78
81
  async ignore(length) {
79
- // debug(`ignore ${this.position}...${this.position + length - 1}`);
82
+ if (length < 0) {
83
+ throw new RangeError('ignore length must be ≥ 0 bytes');
84
+ }
80
85
  const bufSize = Math.min(maxBufferSize, length);
81
86
  const buf = new Uint8Array(bufSize);
82
87
  let totBytesRead = 0;
@@ -13,7 +13,7 @@ export class WebStreamByobReader extends WebStreamReader {
13
13
  async readFromStream(buffer, mayBeLess) {
14
14
  if (buffer.length === 0)
15
15
  return 0;
16
- // @ts-ignore
16
+ // @ts-expect-error
17
17
  const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? undefined : buffer.length });
18
18
  if (result.done) {
19
19
  this.endOfStream = result.done;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strtok3",
3
- "version": "10.3.2",
3
+ "version": "10.3.5",
4
4
  "description": "A promise based streaming tokenizer",
5
5
  "author": {
6
6
  "name": "Borewit",
@@ -12,10 +12,11 @@
12
12
  },
13
13
  "scripts": {
14
14
  "clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'test/**/*.js' 'test/**/*.js.map'",
15
- "compile-src": "tsc -p lib",
15
+ "compile-src": "tsc -p lib --sourceMap false",
16
16
  "compile-test": "tsc -p test",
17
17
  "compile": "yarn run compile-src && yarn run compile-test",
18
18
  "build": "yarn run clean && yarn run compile",
19
+ "prepublishOnly": "yarn run build",
19
20
  "eslint": "eslint lib test",
20
21
  "lint:md": "remark -u preset-lint-recommended .",
21
22
  "lint:ts": "biome check",
@@ -25,14 +26,15 @@
25
26
  "bun:test": "bun run --bun test",
26
27
  "test-coverage": "c8 yarn run test",
27
28
  "send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
28
- "start": "yarn run compile && yarn run lint && yarn run cover-test"
29
+ "start": "yarn run compile && yarn run lint && yarn run cover-test",
30
+ "update-biome": "yarn add -D --exact @biomejs/biome && npx @biomejs/biome migrate --write"
29
31
  },
30
32
  "engines": {
31
33
  "node": ">=18"
32
34
  },
33
35
  "repository": {
34
36
  "type": "git",
35
- "url": "https://github.com/Borewit/strtok3.git"
37
+ "url": "git+https://github.com/Borewit/strtok3.git"
36
38
  },
37
39
  "license": "MIT",
38
40
  "type": "module",
@@ -55,21 +57,21 @@
55
57
  "@tokenizer/token": "^0.3.0"
56
58
  },
57
59
  "devDependencies": {
58
- "@biomejs/biome": "2.1.1",
60
+ "@biomejs/biome": "2.4.8",
59
61
  "@types/chai": "^5.2.2",
60
62
  "@types/chai-as-promised": "^8.0.2",
61
63
  "@types/debug": "^4.1.12",
62
64
  "@types/mocha": "^10.0.10",
63
- "@types/node": "^24.0.7",
64
- "c8": "^10.1.3",
65
+ "@types/node": "^24.1.0",
66
+ "c8": "^11.0.0",
65
67
  "chai": "^5.2.1",
66
- "chai-as-promised": "^8.0.1",
67
- "del-cli": "^6.0.0",
68
- "mocha": "^11.7.1",
68
+ "chai-as-promised": "^8.0.2",
69
+ "del-cli": "^7.0.0",
70
+ "mocha": "^11.7.5",
69
71
  "node-readable-to-web-readable-stream": "^0.4.2",
70
72
  "remark-cli": "^12.0.1",
71
73
  "remark-preset-lint-recommended": "^7.0.1",
72
- "token-types": "^6.0.3",
74
+ "token-types": "^6.1.2",
73
75
  "ts-node": "^10.9.2",
74
76
  "typescript": "^5.8.3",
75
77
  "uint8array-extras": "^1.4.0"