diff options
Diffstat (limited to 'node_modules/strtok3')
-rw-r--r-- | node_modules/strtok3/LICENSE | 15 | ||||
-rw-r--r-- | node_modules/strtok3/README.md | 301 | ||||
-rw-r--r-- | node_modules/strtok3/lib/AbstractTokenizer.d.ts | 62 | ||||
-rw-r--r-- | node_modules/strtok3/lib/AbstractTokenizer.js | 69 | ||||
-rw-r--r-- | node_modules/strtok3/lib/BufferTokenizer.d.ts | 37 | ||||
-rw-r--r-- | node_modules/strtok3/lib/BufferTokenizer.js | 114 | ||||
-rw-r--r-- | node_modules/strtok3/lib/FileTokenizer.d.ts | 28 | ||||
-rw-r--r-- | node_modules/strtok3/lib/FileTokenizer.js | 112 | ||||
-rw-r--r-- | node_modules/strtok3/lib/FsPromise.d.ts | 18 | ||||
-rw-r--r-- | node_modules/strtok3/lib/FsPromise.js | 79 | ||||
-rw-r--r-- | node_modules/strtok3/lib/ReadStreamTokenizer.d.ts | 28 | ||||
-rw-r--r-- | node_modules/strtok3/lib/ReadStreamTokenizer.js | 128 | ||||
-rw-r--r-- | node_modules/strtok3/lib/core.d.ts | 23 | ||||
-rw-r--r-- | node_modules/strtok3/lib/core.js | 29 | ||||
-rw-r--r-- | node_modules/strtok3/lib/index.d.ts | 15 | ||||
-rw-r--r-- | node_modules/strtok3/lib/index.js | 27 | ||||
-rw-r--r-- | node_modules/strtok3/lib/types.d.ts | 103 | ||||
-rw-r--r-- | node_modules/strtok3/lib/types.js | 2 | ||||
-rw-r--r-- | node_modules/strtok3/package.json | 126 |
19 files changed, 1316 insertions, 0 deletions
diff --git a/node_modules/strtok3/LICENSE b/node_modules/strtok3/LICENSE new file mode 100644 index 0000000..c85ef2c --- /dev/null +++ b/node_modules/strtok3/LICENSE @@ -0,0 +1,15 @@ +Copyright (c) 2017, Borewit +All rights reserved. + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. + +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.
\ No newline at end of file diff --git a/node_modules/strtok3/README.md b/node_modules/strtok3/README.md new file mode 100644 index 0000000..b93a911 --- /dev/null +++ b/node_modules/strtok3/README.md @@ -0,0 +1,301 @@ +![Node.js CI](https://github.com/Borewit/strtok3/workflows/Node.js%20CI/badge.svg) +[![NPM version](https://badge.fury.io/js/strtok3.svg)](https://npmjs.org/package/strtok3) +[![npm downloads](http://img.shields.io/npm/dm/strtok3.svg)](https://npmcharts.com/compare/strtok3,token-types?start=1200&interval=30) +[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=Borewit/music-metadata)](https://dependabot.com)[![Coverage status](https://coveralls.io/repos/github/Borewit/strtok3/badge.svg?branch=master)](https://coveralls.io/github/Borewit/strtok3?branch=master) +[![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) +[![Known Vulnerabilities](https://snyk.io/test/github/Borewit/strtok3/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/strtok3?targetFile=package.json) +[![Total alerts](https://img.shields.io/lgtm/alerts/g/Borewit/strtok3.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Borewit/strtok3/alerts/) +[![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) +[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Borewit/strtok3.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Borewit/strtok3/context:javascript) +# strtok3 + +A promise based streaming [*tokenizer*](#tokenizer) for [Node.js](http://nodejs.org) and browsers. +This node module is a successor of [strtok2](https://github.com/Borewit/strtok2). + +The `strtok3` contains a few methods to turn different input into a [*tokenizer*](#tokenizer). Designed to +* Support a streaming environment +* Decoding of binary data, strings and numbers in mind +* Read [predefined](https://github.com/Borewit/token-types) or custom tokens. +* Optimized [*tokenizers*](#tokenizer) for reading from [file](#method-strtok3fromfile), [stream](#method-strtok3fromstream) or [buffer](#method-strtok3frombuffer). + +It can read from: +* A file (taking a file path as an input) +* A Node.js [stream](https://nodejs.org/api/stream.html). +* A [Buffer](https://nodejs.org/api/buffer.html) +* HTTP chunked transfer provided by [@tokenizer/http](https://github.com/Borewit/tokenizer-http). +* Chunked [Amazon S3](https://aws.amazon.com/s3) access provided by [@tokenizer/s3](https://github.com/Borewit/tokenizer-s3). + +## Installation + +```sh +npm install strtok3 +``` + +## API + +Use one of the methods to instantiate an [*abstract tokenizer*](#tokenizer): +* [strtok3.fromFile](#method-strtok3fromfile) +* [strtok3.fromStream](#method-strtok3fromstream) +* [strtok3.fromBuffer](#method-strtok3frombuffer) + +### strtok3 methods + +All of the strtok3 methods return a [*tokenizer*](#tokenizer), either directly or via a promise. + +#### Method `strtok3.fromFile()` + +| Parameter | Type | Description | +|-----------|-----------------------|----------------------------| +| path | Path to file (string) | Path to file to read from | + +Note that [file-information](#file-information) is automatically added. + +Returns, via a promise, a [*tokenizer*](#tokenizer) which can be used to parse a file. + +```js +const strtok3 = require('strtok3'); +const Token = require('token-types'); + +(async () => { + + const tokenizer = await strtok3.fromFile("somefile.bin"); + try { + const myNumber = await tokenizer.readToken(Token.UINT8); + console.log(`My number: ${myNumber}`); + } finally { + tokenizer.close(); // Close the file + } +})(); + +``` + +#### Method `strtok3.fromStream()` + +Create [*tokenizer*](#tokenizer) from a node.js [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable). + +| Parameter | Optional | Type | Description | +|-----------|-----------|-----------------------------------------------------------------------------|--------------------------| +| stream | no | [Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable) | Stream to read from | +| fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information | + +Returns a [*tokenizer*](#tokenizer), via a Promise, which can be used to parse a buffer. + +```js +const strtok3 = require('strtok3'); +const Token = require('token-types'); + +strtok3.fromStream(stream).then(tokenizer => { + return tokenizer.readToken(Token.UINT8).then(myUint8Number => { + console.log(`My number: ${myUint8Number}`); + }); +}); +``` + +#### Method `strtok3.fromBuffer()` + +| Parameter | Optional | Type | Description | +|-----------|----------|----------------------------------------------|--------------------------| +| buffer | no | [Buffer](https://nodejs.org/api/buffer.html) | Buffer to read from | +| fileInfo | yes | [IFileInfo](#IFileInfo) | Provide file information | + +Returns a [*tokenizer*](#tokenizer) which can be used to parse the provided buffer. + +```js +const strtok3 = require('strtok3'); + +const tokenizer = strtok3.fromBuffer(buffer); + +tokenizer.readToken(Token.UINT8).then(myUint8Number => { + console.log(`My number: ${myUint8Number}`); +}); +``` + +## Tokenizer +The tokenizer allows us to *read* or *peek* from the *tokenizer-stream*. The *tokenizer-stream* is an abstraction of a [stream](https://nodejs.org/api/stream.html), file or [Buffer](https://nodejs.org/api/buffer.html). +It can also be translated in chunked reads, as done in [@tokenizer/http](https://github.com/Borewit/tokenizer-http); + +What is the difference with Nodejs.js stream? +* The *tokenizer-stream* supports jumping / seeking in a the *tokenizer-stream* using [`tokenizer.ignore()`](#method-tokenizerignore) +* In addition to *read* methods, it has *peek* methods, to read a ahead and check what is coming. + +The [tokenizer.position](#attribute-tokenizerposition) keeps tracks of the read position. + +### strtok3 attributes + +#### Attribute `tokenizer.fileInfo` +Optional attribute describing the file information, see [IFileInfo](#IFileInfo) + +#### Attribute `tokenizer.position` +Pointer to the current position in the [*tokenizer*](#tokenizer) stream. +If a *position* is provided to a *read* or *peek* method, is should be, at least, equal or greater than this value. + +### Tokenizer methods + +There are to groups of methods + +* *read* methods: used to read a *token* of [Buffer](https://nodejs.org/api/buffer.html) from the [*tokenizer*](#tokenizer). The position of the *tokenizer-stream* will advance with the size of the token. +* *peek* methods: same as the read, but it will *not* advance the pointer. It allows to read (peek) ahead. + +#### Method `tokenizer.readBuffer()` + +Read buffer from stream. +`readBuffer(buffer, options?)` + +| Parameter | Type | Description | +|------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| buffer | [Buffer](https://nodejs.org/api/buffer.html) | Uint8Array | Target buffer to write the data read to | +| options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read | + +Return value `Promise<number>` Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set. + +#### Method `tokenizer.peekBuffer()` + +Peek (read ahead) buffer from [*tokenizer*](#tokenizer) +`peekBuffer(buffer, options?)` + +| Parameter | Type | Description | +|------------|-----------------------------------------|-----------------------------------------------------| +| buffer | Buffer | Uint8Array | Target buffer to write the data read (peeked) to. | +| options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read. | | + +Return value `Promise<number>` Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set. + +#### Method `tokenizer.readToken()` + +Read a *token* from the tokenizer-stream. +`readToken(token, position?)` + +| Parameter | Type | Description | +|------------|-------------------------|---------------------------------------------------------------------------------------------------------------------- | +| token | [IGetToken](#IGetToken) | Token to read from the tokenizer-stream. | +| position? | number | Offset where to begin reading within the file. If position is null, data will be read from the current file position. | + +Return value `Promise<number>`. Promise with number of bytes read. The number of bytes read maybe if less, *mayBeLess* flag was set. + +#### Method `tokenizer.peekToken()` + +Peek a *token* from the [*tokenizer*](#tokenizer). +`peekToken(token, position?)` + +| Parameter | Type | Description | +|------------|----------------------------|-------------------------------------------------------------------------------------------------------------------------| +| token | [IGetToken<T>](#IGetToken) | Token to read from the tokenizer-stream. | +| position? | number | Offset where to begin reading within the file. If position is null, data will be read from the current file position. | + +Return value `Promise<T>` Promise with token value peeked from the [*tokenizer*](#tokenizer). + +#### Method `tokenizer.readNumber()` + +Peek a numeric [*token*](#token) from the [*tokenizer*](#tokenizer). +`readNumber(token)` + +| Parameter | Type | Description | +|------------|---------------------------------|----------------------------------------------------| +| token | [IGetToken<number>](#IGetToken) | Numeric token to read from the tokenizer-stream. | + +Return value `Promise<number>` Promise with number peeked from the *tokenizer-stream*. + +#### Method `tokenizer.ignore()` + +Peek a numeric [*token*](#token) from the tokenizer-stream. +`ignore(length)` + +| Parameter | Type | Description | +|------------|--------|----------------------------------------------------------------------| +| ignore | number | Numeric of bytes to ignore. Will advance the `tokenizer.position` | + +Return value `Promise<number>` Promise with number peeked from the *tokenizer-stream*. + +#### Method `tokenizer.close()` +Clean up resources, such as closing a file pointer if applicable. + +### IReadChunkOptions + +Each attribute is optional: + +| Attribute | Type | Description | +|-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| offset | number | The offset in the buffer to start writing at; if not provided, start at 0 | +| length | number | Requested number of bytes to read. | +| 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) | +| mayBeLess | boolean | If and only if set, will not throw an EOF error if less then the requested *mayBeLess* could be read. | + +Example: +```js + tokenizer.peekBuffer(buffer, {mayBeLess: true}); +``` + +## IFileInfo + +File information interface which describes the underlying file, each attribute is optional. + +| Attribute | Type | Description | +|-----------|---------|---------------------------------------------------------------------------------------------------| +| size | number | File size in bytes | +| mimeType | number | [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of file. | +| path | number | File path | +| url | boolean | File URL | + +## Token + +The *token* is basically a description what to read form the [*tokenizer-stream*](#tokenizer). +A basic set of *token types* can be found here: [*token-types*](https://github.com/Borewit/token-types). + +A token is something which implements the following interface: +```ts +export interface IGetToken<T> { + + /** + * Length in bytes of encoded value + */ + len: number; + + /** + * Decode value from buffer at offset + * @param buf Buffer to read the decoded value from + * @param off Decode offset + */ + get(buf: Buffer, off: number): T; +} +``` +The *tokenizer* reads `token.len` bytes from the *tokenizer-stream* into a Buffer. +The `token.get` will be called with the Buffer. `token.get` is responsible for conversion from the buffer to the desired output type. + +## Browser compatibility +To exclude fs based dependencies, you can use a submodule-import from 'strtok3/lib/core'. + +| function | 'strtok3' | 'strtok3/lib/core' | +| ----------------------| --------------------|---------------------| +| `parseBuffer` | ✓ | ✓ | +| `parseStream` | ✓ | ✓ | +| `fromFile` | ✓ | | + +### Working with Web-API readable stream +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. + +Example submodule-import: +```js +const strtok3core = require('strtok3/lib/core'); // Submodule-import to prevent Node.js specific dependencies +const {ReadableWebToNodeStream} = require('readable-web-to-node-stream'); + +(async () => { + + const response = await fetch(url); + const readableWebStream = response.body; // Web-API readable stream + const nodeStream = new ReadableWebToNodeStream(readableWebStream); // convert to Node.js readable stream + + const tokenizer = strtok3core.fromStream(nodeStream); // And we now have tokenizer in a web environment +})(); +``` + +## Licence + +(The MIT License) + +Copyright (c) 2020 Borewit + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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. diff --git a/node_modules/strtok3/lib/AbstractTokenizer.d.ts b/node_modules/strtok3/lib/AbstractTokenizer.d.ts new file mode 100644 index 0000000..936a758 --- /dev/null +++ b/node_modules/strtok3/lib/AbstractTokenizer.d.ts @@ -0,0 +1,62 @@ +/// <reference types="node" /> +import { ITokenizer, IFileInfo, IReadChunkOptions } from './types'; +import { IGetToken, IToken } from '@tokenizer/token'; +/** + * Core tokenizer + */ +export declare abstract class AbstractTokenizer implements ITokenizer { + fileInfo: IFileInfo; + protected constructor(fileInfo?: IFileInfo); + /** + * Tokenizer-stream position + */ + position: number; + private numBuffer; + /** + * Read buffer from tokenizer + * @param buffer - Target buffer to fill with data read from the tokenizer-stream + * @param options - Additional read options + * @returns Promise with number of bytes read + */ + abstract readBuffer(buffer: Buffer | Uint8Array, options?: IReadChunkOptions): Promise<number>; + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer - Target buffer to fill with data peek from the tokenizer-stream + * @param options - Peek behaviour options + * @returns Promise with number of bytes read + */ + abstract peekBuffer(buffer: Buffer | Uint8Array, options?: IReadChunkOptions): Promise<number>; + /** + * Read a token from the tokenizer-stream + * @param token - The token to read + * @param position - If provided, the desired position in the tokenizer-stream + * @returns Promise with token data + */ + readToken<T>(token: IGetToken<T>, position?: number): Promise<T>; + /** + * Peek a token from the tokenizer-stream. + * @param token - Token to peek from the tokenizer-stream. + * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position. + * @returns Promise with token data + */ + peekToken<T>(token: IGetToken<T>, position?: number): Promise<T>; + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + readNumber(token: IToken<number>): Promise<number>; + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + peekNumber(token: IToken<number>): Promise<number>; + /** + * Ignore number of bytes, advances the pointer in under tokenizer-stream. + * @param length - Number of bytes to skip (ignore) + * @return actual number of bytes ignored + */ + abstract ignore(length: number): Promise<number>; + close(): Promise<void>; +} diff --git a/node_modules/strtok3/lib/AbstractTokenizer.js b/node_modules/strtok3/lib/AbstractTokenizer.js new file mode 100644 index 0000000..d4d4dba --- /dev/null +++ b/node_modules/strtok3/lib/AbstractTokenizer.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AbstractTokenizer = void 0; +const peek_readable_1 = require("peek-readable"); +/** + * Core tokenizer + */ +class AbstractTokenizer { + constructor(fileInfo) { + /** + * Tokenizer-stream position + */ + this.position = 0; + this.numBuffer = Buffer.alloc(10); + this.fileInfo = fileInfo ? fileInfo : {}; + } + /** + * Read a token from the tokenizer-stream + * @param token - The token to read + * @param position - If provided, the desired position in the tokenizer-stream + * @returns Promise with token data + */ + async readToken(token, position) { + const buffer = Buffer.alloc(token.len); + const len = await this.readBuffer(buffer, { position }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(buffer, 0); + } + /** + * Peek a token from the tokenizer-stream. + * @param token - Token to peek from the tokenizer-stream. + * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position. + * @returns Promise with token data + */ + async peekToken(token, position = this.position) { + const buffer = Buffer.alloc(token.len); + const len = await this.peekBuffer(buffer, { position }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(buffer, 0); + } + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + async readNumber(token) { + const len = await this.readBuffer(this.numBuffer, { length: token.len }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(this.numBuffer, 0); + } + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + async peekNumber(token) { + const len = await this.peekBuffer(this.numBuffer, { length: token.len }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(this.numBuffer, 0); + } + async close() { + // empty + } +} +exports.AbstractTokenizer = AbstractTokenizer; diff --git a/node_modules/strtok3/lib/BufferTokenizer.d.ts b/node_modules/strtok3/lib/BufferTokenizer.d.ts new file mode 100644 index 0000000..1dd6119 --- /dev/null +++ b/node_modules/strtok3/lib/BufferTokenizer.d.ts @@ -0,0 +1,37 @@ +/// <reference types="node" /> +import { IFileInfo, IReadChunkOptions, ITokenizer } from './types'; +import { IGetToken, IToken } from '@tokenizer/token'; +export declare class BufferTokenizer implements ITokenizer { + private buffer; + fileInfo: IFileInfo; + position: number; + /** + * Construct BufferTokenizer + * @param buffer - Buffer to tokenize + * @param fileInfo - Pass additional file information to the tokenizer + */ + constructor(buffer: Buffer, fileInfo?: IFileInfo); + /** + * Read buffer from tokenizer + * @param buffer + * @param options - Read behaviour options + * @returns {Promise<number>} + */ + readBuffer(buffer: Buffer | Uint8Array, options?: IReadChunkOptions): Promise<number>; + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer + * @param options - Read behaviour options + * @returns {Promise<number>} + */ + peekBuffer(buffer: Buffer | Uint8Array, options?: IReadChunkOptions): Promise<number>; + readToken<T>(token: IGetToken<T>, position?: number): Promise<T>; + peekToken<T>(token: IGetToken<T>, position?: number): Promise<T>; + readNumber(token: IToken<number>): Promise<number>; + peekNumber(token: IToken<number>): Promise<number>; + /** + * @return actual number of bytes ignored + */ + ignore(length: number): Promise<number>; + close(): Promise<void>; +} diff --git a/node_modules/strtok3/lib/BufferTokenizer.js b/node_modules/strtok3/lib/BufferTokenizer.js new file mode 100644 index 0000000..aae1395 --- /dev/null +++ b/node_modules/strtok3/lib/BufferTokenizer.js @@ -0,0 +1,114 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BufferTokenizer = void 0; +const peek_readable_1 = require("peek-readable"); +class BufferTokenizer { + /** + * Construct BufferTokenizer + * @param buffer - Buffer to tokenize + * @param fileInfo - Pass additional file information to the tokenizer + */ + constructor(buffer, fileInfo) { + this.buffer = buffer; + this.position = 0; + this.fileInfo = fileInfo ? fileInfo : {}; + this.fileInfo.size = this.fileInfo.size ? this.fileInfo.size : buffer.length; + } + /** + * Read buffer from tokenizer + * @param buffer + * @param options - Read behaviour options + * @returns {Promise<number>} + */ + async readBuffer(buffer, options) { + if (options && options.position) { + if (options.position < this.position) { + throw new Error('`options.position` must be equal or greater than `tokenizer.position`'); + } + this.position = options.position; + } + return this.peekBuffer(buffer, options).then(bytesRead => { + this.position += bytesRead; + return bytesRead; + }); + } + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer + * @param options - Read behaviour options + * @returns {Promise<number>} + */ + async peekBuffer(buffer, options) { + let offset = 0; + let length = buffer.length; + let position = this.position; + if (options) { + if (options.position) { + if (options.position < this.position) { + throw new Error('`options.position` can be less than `tokenizer.position`'); + } + position = options.position; + } + if (Number.isInteger(options.length)) { + length = options.length; + } + else { + length -= options.offset || 0; + } + if (options.offset) { + offset = options.offset; + } + } + if (length === 0) { + return Promise.resolve(0); + } + position = position || this.position; + if (!length) { + length = buffer.length; + } + const bytes2read = Math.min(this.buffer.length - position, length); + if ((!options || !options.mayBeLess) && bytes2read < length) { + throw new peek_readable_1.EndOfStreamError(); + } + else { + this.buffer.copy(buffer, offset, position, position + bytes2read); + return bytes2read; + } + } + async readToken(token, position) { + this.position = position || this.position; + try { + const tv = this.peekToken(token, this.position); + this.position += token.len; + return tv; + } + catch (err) { + this.position += this.buffer.length - position; + throw err; + } + } + async peekToken(token, position = this.position) { + if (this.buffer.length - position < token.len) { + throw new peek_readable_1.EndOfStreamError(); + } + return token.get(this.buffer, position); + } + async readNumber(token) { + return this.readToken(token); + } + async peekNumber(token) { + return this.peekToken(token); + } + /** + * @return actual number of bytes ignored + */ + async ignore(length) { + const bytesIgnored = Math.min(this.buffer.length - this.position, length); + this.position += bytesIgnored; + return bytesIgnored; + } + async close() { + // empty + } +} +exports.BufferTokenizer = BufferTokenizer; diff --git a/node_modules/strtok3/lib/FileTokenizer.d.ts b/node_modules/strtok3/lib/FileTokenizer.d.ts new file mode 100644 index 0000000..c15f74b --- /dev/null +++ b/node_modules/strtok3/lib/FileTokenizer.d.ts @@ -0,0 +1,28 @@ +/// <reference types="node" /> +import { AbstractTokenizer } from './AbstractTokenizer'; +import { IFileInfo, IReadChunkOptions } from './types'; +export declare class FileTokenizer extends AbstractTokenizer { + private fd; + constructor(fd: number, fileInfo: IFileInfo); + /** + * Read buffer from file + * @param buffer + * @param options - Read behaviour options + * @returns Promise number of bytes read + */ + readBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>; + /** + * Peek buffer from file + * @param buffer + * @param options - Read behaviour options + * @returns Promise number of bytes read + */ + peekBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>; + /** + * @param length - Number of bytes to ignore + * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available + */ + ignore(length: number): Promise<number>; + close(): Promise<void>; +} +export declare function fromFile(sourceFilePath: string): Promise<FileTokenizer>; diff --git a/node_modules/strtok3/lib/FileTokenizer.js b/node_modules/strtok3/lib/FileTokenizer.js new file mode 100644 index 0000000..b3adc24 --- /dev/null +++ b/node_modules/strtok3/lib/FileTokenizer.js @@ -0,0 +1,112 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fromFile = exports.FileTokenizer = void 0; +const AbstractTokenizer_1 = require("./AbstractTokenizer"); +const peek_readable_1 = require("peek-readable"); +const fs = require("./FsPromise"); +class FileTokenizer extends AbstractTokenizer_1.AbstractTokenizer { + constructor(fd, fileInfo) { + super(fileInfo); + this.fd = fd; + } + /** + * Read buffer from file + * @param buffer + * @param options - Read behaviour options + * @returns Promise number of bytes read + */ + async readBuffer(buffer, options) { + let offset = 0; + let length = buffer.length; + if (options) { + if (options.position) { + if (options.position < this.position) { + throw new Error('`options.position` must be equal or greater than `tokenizer.position`'); + } + this.position = options.position; + } + if (Number.isInteger(options.length)) { + length = options.length; + } + else { + length -= options.offset || 0; + } + if (options.offset) { + offset = options.offset; + } + } + if (length === 0) { + return Promise.resolve(0); + } + const res = await fs.read(this.fd, buffer, offset, length, this.position); + this.position += res.bytesRead; + if (res.bytesRead < length && (!options || !options.mayBeLess)) { + throw new peek_readable_1.EndOfStreamError(); + } + return res.bytesRead; + } + /** + * Peek buffer from file + * @param buffer + * @param options - Read behaviour options + * @returns Promise number of bytes read + */ + async peekBuffer(buffer, options) { + let offset = 0; + let length = buffer.length; + let position = this.position; + if (options) { + if (options.position) { + if (options.position < this.position) { + throw new Error('`options.position` must be equal or greater than `tokenizer.position`'); + } + position = options.position; + } + if (Number.isInteger(options.length)) { + length = options.length; + } + else { + length -= options.offset || 0; + } + if (options.offset) { + offset = options.offset; + } + } + if (length === 0) { + return Promise.resolve(0); + } + const res = await fs.read(this.fd, buffer, offset, length, position); + if ((!options || !options.mayBeLess) && res.bytesRead < length) { + throw new peek_readable_1.EndOfStreamError(); + } + return res.bytesRead; + } + /** + * @param length - Number of bytes to ignore + * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available + */ + async ignore(length) { + const bytesLeft = this.fileInfo.size - this.position; + if (length <= bytesLeft) { + this.position += length; + return length; + } + else { + this.position += bytesLeft; + return bytesLeft; + } + } + async close() { + return fs.close(this.fd); + } +} +exports.FileTokenizer = FileTokenizer; +async function fromFile(sourceFilePath) { + const stat = await fs.stat(sourceFilePath); + if (!stat.isFile) { + throw new Error(`File not a file: ${sourceFilePath}`); + } + const fd = await fs.open(sourceFilePath, 'r'); + return new FileTokenizer(fd, { path: sourceFilePath, size: stat.size }); +} +exports.fromFile = fromFile; diff --git a/node_modules/strtok3/lib/FsPromise.d.ts b/node_modules/strtok3/lib/FsPromise.d.ts new file mode 100644 index 0000000..1c9917a --- /dev/null +++ b/node_modules/strtok3/lib/FsPromise.d.ts @@ -0,0 +1,18 @@ +/** + * Module convert fs functions to promise based functions + */ +/// <reference types="node" /> +import * as fs from 'fs'; +export interface IReadResult { + bytesRead: number; + buffer: Buffer; +} +export declare const pathExists: typeof fs.existsSync; +export declare const createReadStream: typeof fs.createReadStream; +export declare function stat(path: fs.PathLike): Promise<fs.Stats>; +export declare function close(fd: number): Promise<void>; +export declare function open(path: fs.PathLike, mode?: string): Promise<number>; +export declare function read(fd: number, buffer: Buffer, offset: number, length: number, position: number): Promise<IReadResult>; +export declare function writeFile(path: fs.PathLike, data: Buffer | string): Promise<void>; +export declare function writeFileSync(path: fs.PathLike, data: Buffer | string): void; +export declare function readFile(path: fs.PathLike): Promise<Buffer>; diff --git a/node_modules/strtok3/lib/FsPromise.js b/node_modules/strtok3/lib/FsPromise.js new file mode 100644 index 0000000..690a5e2 --- /dev/null +++ b/node_modules/strtok3/lib/FsPromise.js @@ -0,0 +1,79 @@ +"use strict"; +/** + * Module convert fs functions to promise based functions + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.readFile = exports.writeFileSync = exports.writeFile = exports.read = exports.open = exports.close = exports.stat = exports.createReadStream = exports.pathExists = void 0; +const fs = require("fs"); +exports.pathExists = fs.existsSync; +exports.createReadStream = fs.createReadStream; +async function stat(path) { + return new Promise((resolve, reject) => { + fs.stat(path, (err, stats) => { + if (err) + reject(err); + else + resolve(stats); + }); + }); +} +exports.stat = stat; +async function close(fd) { + return new Promise((resolve, reject) => { + fs.close(fd, err => { + if (err) + reject(err); + else + resolve(); + }); + }); +} +exports.close = close; +async function open(path, mode) { + return new Promise((resolve, reject) => { + fs.open(path, mode, (err, fd) => { + if (err) + reject(err); + else + resolve(fd); + }); + }); +} +exports.open = open; +async function read(fd, buffer, offset, length, position) { + return new Promise((resolve, reject) => { + fs.read(fd, buffer, offset, length, position, (err, bytesRead, _buffer) => { + if (err) + reject(err); + else + resolve({ bytesRead, buffer: _buffer }); + }); + }); +} +exports.read = read; +async function writeFile(path, data) { + return new Promise((resolve, reject) => { + fs.writeFile(path, data, err => { + if (err) + reject(err); + else + resolve(); + }); + }); +} +exports.writeFile = writeFile; +function writeFileSync(path, data) { + fs.writeFileSync(path, data); +} +exports.writeFileSync = writeFileSync; +async function readFile(path) { + return new Promise((resolve, reject) => { + fs.readFile(path, (err, buffer) => { + if (err) + reject(err); + else + resolve(buffer); + }); + }); +} +exports.readFile = readFile; diff --git a/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts b/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts new file mode 100644 index 0000000..fe0280f --- /dev/null +++ b/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts @@ -0,0 +1,28 @@ +/// <reference types="node" /> +import { AbstractTokenizer } from './AbstractTokenizer'; +import * as Stream from 'stream'; +import { IFileInfo, IReadChunkOptions } from './types'; +export declare class ReadStreamTokenizer extends AbstractTokenizer { + private streamReader; + constructor(stream: Stream.Readable, fileInfo?: IFileInfo); + /** + * Get file information, an HTTP-client may implement this doing a HEAD request + * @return Promise with file information + */ + getFileInfo(): Promise<IFileInfo>; + /** + * Read buffer from tokenizer + * @param buffer - Target buffer to fill with data read from the tokenizer-stream + * @param options - Read behaviour options + * @returns Promise with number of bytes read + */ + readBuffer(buffer: Buffer | Uint8Array, options?: IReadChunkOptions): Promise<number>; + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer - Target buffer to write the data read to + * @param options - Read behaviour options + * @returns Promise with number of bytes peeked + */ + peekBuffer(buffer: Buffer | Uint8Array, options?: IReadChunkOptions): Promise<number>; + ignore(length: number): Promise<number>; +} diff --git a/node_modules/strtok3/lib/ReadStreamTokenizer.js b/node_modules/strtok3/lib/ReadStreamTokenizer.js new file mode 100644 index 0000000..142d154 --- /dev/null +++ b/node_modules/strtok3/lib/ReadStreamTokenizer.js @@ -0,0 +1,128 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ReadStreamTokenizer = void 0; +const AbstractTokenizer_1 = require("./AbstractTokenizer"); +const peek_readable_1 = require("peek-readable"); +// import * as _debug from 'debug'; +// const debug = _debug('strtok3:ReadStreamTokenizer'); +const maxBufferSize = 256000; +class ReadStreamTokenizer extends AbstractTokenizer_1.AbstractTokenizer { + constructor(stream, fileInfo) { + super(fileInfo); + this.streamReader = new peek_readable_1.StreamReader(stream); + } + /** + * Get file information, an HTTP-client may implement this doing a HEAD request + * @return Promise with file information + */ + async getFileInfo() { + return this.fileInfo; + } + /** + * Read buffer from tokenizer + * @param buffer - Target buffer to fill with data read from the tokenizer-stream + * @param options - Read behaviour options + * @returns Promise with number of bytes read + */ + async readBuffer(buffer, options) { + // const _offset = position ? position : this.position; + // debug(`readBuffer ${_offset}...${_offset + length - 1}`); + let offset = 0; + let length = buffer.length; + if (options) { + if (Number.isInteger(options.length)) { + length = options.length; + } + else { + length -= options.offset || 0; + } + if (options.position) { + const skipBytes = options.position - this.position; + if (skipBytes > 0) { + await this.ignore(skipBytes); + return this.readBuffer(buffer, options); + } + else if (skipBytes < 0) { + throw new Error('`options.position` must be equal or greater than `tokenizer.position`'); + } + } + if (options.offset) { + offset = options.offset; + } + } + if (length === 0) { + return 0; + } + const bytesRead = await this.streamReader.read(buffer, offset, length); + this.position += bytesRead; + if ((!options || !options.mayBeLess) && bytesRead < length) { + throw new peek_readable_1.EndOfStreamError(); + } + return bytesRead; + } + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer - Target buffer to write the data read to + * @param options - Read behaviour options + * @returns Promise with number of bytes peeked + */ + async peekBuffer(buffer, options) { + // const _offset = position ? position : this.position; + // debug(`peek ${_offset}...${_offset + length - 1}`); + let offset = 0; + let bytesRead; + let length = buffer.length; + if (options) { + if (options.offset) { + offset = options.offset; + } + if (Number.isInteger(options.length)) { + length = options.length; + } + else { + length -= options.offset || 0; + } + if (options.position) { + const skipBytes = options.position - this.position; + if (skipBytes > 0) { + const skipBuffer = Buffer.alloc(length + skipBytes); + bytesRead = await this.peekBuffer(skipBuffer, { mayBeLess: options.mayBeLess }); + skipBuffer.copy(buffer, offset, skipBytes); + return bytesRead - skipBytes; + } + else if (skipBytes < 0) { + throw new Error('Cannot peek from a negative offset in a stream'); + } + } + } + try { + bytesRead = await this.streamReader.peek(buffer, offset, length); + } + catch (err) { + if (options && options.mayBeLess && err instanceof peek_readable_1.EndOfStreamError) { + return 0; + } + throw err; + } + if ((!options || !options.mayBeLess) && bytesRead < length) { + throw new peek_readable_1.EndOfStreamError(); + } + return bytesRead; + } + async ignore(length) { + // debug(`ignore ${this.position}...${this.position + length - 1}`); + const bufSize = Math.min(maxBufferSize, length); + const buf = Buffer.alloc(bufSize); + let totBytesRead = 0; + while (totBytesRead < length) { + const remaining = length - totBytesRead; + const bytesRead = await this.readBuffer(buf, { length: Math.min(bufSize, remaining) }); + if (bytesRead < 0) { + return bytesRead; + } + totBytesRead += bytesRead; + } + return totBytesRead; + } +} +exports.ReadStreamTokenizer = ReadStreamTokenizer; diff --git a/node_modules/strtok3/lib/core.d.ts b/node_modules/strtok3/lib/core.d.ts new file mode 100644 index 0000000..72db304 --- /dev/null +++ b/node_modules/strtok3/lib/core.d.ts @@ -0,0 +1,23 @@ +/// <reference types="node" /> +import { ReadStreamTokenizer } from './ReadStreamTokenizer'; +import * as Stream from 'stream'; +import { BufferTokenizer } from './BufferTokenizer'; +import { IFileInfo } from './types'; +export { EndOfStreamError } from 'peek-readable'; +export { ITokenizer, IFileInfo } from './types'; +export { IToken, IGetToken } from '@tokenizer/token'; +/** + * Construct ReadStreamTokenizer from given Stream. + * Will set fileSize, if provided given Stream has set the .path property/ + * @param stream - Read from Node.js Stream.Readable + * @param fileInfo - Pass the file information, like size and MIME-type of the correspnding stream. + * @returns ReadStreamTokenizer + */ +export declare function fromStream(stream: Stream.Readable, fileInfo?: IFileInfo): ReadStreamTokenizer; +/** + * Construct ReadStreamTokenizer from given Buffer. + * @param buffer - Buffer to tokenize + * @param fileInfo - Pass additional file information to the tokenizer + * @returns BufferTokenizer + */ +export declare function fromBuffer(buffer: Buffer, fileInfo?: IFileInfo): BufferTokenizer; diff --git a/node_modules/strtok3/lib/core.js b/node_modules/strtok3/lib/core.js new file mode 100644 index 0000000..e572b1c --- /dev/null +++ b/node_modules/strtok3/lib/core.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fromBuffer = exports.fromStream = exports.EndOfStreamError = void 0; +const ReadStreamTokenizer_1 = require("./ReadStreamTokenizer"); +const BufferTokenizer_1 = require("./BufferTokenizer"); +var peek_readable_1 = require("peek-readable"); +Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return peek_readable_1.EndOfStreamError; } }); +/** + * Construct ReadStreamTokenizer from given Stream. + * Will set fileSize, if provided given Stream has set the .path property/ + * @param stream - Read from Node.js Stream.Readable + * @param fileInfo - Pass the file information, like size and MIME-type of the correspnding stream. + * @returns ReadStreamTokenizer + */ +function fromStream(stream, fileInfo) { + fileInfo = fileInfo ? fileInfo : {}; + return new ReadStreamTokenizer_1.ReadStreamTokenizer(stream, fileInfo); +} +exports.fromStream = fromStream; +/** + * Construct ReadStreamTokenizer from given Buffer. + * @param buffer - Buffer to tokenize + * @param fileInfo - Pass additional file information to the tokenizer + * @returns BufferTokenizer + */ +function fromBuffer(buffer, fileInfo) { + return new BufferTokenizer_1.BufferTokenizer(buffer, fileInfo); +} +exports.fromBuffer = fromBuffer; diff --git a/node_modules/strtok3/lib/index.d.ts b/node_modules/strtok3/lib/index.d.ts new file mode 100644 index 0000000..95397c3 --- /dev/null +++ b/node_modules/strtok3/lib/index.d.ts @@ -0,0 +1,15 @@ +/// <reference types="node" /> +import * as Stream from 'stream'; +import { ReadStreamTokenizer } from './ReadStreamTokenizer'; +import * as core from './core'; +export { fromFile } from './FileTokenizer'; +export { ITokenizer, EndOfStreamError, fromBuffer, IFileInfo } from './core'; +export { IToken, IGetToken } from '@tokenizer/token'; +/** + * Construct ReadStreamTokenizer from given Stream. + * Will set fileSize, if provided given Stream has set the .path property. + * @param stream - Node.js Stream.Readable + * @param fileInfo - Pass additional file information to the tokenizer + * @returns Tokenizer + */ +export declare function fromStream(stream: Stream.Readable, fileInfo?: core.IFileInfo): Promise<ReadStreamTokenizer>; diff --git a/node_modules/strtok3/lib/index.js b/node_modules/strtok3/lib/index.js new file mode 100644 index 0000000..030e750 --- /dev/null +++ b/node_modules/strtok3/lib/index.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fromStream = exports.fromBuffer = exports.EndOfStreamError = exports.fromFile = void 0; +const fs = require("./FsPromise"); +const core = require("./core"); +var FileTokenizer_1 = require("./FileTokenizer"); +Object.defineProperty(exports, "fromFile", { enumerable: true, get: function () { return FileTokenizer_1.fromFile; } }); +var core_1 = require("./core"); +Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return core_1.EndOfStreamError; } }); +Object.defineProperty(exports, "fromBuffer", { enumerable: true, get: function () { return core_1.fromBuffer; } }); +/** + * Construct ReadStreamTokenizer from given Stream. + * Will set fileSize, if provided given Stream has set the .path property. + * @param stream - Node.js Stream.Readable + * @param fileInfo - Pass additional file information to the tokenizer + * @returns Tokenizer + */ +async function fromStream(stream, fileInfo) { + fileInfo = fileInfo ? fileInfo : {}; + if (stream.path) { + const stat = await fs.stat(stream.path); + fileInfo.path = stream.path; + fileInfo.size = stat.size; + } + return core.fromStream(stream, fileInfo); +} +exports.fromStream = fromStream; diff --git a/node_modules/strtok3/lib/types.d.ts b/node_modules/strtok3/lib/types.d.ts new file mode 100644 index 0000000..93895df --- /dev/null +++ b/node_modules/strtok3/lib/types.d.ts @@ -0,0 +1,103 @@ +/// <reference types="node" /> +import { IGetToken } from '@tokenizer/token'; +export interface IFileInfo { + /** + * File size in bytes + */ + size?: number; + /** + * MIME-type of file + */ + mimeType?: string; + /** + * File path + */ + path?: string; + /** + * File URL + */ + url?: string; +} +export interface IReadChunkOptions { + /** + * The offset in the buffer to start writing at; default is 0 + */ + offset?: number; + /** + * Number of bytes to read. + */ + length?: number; + /** + * Position where to begin reading from the file. + * Default it is `tokenizer.position`. + * Position may not be less then `tokenizer.position`. + */ + position?: number; + /** + * If set, will not throw an EOF error if not all of the requested data could be read + */ + mayBeLess?: boolean; +} +/** + * The tokenizer allows us to read or peek from the tokenizer-stream. + * The tokenizer-stream is an abstraction of a stream, file or Buffer. + */ +export interface ITokenizer { + /** + * Provide access to information of the underlying information stream or file. + */ + fileInfo: IFileInfo; + /** + * Offset in bytes (= number of bytes read) since beginning of file or stream + */ + position: number; + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer - Target buffer to fill with data peek from the tokenizer-stream + * @param options - Read behaviour options + * @returns Promise with number of bytes read + */ + peekBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>; + /** + * Peek (read ahead) buffer from tokenizer + * @param buffer - Target buffer to fill with data peeked from the tokenizer-stream + * @param options - Additional read options + * @returns Promise with number of bytes read + */ + readBuffer(buffer: Buffer, options?: IReadChunkOptions): Promise<number>; + /** + * Peek a token from the tokenizer-stream. + * @param token - Token to peek from the tokenizer-stream. + * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position. + * @param maybeless - If set, will not throw an EOF error if the less then the requested length could be read. + */ + peekToken<T>(token: IGetToken<T>, position?: number | null, maybeless?: boolean): Promise<T>; + /** + * Read a token from the tokenizer-stream. + * @param token - Token to peek from the tokenizer-stream. + * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position. + */ + readToken<T>(token: IGetToken<T>, position?: number): Promise<T>; + /** + * Peek a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + peekNumber(token: IGetToken<number>): Promise<number>; + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + readNumber(token: IGetToken<number>): Promise<number>; + /** + * Ignore given number of bytes + * @param length - Number of bytes ignored + */ + ignore(length: number): Promise<number>; + /** + * Clean up resources. + * It does not close the stream for StreamReader, but is does close the file-descriptor. + */ + close(): Promise<void>; +} diff --git a/node_modules/strtok3/lib/types.js b/node_modules/strtok3/lib/types.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/strtok3/lib/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/strtok3/package.json b/node_modules/strtok3/package.json new file mode 100644 index 0000000..e71b217 --- /dev/null +++ b/node_modules/strtok3/package.json @@ -0,0 +1,126 @@ +{ + "_from": "strtok3@^6.0.3", + "_id": "strtok3@6.0.8", + "_inBundle": false, + "_integrity": "sha512-QLgv+oiXwXgCgp2PdPPa+Jpp4D9imK9e/0BsyfeFMr6QL6wMVqoVn9+OXQ9I7MZbmUzN6lmitTJ09uwS2OmGcw==", + "_location": "/strtok3", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "strtok3@^6.0.3", + "name": "strtok3", + "escapedName": "strtok3", + "rawSpec": "^6.0.3", + "saveSpec": null, + "fetchSpec": "^6.0.3" + }, + "_requiredBy": [ + "/file-type" + ], + "_resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.0.8.tgz", + "_shasum": "c839157f615c10ba0f4ae35067dad9959eeca346", + "_spec": "strtok3@^6.0.3", + "_where": "/data/dev/Projets/FNS Electrode/Projets/FNS Electrode/node_modules/file-type", + "author": { + "name": "Borewit", + "url": "https://github.com/Borewit" + }, + "bugs": { + "url": "https://github.com/Borewit/strtok3/issues" + }, + "bundleDependencies": false, + "dependencies": { + "@tokenizer/token": "^0.1.1", + "@types/debug": "^4.1.5", + "peek-readable": "^3.1.3" + }, + "deprecated": false, + "description": "A promise based streaming tokenizer", + "devDependencies": { + "@types/chai": "^4.2.14", + "@types/mocha": "^8.2.0", + "@types/node": "^14.14.20", + "@typescript-eslint/eslint-plugin": "^2.34.0", + "@typescript-eslint/eslint-plugin-tslint": "^4.13.0", + "@typescript-eslint/parser": "^2.34.0", + "chai": "^4.2.0", + "coveralls": "^3.1.0", + "del-cli": "^3.0.1", + "eslint": "^6.8.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prefer-arrow": "^1.2.2", + "mocha": "^7.2.0", + "nyc": "^15.1.0", + "remark-cli": "^9.0.0", + "remark-preset-lint-recommended": "^5.0.0", + "source-map-support": "^0.5.16", + "token-types": "^2.1.1", + "ts-node": "^9.1.1", + "tslint": "^6.1.3", + "typescript": "^4.1.3" + }, + "engines": { + "node": ">=8" + }, + "files": [ + "lib/**/*.js", + "lib/**/*.d.ts" + ], + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + }, + "homepage": "https://github.com/Borewit/strtok3#readme", + "keywords": [ + "tokenizer", + "reader", + "token", + "async", + "promise", + "parser", + "decoder", + "binary", + "endian", + "uint", + "stream", + "streaming" + ], + "license": "MIT", + "main": "lib/index.js", + "name": "strtok3", + "nyc": { + "check-coverage": false, + "extension": [ + ".ts" + ], + "sourceMap": true, + "instrument": true, + "reporter": [ + "lcov", + "text" + ], + "report-dir": "coverage" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Borewit/strtok3.git" + }, + "scripts": { + "build": "npm run clean && npm run compile", + "clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts test/**/*.js test/**/*.js.map", + "compile": "npm run compile-src && npm run compile-test", + "compile-src": "tsc -p lib", + "compile-test": "tsc -p test", + "eslint": "eslint lib test --ext .ts --ignore-pattern *.d.ts", + "lint": "npm run lint-md && npm run eslint", + "lint-md": "remark -u preset-lint-recommended .", + "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage", + "send-coveralls": "nyc report --reporter=text-lcov | coveralls", + "start": "npm run compile && npm run lint && npm run cover-test", + "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test.ts", + "test-coverage": "nyc npm run test" + }, + "types": "lib/index.d.ts", + "version": "6.0.8" +} |