strtok3 10.1.1 → 10.2.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/LICENSE CHANGED
@@ -1,15 +1,15 @@
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
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
15
  OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,382 +1,384 @@
1
- [![Node.js CI](https://github.com/Borewit/strtok3/actions/workflows/nodejs-ci.yml/badge.svg?branch=master)](https://github.com/Borewit/strtok3/actions/workflows/nodejs-ci.yml?query=branch%3Amaster)
2
- [![CodeQL](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml)
3
- [![NPM version](https://badge.fury.io/js/strtok3.svg)](https://npmjs.org/package/strtok3)
4
- [![npm downloads](http://img.shields.io/npm/dm/strtok3.svg)](https://npmcharts.com/compare/strtok3,token-types?start=1200&interval=30)
5
- [![DeepScan grade](https://deepscan.io/api/teams/5165/projects/8526/branches/103329/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5165&pid=8526&bid=103329)
6
- [![Known Vulnerabilities](https://snyk.io/test/github/Borewit/strtok3/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/strtok3?targetFile=package.json)
7
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/59dd6795e61949fb97066ca52e6097ef)](https://www.codacy.com/app/Borewit/strtok3?utm_source=github.com&utm_medium=referral&utm_content=Borewit/strtok3&utm_campaign=Badge_Grade)
8
- # strtok3
9
-
10
- A promise based streaming [*tokenizer*](#tokenizer-object) for [Node.js](http://nodejs.org) and browsers.
11
-
12
- The `strtok3` module provides several methods for creating a [*tokenizer*](#tokenizer-object) from various input sources.
13
- Designed for:
14
- * Seamless support in streaming environments.
15
- * Efficiently decode binary data, strings, and numbers.
16
- * Reading [predefined](https://github.com/Borewit/token-types) or custom tokens.
17
- * Offering [*tokenizers*](#tokenizer-object) for reading from [files](#method-strtok3fromfile), [streams](#fromstream-function) or [Uint8Arrays](#frombuffer-function).
18
-
19
- ### Features
20
- `strtok3` can read from:
21
- * Files, using a file path as input.
22
- * Node.js [streams](https://nodejs.org/api/stream.html).
23
- * [Buffer](https://nodejs.org/api/buffer.html) or [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
24
- * HTTP chunked transfer provided by [@tokenizer/http](https://github.com/Borewit/tokenizer-http).
25
- * [Amazon S3](https://aws.amazon.com/s3) chunks with [@tokenizer/s3](https://github.com/Borewit/tokenizer-s3).
26
-
27
- ## Installation
28
-
29
- ```sh
30
- npm install strtok3
31
- ```
32
-
33
- ### Compatibility
34
-
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
- 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
-
38
- For TypeScript CommonJs backward compatibility, you can use [load-esm](https://github.com/Borewit/load-esm).
39
-
40
- > [!NOTE]
41
- > This module requires a [Node.js ≥ 16](https://nodejs.org/en/about/previous-releases) engine.
42
- > It can also be used in a browser environment when bundled with a module bundler.
43
-
44
- ## Support the Project
45
- If you find this project useful and would like to support its development, consider sponsoring or contributing:
46
-
47
- - [Become a sponsor to Borewit](https://github.com/sponsors/Borewit)
48
-
49
- - Buy me a coffee:
50
-
51
- <a href="https://www.buymeacoffee.com/borewit" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy me A coffee" height="41" width="174"></a>
52
-
53
- ## API Documentation
54
-
55
- ### strtok3 methods
56
-
57
- Use one of the methods to instantiate an [*abstract tokenizer*](#tokenizer-object):
58
- - [fromFile](#fromfile-function)[^1]
59
- - [fromStream](#fromstream-function)[^1]
60
- - [fromWebStream](#fromwebstream-function)
61
- - [fromBuffer](#frombuffer-function)
62
-
63
- [^1]: Only available when importing this module with Node.js
64
-
65
- All methods return a [`Tokenizer`](#tokenizer-object), either directly or via a promise.
66
-
67
- #### `fromFile` function
68
-
69
- Creates a [*tokenizer*](#tokenizer-object) from a local file.
70
-
71
- ```ts
72
- function fromFile(sourceFilePath: string): Promise<FileTokenizer>
73
- ```
74
-
75
- | Parameter | Type | Description |
76
- |----------------|----------|----------------------------|
77
- | sourceFilePath | `string` | Path to file to read from |
78
-
79
- > [!NOTE]
80
- > - Only available for Node.js engines
81
- > - `fromFile` automatically embeds [file-information](#file-information)
82
-
83
- Returns, via a promise, a [*tokenizer*](#tokenizer-object) which can be used to parse a file.
84
-
85
- ```js
86
- import * as strtok3 from 'strtok3';
87
- import * as Token from 'token-types';
88
-
89
- (async () => {
90
-
91
- const tokenizer = await strtok3.fromFile("somefile.bin");
92
- try {
93
- const myNumber = await tokenizer.readToken(Token.UINT8);
94
- console.log(`My number: ${myNumber}`);
95
- } finally {
96
- tokenizer.close(); // Close the file
97
- }
98
- })();
99
- ```
100
-
101
- #### `fromStream` function
102
-
103
- Creates a [*tokenizer*](#tokenizer-object) from a Node.js [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable).
104
-
105
- ```ts
106
- function fromStream(stream: Readable, options?: ITokenizerOptions): Promise<ReadStreamTokenizer>
107
- ```
108
-
109
- | Parameter | Optional | Type | Description |
110
- |-----------|-----------|-------------------------|--------------------------|
111
- | stream | no | [Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable) | Stream to read from |
112
- | fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information |
113
-
114
- Returns a Promise providing a [*tokenizer*](#tokenizer-object).
115
-
116
- > [!NOTE]
117
- > - Only available for Node.js engines
118
-
119
- #### `fromWebStream` function
120
-
121
- Creates [*tokenizer*](#tokenizer-object) from a [WHATWG ReadableStream](https://nodejs.org/api/webstreams.html#web-streams-api).
122
-
123
- ```ts
124
- function fromWebStream(webStream: AnyWebByteStream, options?: ITokenizerOptions): ReadStreamTokenizer
125
- ```
126
-
127
- | Parameter | Optional | Type | Description |
128
- |----------------|-----------|--------------------------------------------------------------------------|------------------------------------|
129
- | readableStream | no | [ReadableStream](https://nodejs.org/api/webstreams.html#web-streams-api) | WHATWG ReadableStream to read from |
130
- | fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information |
131
-
132
- Returns a Promise providing a [*tokenizer*](#tokenizer-object)
133
-
134
- ```js
135
- import strtok3 from 'strtok3';
136
- import * as Token from 'token-types';
137
-
138
- strtok3.fromWebStream(readableStream).then(tokenizer => {
139
- return tokenizer.readToken(Token.UINT8).then(myUint8Number => {
140
- console.log(`My number: ${myUint8Number}`);
141
- });
142
- });
143
- ```
144
-
145
- #### `fromBuffer()` function
146
-
147
- Create a tokenizer from memory ([Uint8Array](https://nodejs.org/api/buffer.html)).
148
-
149
- ```ts
150
- function fromBuffer(uint8Array: Uint8Array, options?: ITokenizerOptions): BufferTokenizer
151
- ```
152
-
153
- | Parameter | Optional | Type | Description |
154
- |------------|----------|--------------------------------------------------|----------------------------------------|
155
- | uint8Array | no | [Uint8Array](https://nodejs.org/api/buffer.html) | Uint8Array or Buffer to read from |
156
- | fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information |
157
-
158
- Returns a Promise providing a [*tokenizer*](#tokenizer-object).
159
-
160
- ```js
161
- import * as strtok3 from 'strtok3';
162
-
163
- const tokenizer = strtok3.fromBuffer(buffer);
164
-
165
- tokenizer.readToken(Token.UINT8).then(myUint8Number => {
166
- console.log(`My number: ${myUint8Number}`);
167
- });
168
- ```
169
-
170
- ### `Tokenizer` object
171
- The *tokenizer* is an abstraction of a [stream](https://nodejs.org/api/stream.html), file or [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), allowing _reading_ or _peeking_ from the stream.
172
- It can also be translated in chunked reads, as done in [@tokenizer/http](https://github.com/Borewit/tokenizer-http);
173
-
174
- #### Key Features:
175
-
176
- - Supports seeking within the stream using `tokenizer.ignore()`.
177
- - Offers `peek` methods to preview data without advancing the read pointer.
178
- - Maintains the read position via tokenizer.position.
179
-
180
- #### Tokenizer functions
181
-
182
- _Read_ methods advance the stream pointer, while _peek_ methods do not.
183
-
184
- There are two kind of functions:
185
- 1. *read* methods: used to read a *token* of [Buffer](https://nodejs.org/api/buffer.html) from the [*tokenizer*](#tokenizer-object). The position of the *tokenizer-stream* will advance with the size of the token.
186
- 2. *peek* methods: same as the read, but it will *not* advance the pointer. It allows to read (peek) ahead.
187
-
188
- #### `readBuffer` function
189
-
190
- Read data from the _tokenizer_ into provided "buffer" (`Uint8Array`).
191
- `readBuffer(buffer, options?)`
192
-
193
- ```ts
194
- readBuffer(buffer: Uint8Array, options?: IReadChunkOptions): Promise<number>;
195
- ```
196
-
197
- | Parameter | Type | Description |
198
- |------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
199
- | buffer | [Buffer](https://nodejs.org/api/buffer.html) &#124; Uint8Array | Target buffer to write the data read to |
200
- | options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read |
201
-
202
- Return promise with number of bytes read.
203
- The number of bytes read maybe if less, *mayBeLess* flag was set.
204
-
205
- #### `peekBuffer` function
206
-
207
- Peek (read ahead), from [*tokenizer*](#tokenizer-object), into the buffer without advancing the stream pointer.
208
-
209
- ```ts
210
- peekBuffer(uint8Array: Uint8Array, options?: IReadChunkOptions): Promise<number>;
211
- ```
212
-
213
- | Parameter | Type | Description |
214
- |------------|-----------------------------------------|-----------------------------------------------------|
215
- | buffer | Buffer &#124; Uint8Array | Target buffer to write the data read (peeked) to. |
216
- | options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read. | |
217
-
218
- Return value `Promise<number>` Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set.
219
-
220
- #### `readToken` function
221
-
222
- Read a *token* from the tokenizer-stream.
223
-
224
- ```ts
225
- readToken<Value>(token: IGetToken<Value>, position: number = this.position): Promise<Value>
226
- ```
227
-
228
- | Parameter | Type | Description |
229
- |------------|-------------------------|---------------------------------------------------------------------------------------------------------------------- |
230
- | token | [IGetToken](#IGetToken) | Token to read from the tokenizer-stream. |
231
- | position? | number | Offset where to begin reading within the file. If position is null, data will be read from the current file position. |
232
-
233
- Return value `Promise<number>`. Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set.
234
-
235
- #### `peek` function
236
-
237
- Peek a *token* from the [*tokenizer*](#tokenizer-object).
238
-
239
- ```ts
240
- peekToken<Value>(token: IGetToken<Value>, position: number = this.position): Promise<Value>
241
- ```
242
-
243
- | Parameter | Type | Description |
244
- |------------|----------------------------|-------------------------------------------------------------------------------------------------------------------------|
245
- | token | [IGetToken<T>](#IGetToken) | Token to read from the tokenizer-stream. |
246
- | position? | number | Offset where to begin reading within the file. If position is null, data will be read from the current file position. |
247
-
248
- Return a promise with the token value peeked from the [*tokenizer*](#tokenizer-object).
249
-
250
- #### `readNumber` function
251
-
252
- Peek a numeric [*token*](#token) from the [*tokenizer*](#tokenizer-object).
253
-
254
- ```ts
255
- readNumber(token: IToken<number>): Promise<number>
256
- ```
257
-
258
- | Parameter | Type | Description |
259
- |------------|---------------------------------|----------------------------------------------------|
260
- | token | [IGetToken<number>](#IGetToken) | Numeric token to read from the tokenizer-stream. |
261
-
262
- Returns a promise with the decoded numeric value from the *tokenizer-stream*.
263
-
264
- #### `ignore` function
265
-
266
- Advance the offset pointer with the token number of bytes provided.
267
-
268
- ```ts
269
- ignore(length: number): Promise<number>
270
- ```
271
-
272
- | Parameter | Type | Description |
273
- |------------|--------|----------------------------------------------------------------------|
274
- | ignore | number | Numeric of bytes to ignore. Will advance the `tokenizer.position` |
275
-
276
- Returns a promise with the decoded numeric value from the *tokenizer-stream*.
277
-
278
- #### `close` function
279
- Clean up resources, such as closing a file pointer if applicable.
280
-
281
- #### `Tokenizer` attributes
282
-
283
- - `fileInfo`
284
-
285
- Optional attribute describing the file information, see [IFileInfo](#IFileInfo)
286
-
287
- - `position`
288
-
289
- Pointer to the current position in the [*tokenizer*](#tokenizer-object) stream.
290
- If a *position* is provided to a _read_ or _peek_ method, is should be, at least, equal or greater than this value.
291
-
292
- ### `IReadChunkOptions` interface
293
-
294
- Each attribute is optional:
295
-
296
- | Attribute | Type | Description |
297
- |-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
298
- | length | number | Requested number of bytes to read. |
299
- | position | number | Position where to peek from the file. If position is null, data will be read from the [current file position](#attribute-tokenizerposition). Position may not be less then [tokenizer.position](#attribute-tokenizerposition) |
300
- | mayBeLess | boolean | If and only if set, will not throw an EOF error if less then the requested *mayBeLess* could be read. |
301
-
302
- Example usage:
303
- ```js
304
- tokenizer.peekBuffer(buffer, {mayBeLess: true});
305
- ```
306
-
307
- ### `IFileInfo` interface
308
-
309
- Provides optional metadata about the file being tokenized.
310
-
311
- | Attribute | Type | Description |
312
- |-----------|---------|---------------------------------------------------------------------------------------------------|
313
- | size | number | File size in bytes |
314
- | mimeType | number | [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of file. |
315
- | path | number | File path |
316
- | url | boolean | File URL |
317
-
318
- ### `Token` object
319
-
320
- The *token* is basically a description what to read form the [*tokenizer-stream*](#tokenizer-object).
321
- A basic set of *token types* can be found here: [*token-types*](https://github.com/Borewit/token-types).
322
-
323
- A token is something which implements the following interface:
324
- ```ts
325
- export interface IGetToken<T> {
326
-
327
- /**
328
- * Length in bytes of encoded value
329
- */
330
- len: number;
331
-
332
- /**
333
- * Decode value from buffer at offset
334
- * @param buf Buffer to read the decoded value from
335
- * @param off Decode offset
336
- */
337
- get(buf: Uint8Array, off: number): T;
338
- }
339
- ```
340
- The *tokenizer* reads `token.len` bytes from the *tokenizer-stream* into a Buffer.
341
- The `token.get` will be called with the Buffer. `token.get` is responsible for conversion from the buffer to the desired output type.
342
-
343
- ### Working with Web-API readable stream
344
- To convert a [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) into a [Node.js readable stream]((https://nodejs.org/api/stream.html#stream_readable_streams)), you can use [readable-web-to-node-stream](https://github.com/Borewit/readable-web-to-node-stream) to convert one in another.
345
-
346
- ```js
347
- import { fromWebStream } strtok3 from 'strtok3';
348
- import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
349
-
350
- (async () => {
351
-
352
- const response = await fetch(url);
353
- const readableWebStream = response.body; // Web-API readable stream
354
- const webStream = new ReadableWebToNodeStream(readableWebStream); // convert to Node.js readable stream
355
-
356
- const tokenizer = fromWebStream(webStream); // And we now have tokenizer in a web environment
357
- })();
358
- ```
359
-
360
- ## Dependencies
361
-
362
- The diagram below illustrates the primary dependencies of `strtok3`:
363
- ```mermaid
364
- graph TD;
365
- S(strtok3)-->P(peek-readable)
366
- S(strtok3)-->TO("@tokenizer/token")
367
- ```
368
- -
369
- - [peek-readable](https://github.com/Borewit/peek-readable): Manages reading operations with peeking capabilities, allowing data to be previewed without advancing the read pointer.
370
- - [@tokenizer/token](https://github.com/Borewit/tokenizer-token): Provides token definitions and utilities used by `strtok3` for interpreting binary data.
371
-
372
- ## Licence
373
-
374
- (The MIT License)
375
-
376
- Copyright (c) 2024 Borewit
377
-
378
- 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:
379
-
380
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
381
-
382
- 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.
1
+ [![Node.js CI](https://github.com/Borewit/strtok3/actions/workflows/nodejs-ci.yml/badge.svg?branch=master)](https://github.com/Borewit/strtok3/actions/workflows/nodejs-ci.yml?query=branch%3Amaster)
2
+ [![CodeQL](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml)
3
+ [![NPM version](https://badge.fury.io/js/strtok3.svg)](https://npmjs.org/package/strtok3)
4
+ [![npm downloads](http://img.shields.io/npm/dm/strtok3.svg)](https://npmcharts.com/compare/strtok3,token-types?start=1200&interval=30)
5
+ [![DeepScan grade](https://deepscan.io/api/teams/5165/projects/8526/branches/103329/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5165&pid=8526&bid=103329)
6
+ [![Known Vulnerabilities](https://snyk.io/test/github/Borewit/strtok3/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/strtok3?targetFile=package.json)
7
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/59dd6795e61949fb97066ca52e6097ef)](https://www.codacy.com/app/Borewit/strtok3?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Borewit/strtok3&amp;utm_campaign=Badge_Grade)
8
+ # strtok3
9
+
10
+ A promise based streaming [*tokenizer*](#tokenizer-object) for [Node.js](http://nodejs.org) and browsers.
11
+
12
+ The `strtok3` module provides several methods for creating a [*tokenizer*](#tokenizer-object) from various input sources.
13
+ Designed for:
14
+ * Seamless support in streaming environments.
15
+ * Efficiently decode binary data, strings, and numbers.
16
+ * Reading [predefined](https://github.com/Borewit/token-types) or custom tokens.
17
+ * Offering [*tokenizers*](#tokenizer-object) for reading from [files](#method-strtok3fromfile), [streams](#fromstream-function) or [Uint8Arrays](#frombuffer-function).
18
+
19
+ ### Features
20
+ `strtok3` can read from:
21
+ * Files, using a file path as input.
22
+ * Node.js [streams](https://nodejs.org/api/stream.html).
23
+ * [Buffer](https://nodejs.org/api/buffer.html) or [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
24
+ * HTTP chunked transfer provided by [@tokenizer/http](https://github.com/Borewit/tokenizer-http).
25
+ * [Amazon S3](https://aws.amazon.com/s3) chunks with [@tokenizer/s3](https://github.com/Borewit/tokenizer-s3).
26
+
27
+ ## Installation
28
+
29
+ ```sh
30
+ npm install strtok3
31
+ ```
32
+
33
+ ### Compatibility
34
+
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
+ 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
+
38
+ Requires a modern browser or Node.js ≥ 18 engine.
39
+
40
+ For TypeScript CommonJs backward compatibility, you can use [load-esm](https://github.com/Borewit/load-esm).
41
+
42
+ > [!NOTE]
43
+ > This module requires a [Node.js ≥ 16](https://nodejs.org/en/about/previous-releases) engine.
44
+ > It can also be used in a browser environment when bundled with a module bundler.
45
+
46
+ ## Support the Project
47
+ If you find this project useful and would like to support its development, consider sponsoring or contributing:
48
+
49
+ - [Become a sponsor to Borewit](https://github.com/sponsors/Borewit)
50
+
51
+ - Buy me a coffee:
52
+
53
+ <a href="https://www.buymeacoffee.com/borewit" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy me A coffee" height="41" width="174"></a>
54
+
55
+ ## API Documentation
56
+
57
+ ### strtok3 methods
58
+
59
+ Use one of the methods to instantiate an [*abstract tokenizer*](#tokenizer-object):
60
+ - [fromFile](#fromfile-function)[^1]
61
+ - [fromStream](#fromstream-function)[^1]
62
+ - [fromWebStream](#fromwebstream-function)
63
+ - [fromBuffer](#frombuffer-function)
64
+
65
+ [^1]: Only available when importing this module with Node.js
66
+
67
+ All methods return a [`Tokenizer`](#tokenizer-object), either directly or via a promise.
68
+
69
+ #### `fromFile` function
70
+
71
+ Creates a [*tokenizer*](#tokenizer-object) from a local file.
72
+
73
+ ```ts
74
+ function fromFile(sourceFilePath: string): Promise<FileTokenizer>
75
+ ```
76
+
77
+ | Parameter | Type | Description |
78
+ |----------------|----------|----------------------------|
79
+ | sourceFilePath | `string` | Path to file to read from |
80
+
81
+ > [!NOTE]
82
+ > - Only available for Node.js engines
83
+ > - `fromFile` automatically embeds [file-information](#file-information)
84
+
85
+ Returns, via a promise, a [*tokenizer*](#tokenizer-object) which can be used to parse a file.
86
+
87
+ ```js
88
+ import * as strtok3 from 'strtok3';
89
+ import * as Token from 'token-types';
90
+
91
+ (async () => {
92
+
93
+ const tokenizer = await strtok3.fromFile("somefile.bin");
94
+ try {
95
+ const myNumber = await tokenizer.readToken(Token.UINT8);
96
+ console.log(`My number: ${myNumber}`);
97
+ } finally {
98
+ tokenizer.close(); // Close the file
99
+ }
100
+ })();
101
+ ```
102
+
103
+ #### `fromStream` function
104
+
105
+ Creates a [*tokenizer*](#tokenizer-object) from a Node.js [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable).
106
+
107
+ ```ts
108
+ function fromStream(stream: Readable, options?: ITokenizerOptions): Promise<ReadStreamTokenizer>
109
+ ```
110
+
111
+ | Parameter | Optional | Type | Description |
112
+ |-----------|-----------|-------------------------|--------------------------|
113
+ | stream | no | [Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable) | Stream to read from |
114
+ | fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information |
115
+
116
+ Returns a Promise providing a [*tokenizer*](#tokenizer-object).
117
+
118
+ > [!NOTE]
119
+ > - Only available for Node.js engines
120
+
121
+ #### `fromWebStream` function
122
+
123
+ Creates [*tokenizer*](#tokenizer-object) from a [WHATWG ReadableStream](https://nodejs.org/api/webstreams.html#web-streams-api).
124
+
125
+ ```ts
126
+ function fromWebStream(webStream: AnyWebByteStream, options?: ITokenizerOptions): ReadStreamTokenizer
127
+ ```
128
+
129
+ | Parameter | Optional | Type | Description |
130
+ |----------------|-----------|--------------------------------------------------------------------------|------------------------------------|
131
+ | readableStream | no | [ReadableStream](https://nodejs.org/api/webstreams.html#web-streams-api) | WHATWG ReadableStream to read from |
132
+ | fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information |
133
+
134
+ Returns a Promise providing a [*tokenizer*](#tokenizer-object)
135
+
136
+ ```js
137
+ import strtok3 from 'strtok3';
138
+ import * as Token from 'token-types';
139
+
140
+ strtok3.fromWebStream(readableStream).then(tokenizer => {
141
+ return tokenizer.readToken(Token.UINT8).then(myUint8Number => {
142
+ console.log(`My number: ${myUint8Number}`);
143
+ });
144
+ });
145
+ ```
146
+
147
+ #### `fromBuffer()` function
148
+
149
+ Create a tokenizer from memory ([Uint8Array](https://nodejs.org/api/buffer.html)).
150
+
151
+ ```ts
152
+ function fromBuffer(uint8Array: Uint8Array, options?: ITokenizerOptions): BufferTokenizer
153
+ ```
154
+
155
+ | Parameter | Optional | Type | Description |
156
+ |------------|----------|--------------------------------------------------|----------------------------------------|
157
+ | uint8Array | no | [Uint8Array](https://nodejs.org/api/buffer.html) | Uint8Array or Buffer to read from |
158
+ | fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information |
159
+
160
+ Returns a Promise providing a [*tokenizer*](#tokenizer-object).
161
+
162
+ ```js
163
+ import * as strtok3 from 'strtok3';
164
+
165
+ const tokenizer = strtok3.fromBuffer(buffer);
166
+
167
+ tokenizer.readToken(Token.UINT8).then(myUint8Number => {
168
+ console.log(`My number: ${myUint8Number}`);
169
+ });
170
+ ```
171
+
172
+ ### `Tokenizer` object
173
+ The *tokenizer* is an abstraction of a [stream](https://nodejs.org/api/stream.html), file or [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), allowing _reading_ or _peeking_ from the stream.
174
+ It can also be translated in chunked reads, as done in [@tokenizer/http](https://github.com/Borewit/tokenizer-http);
175
+
176
+ #### Key Features:
177
+
178
+ - Supports seeking within the stream using `tokenizer.ignore()`.
179
+ - Offers `peek` methods to preview data without advancing the read pointer.
180
+ - Maintains the read position via tokenizer.position.
181
+
182
+ #### Tokenizer functions
183
+
184
+ _Read_ methods advance the stream pointer, while _peek_ methods do not.
185
+
186
+ There are two kind of functions:
187
+ 1. *read* methods: used to read a *token* of [Buffer](https://nodejs.org/api/buffer.html) from the [*tokenizer*](#tokenizer-object). The position of the *tokenizer-stream* will advance with the size of the token.
188
+ 2. *peek* methods: same as the read, but it will *not* advance the pointer. It allows to read (peek) ahead.
189
+
190
+ #### `readBuffer` function
191
+
192
+ Read data from the _tokenizer_ into provided "buffer" (`Uint8Array`).
193
+ `readBuffer(buffer, options?)`
194
+
195
+ ```ts
196
+ readBuffer(buffer: Uint8Array, options?: IReadChunkOptions): Promise<number>;
197
+ ```
198
+
199
+ | Parameter | Type | Description |
200
+ |------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
201
+ | buffer | [Buffer](https://nodejs.org/api/buffer.html) &#124; Uint8Array | Target buffer to write the data read to |
202
+ | options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read |
203
+
204
+ Return promise with number of bytes read.
205
+ The number of bytes read maybe if less, *mayBeLess* flag was set.
206
+
207
+ #### `peekBuffer` function
208
+
209
+ Peek (read ahead), from [*tokenizer*](#tokenizer-object), into the buffer without advancing the stream pointer.
210
+
211
+ ```ts
212
+ peekBuffer(uint8Array: Uint8Array, options?: IReadChunkOptions): Promise<number>;
213
+ ```
214
+
215
+ | Parameter | Type | Description |
216
+ |------------|-----------------------------------------|-----------------------------------------------------|
217
+ | buffer | Buffer &#124; Uint8Array | Target buffer to write the data read (peeked) to. |
218
+ | options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read. | |
219
+
220
+ Return value `Promise<number>` Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set.
221
+
222
+ #### `readToken` function
223
+
224
+ Read a *token* from the tokenizer-stream.
225
+
226
+ ```ts
227
+ readToken<Value>(token: IGetToken<Value>, position: number = this.position): Promise<Value>
228
+ ```
229
+
230
+ | Parameter | Type | Description |
231
+ |------------|-------------------------|---------------------------------------------------------------------------------------------------------------------- |
232
+ | token | [IGetToken](#IGetToken) | Token to read from the tokenizer-stream. |
233
+ | position? | number | Offset where to begin reading within the file. If position is null, data will be read from the current file position. |
234
+
235
+ Return value `Promise<number>`. Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set.
236
+
237
+ #### `peek` function
238
+
239
+ Peek a *token* from the [*tokenizer*](#tokenizer-object).
240
+
241
+ ```ts
242
+ peekToken<Value>(token: IGetToken<Value>, position: number = this.position): Promise<Value>
243
+ ```
244
+
245
+ | Parameter | Type | Description |
246
+ |------------|----------------------------|-------------------------------------------------------------------------------------------------------------------------|
247
+ | token | [IGetToken<T>](#IGetToken) | Token to read from the tokenizer-stream. |
248
+ | position? | number | Offset where to begin reading within the file. If position is null, data will be read from the current file position. |
249
+
250
+ Return a promise with the token value peeked from the [*tokenizer*](#tokenizer-object).
251
+
252
+ #### `readNumber` function
253
+
254
+ Peek a numeric [*token*](#token) from the [*tokenizer*](#tokenizer-object).
255
+
256
+ ```ts
257
+ readNumber(token: IToken<number>): Promise<number>
258
+ ```
259
+
260
+ | Parameter | Type | Description |
261
+ |------------|---------------------------------|----------------------------------------------------|
262
+ | token | [IGetToken<number>](#IGetToken) | Numeric token to read from the tokenizer-stream. |
263
+
264
+ Returns a promise with the decoded numeric value from the *tokenizer-stream*.
265
+
266
+ #### `ignore` function
267
+
268
+ Advance the offset pointer with the token number of bytes provided.
269
+
270
+ ```ts
271
+ ignore(length: number): Promise<number>
272
+ ```
273
+
274
+ | Parameter | Type | Description |
275
+ |------------|--------|----------------------------------------------------------------------|
276
+ | ignore | number | Numeric of bytes to ignore. Will advance the `tokenizer.position` |
277
+
278
+ Returns a promise with the decoded numeric value from the *tokenizer-stream*.
279
+
280
+ #### `close` function
281
+ Clean up resources, such as closing a file pointer if applicable.
282
+
283
+ #### `Tokenizer` attributes
284
+
285
+ - `fileInfo`
286
+
287
+ Optional attribute describing the file information, see [IFileInfo](#IFileInfo)
288
+
289
+ - `position`
290
+
291
+ Pointer to the current position in the [*tokenizer*](#tokenizer-object) stream.
292
+ If a *position* is provided to a _read_ or _peek_ method, is should be, at least, equal or greater than this value.
293
+
294
+ ### `IReadChunkOptions` interface
295
+
296
+ Each attribute is optional:
297
+
298
+ | Attribute | Type | Description |
299
+ |-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
300
+ | length | number | Requested number of bytes to read. |
301
+ | position | number | Position where to peek from the file. If position is null, data will be read from the [current file position](#attribute-tokenizerposition). Position may not be less then [tokenizer.position](#attribute-tokenizerposition) |
302
+ | mayBeLess | boolean | If and only if set, will not throw an EOF error if less then the requested *mayBeLess* could be read. |
303
+
304
+ Example usage:
305
+ ```js
306
+ tokenizer.peekBuffer(buffer, {mayBeLess: true});
307
+ ```
308
+
309
+ ### `IFileInfo` interface
310
+
311
+ Provides optional metadata about the file being tokenized.
312
+
313
+ | Attribute | Type | Description |
314
+ |-----------|---------|---------------------------------------------------------------------------------------------------|
315
+ | size | number | File size in bytes |
316
+ | mimeType | number | [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of file. |
317
+ | path | number | File path |
318
+ | url | boolean | File URL |
319
+
320
+ ### `Token` object
321
+
322
+ The *token* is basically a description what to read form the [*tokenizer-stream*](#tokenizer-object).
323
+ A basic set of *token types* can be found here: [*token-types*](https://github.com/Borewit/token-types).
324
+
325
+ A token is something which implements the following interface:
326
+ ```ts
327
+ export interface IGetToken<T> {
328
+
329
+ /**
330
+ * Length in bytes of encoded value
331
+ */
332
+ len: number;
333
+
334
+ /**
335
+ * Decode value from buffer at offset
336
+ * @param buf Buffer to read the decoded value from
337
+ * @param off Decode offset
338
+ */
339
+ get(buf: Uint8Array, off: number): T;
340
+ }
341
+ ```
342
+ The *tokenizer* reads `token.len` bytes from the *tokenizer-stream* into a Buffer.
343
+ The `token.get` will be called with the Buffer. `token.get` is responsible for conversion from the buffer to the desired output type.
344
+
345
+ ### Working with Web-API readable stream
346
+ To convert a [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) into a [Node.js readable stream]((https://nodejs.org/api/stream.html#stream_readable_streams)), you can use [readable-web-to-node-stream](https://github.com/Borewit/readable-web-to-node-stream) to convert one in another.
347
+
348
+ ```js
349
+ import { fromWebStream } strtok3 from 'strtok3';
350
+ import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
351
+
352
+ (async () => {
353
+
354
+ const response = await fetch(url);
355
+ const readableWebStream = response.body; // Web-API readable stream
356
+ const webStream = new ReadableWebToNodeStream(readableWebStream); // convert to Node.js readable stream
357
+
358
+ const tokenizer = fromWebStream(webStream); // And we now have tokenizer in a web environment
359
+ })();
360
+ ```
361
+
362
+ ## Dependencies
363
+
364
+ The diagram below illustrates the primary dependencies of `strtok3`:
365
+ ```mermaid
366
+ graph TD;
367
+ S(strtok3)-->P(peek-readable)
368
+ S(strtok3)-->TO("@tokenizer/token")
369
+ ```
370
+ -
371
+ - [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
+ - [@tokenizer/token](https://github.com/Borewit/tokenizer-token): Provides token definitions and utilities used by `strtok3` for interpreting binary data.
373
+
374
+ ## Licence
375
+
376
+ (The MIT License)
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.
package/lib/core.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type AnyWebByteStream } from 'peek-readable';
3
3
  import { ReadStreamTokenizer } from './ReadStreamTokenizer.js';
4
4
  import { BufferTokenizer } from './BufferTokenizer.js';
5
5
  import type { ITokenizerOptions } from './types.js';
6
- export { EndOfStreamError, type AnyWebByteStream } from 'peek-readable';
6
+ export { EndOfStreamError, AbortError, type AnyWebByteStream } from 'peek-readable';
7
7
  export type { ITokenizer, IRandomAccessTokenizer, IFileInfo, IRandomAccessFileInfo, ITokenizerOptions, IReadChunkOptions, OnClose } from './types.js';
8
8
  export type { IToken, IGetToken } from '@tokenizer/token';
9
9
  export { AbstractTokenizer } from './AbstractTokenizer.js';
package/lib/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { StreamReader, makeWebStreamReader } from 'peek-readable';
2
2
  import { ReadStreamTokenizer } from './ReadStreamTokenizer.js';
3
3
  import { BufferTokenizer } from './BufferTokenizer.js';
4
- export { EndOfStreamError } from 'peek-readable';
4
+ export { EndOfStreamError, AbortError } from 'peek-readable';
5
5
  export { AbstractTokenizer } from './AbstractTokenizer.js';
6
6
  /**
7
7
  * Construct ReadStreamTokenizer from given Stream.
package/package.json CHANGED
@@ -1,91 +1,91 @@
1
- {
2
- "name": "strtok3",
3
- "version": "10.1.1",
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": "yarn run compile-src && yarn run compile-test",
18
- "build": "yarn run clean && yarn run compile",
19
- "eslint": "eslint lib test",
20
- "lint-md": "remark -u preset-lint-recommended .",
21
- "lint-ts": "biome check",
22
- "lint": "yarn run lint-md && yarn run lint-ts",
23
- "fix": "yarn run biome lint --write",
24
- "test": "mocha",
25
- "test-coverage": "c8 yarn run test",
26
- "send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
27
- "start": "yarn run compile && yarn run lint && yarn run cover-test"
28
- },
29
- "engines": {
30
- "node": ">=16"
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/Borewit/strtok3.git"
35
- },
36
- "license": "MIT",
37
- "type": "module",
38
- "exports": {
39
- ".": {
40
- "node": "./lib/index.js",
41
- "default": "./lib/core.js"
42
- },
43
- "./core": "./lib/core.js"
44
- },
45
- "types": "lib/index.d.ts",
46
- "files": [
47
- "lib/**/*.js",
48
- "lib/**/*.d.ts"
49
- ],
50
- "bugs": {
51
- "url": "https://github.com/Borewit/strtok3/issues"
52
- },
53
- "devDependencies": {
54
- "@biomejs/biome": "^1.9.4",
55
- "@types/chai": "^5.0.1",
56
- "@types/chai-as-promised": "^8.0.1",
57
- "@types/debug": "^4.1.12",
58
- "@types/mocha": "^10.0.10",
59
- "@types/node": "^22.10.10",
60
- "c8": "^10.1.3",
61
- "chai": "^5.1.2",
62
- "chai-as-promised": "^8.0.1",
63
- "del-cli": "^6.0.0",
64
- "mocha": "^11.1.0",
65
- "remark-cli": "^12.0.1",
66
- "remark-preset-lint-recommended": "^7.0.0",
67
- "token-types": "^6.0.0",
68
- "ts-node": "^10.9.2",
69
- "typescript": "^5.7.3",
70
- "uint8array-extras": "^1.4.0"
71
- },
72
- "dependencies": {
73
- "@tokenizer/token": "^0.3.0",
74
- "peek-readable": "^6.0.1"
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
- "packageManager": "yarn@4.6.0"
91
- }
1
+ {
2
+ "name": "strtok3",
3
+ "version": "10.2.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": "yarn run compile-src && yarn run compile-test",
18
+ "build": "yarn run clean && yarn run compile",
19
+ "eslint": "eslint lib test",
20
+ "lint-md": "remark -u preset-lint-recommended .",
21
+ "lint-ts": "biome check",
22
+ "lint": "yarn run lint-md && yarn run lint-ts",
23
+ "fix": "yarn run biome lint --write",
24
+ "test": "mocha",
25
+ "test-coverage": "c8 yarn run test",
26
+ "send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
27
+ "start": "yarn run compile && yarn run lint && yarn run cover-test"
28
+ },
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/Borewit/strtok3.git"
35
+ },
36
+ "license": "MIT",
37
+ "type": "module",
38
+ "exports": {
39
+ ".": {
40
+ "node": "./lib/index.js",
41
+ "default": "./lib/core.js"
42
+ },
43
+ "./core": "./lib/core.js"
44
+ },
45
+ "types": "lib/index.d.ts",
46
+ "files": [
47
+ "lib/**/*.js",
48
+ "lib/**/*.d.ts"
49
+ ],
50
+ "bugs": {
51
+ "url": "https://github.com/Borewit/strtok3/issues"
52
+ },
53
+ "devDependencies": {
54
+ "@biomejs/biome": "^1.9.4",
55
+ "@types/chai": "^5.0.1",
56
+ "@types/chai-as-promised": "^8.0.1",
57
+ "@types/debug": "^4.1.12",
58
+ "@types/mocha": "^10.0.10",
59
+ "@types/node": "^22.12.0",
60
+ "c8": "^10.1.3",
61
+ "chai": "^5.1.2",
62
+ "chai-as-promised": "^8.0.1",
63
+ "del-cli": "^6.0.0",
64
+ "mocha": "^11.1.0",
65
+ "remark-cli": "^12.0.1",
66
+ "remark-preset-lint-recommended": "^7.0.1",
67
+ "token-types": "^6.0.0",
68
+ "ts-node": "^10.9.2",
69
+ "typescript": "^5.7.3",
70
+ "uint8array-extras": "^1.4.0"
71
+ },
72
+ "dependencies": {
73
+ "@tokenizer/token": "^0.3.0",
74
+ "peek-readable": "^6.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
+ "packageManager": "yarn@4.6.0"
91
+ }