Comparing version 7.1.0 to 7.1.1
import { ReadStreamTokenizer } from './ReadStreamTokenizer.js'; | ||
import { Readable } from 'node:stream'; | ||
import { BufferTokenizer } from './BufferTokenizer.js'; | ||
import { IFileInfo } from './types.js'; | ||
import type { ReadableStream } from 'node:stream/web'; | ||
import type { Readable } from 'node:stream'; | ||
export { EndOfStreamError } from 'peek-readable'; | ||
@@ -7,0 +7,0 @@ export { ITokenizer, IFileInfo } from './types.js'; |
import { ReadStreamTokenizer } from './ReadStreamTokenizer.js'; | ||
import { BufferTokenizer } from './BufferTokenizer.js'; | ||
import { StreamReader, WebStreamReader } from "peek-readable"; | ||
import { StreamReader, WebStreamReader } from 'peek-readable'; | ||
export { EndOfStreamError } from 'peek-readable'; | ||
@@ -5,0 +5,0 @@ /** |
import { AbstractTokenizer } from './AbstractTokenizer.js'; | ||
import { IFileInfo, IReadChunkOptions } from './types.js'; | ||
import { FileHandle } from 'node:fs/promises'; | ||
export declare class FileTokenizer extends AbstractTokenizer { | ||
private fd; | ||
constructor(fd: number, fileInfo: IFileInfo); | ||
private fileHandle; | ||
constructor(fileHandle: FileHandle, fileInfo: IFileInfo); | ||
/** | ||
@@ -7,0 +8,0 @@ * Read buffer from file |
import { AbstractTokenizer } from './AbstractTokenizer.js'; | ||
import { EndOfStreamError } from 'peek-readable'; | ||
import * as fs from './FsPromise.js'; | ||
import { open as fsOpen } from 'node:fs/promises'; | ||
export class FileTokenizer extends AbstractTokenizer { | ||
constructor(fd, fileInfo) { | ||
constructor(fileHandle, fileInfo) { | ||
super(fileInfo); | ||
this.fd = fd; | ||
this.fileHandle = fileHandle; | ||
} | ||
@@ -18,3 +18,3 @@ /** | ||
this.position = normOptions.position; | ||
const res = await fs.read(this.fd, uint8Array, normOptions.offset, normOptions.length, normOptions.position); | ||
const res = await this.fileHandle.read(uint8Array, normOptions.offset, normOptions.length, normOptions.position); | ||
this.position += res.bytesRead; | ||
@@ -34,3 +34,3 @@ if (res.bytesRead < normOptions.length && (!options || !options.mayBeLess)) { | ||
const normOptions = this.normalizeOptions(uint8Array, options); | ||
const res = await fs.read(this.fd, uint8Array, normOptions.offset, normOptions.length, normOptions.position); | ||
const res = await this.fileHandle.read(uint8Array, normOptions.offset, normOptions.length, normOptions.position); | ||
if ((!normOptions.mayBeLess) && res.bytesRead < normOptions.length) { | ||
@@ -42,12 +42,9 @@ throw new EndOfStreamError(); | ||
async close() { | ||
return fs.close(this.fd); | ||
return this.fileHandle.close(); | ||
} | ||
} | ||
export 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 }); | ||
const fileHandle = await fsOpen(sourceFilePath, 'r'); | ||
const stat = await fileHandle.stat(); | ||
return new FileTokenizer(fileHandle, { path: sourceFilePath, size: stat.size }); | ||
} |
@@ -1,2 +0,2 @@ | ||
import * as fs from './FsPromise.js'; | ||
import { stat as fsStat } from 'node:fs/promises'; | ||
import * as core from './core.js'; | ||
@@ -15,3 +15,3 @@ export { fromFile } from './FileTokenizer.js'; | ||
if (stream.path) { | ||
const stat = await fs.stat(stream.path); | ||
const stat = await fsStat(stream.path); | ||
fileInfo.path = stream.path; | ||
@@ -18,0 +18,0 @@ fileInfo.size = stat.size; |
{ | ||
"name": "strtok3", | ||
"version": "7.1.0", | ||
"version": "7.1.1", | ||
"description": "A promise based streaming tokenizer", | ||
@@ -19,3 +19,3 @@ "author": { | ||
"build": "npm run clean && npm run compile", | ||
"eslint": "eslint lib test --ext .ts --ignore-pattern *.d.ts", | ||
"eslint": "eslint lib test", | ||
"lint-md": "remark -u preset-lint-recommended .", | ||
@@ -30,3 +30,3 @@ "lint": "npm run lint-md && npm run eslint", | ||
"engines": { | ||
"node": ">=14.16" | ||
"node": ">=16" | ||
}, | ||
@@ -55,18 +55,22 @@ "repository": { | ||
"devDependencies": { | ||
"@eslint/compat": "^1.1.1", | ||
"@eslint/eslintrc": "^3.1.0", | ||
"@eslint/js": "^9.7.0", | ||
"@types/chai": "^4.3.16", | ||
"@types/debug": "^4.1.12", | ||
"@types/mocha": "^10.0.7", | ||
"@types/node": "^20.14.9", | ||
"@typescript-eslint/eslint-plugin": "^7.15.0", | ||
"@typescript-eslint/parser": "^7.15.0", | ||
"@types/node": "^20.14.10", | ||
"@typescript-eslint/eslint-plugin": "^7.16.1", | ||
"@typescript-eslint/parser": "^7.16.1", | ||
"c8": "^10.1.2", | ||
"chai": "^5.1.1", | ||
"del-cli": "^5.1.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint": "^9.7.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-jsdoc": "^46.8.2", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jsdoc": "^48.7.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-unicorn": "^54.0.0", | ||
"global": "^4.4.0", | ||
"mocha": "^10.6.0", | ||
@@ -82,3 +86,3 @@ "remark-cli": "^12.0.1", | ||
"@tokenizer/token": "^0.3.0", | ||
"peek-readable": "^5.1.1" | ||
"peek-readable": "^5.1.3" | ||
}, | ||
@@ -98,3 +102,4 @@ "keywords": [ | ||
"streaming" | ||
] | ||
], | ||
"packageManager": "yarn@4.3.1" | ||
} |
@@ -1,2 +0,3 @@ | ||
![Node.js CI](https://github.com/Borewit/strtok3/workflows/Node.js%20CI/badge.svg) | ||
[![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) | ||
[![CodeQL](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/Borewit/strtok3/actions/workflows/codeql.yml) | ||
[![NPM version](https://badge.fury.io/js/strtok3.svg)](https://npmjs.org/package/strtok3) | ||
@@ -35,3 +36,3 @@ [![npm downloads](http://img.shields.io/npm/dm/strtok3.svg)](https://npmcharts.com/compare/strtok3,token-types?start=1200&interval=30) | ||
JavaScript is compliant with [ECMAScript 2019 (ES10)](https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019). | ||
Requires Node.js ≥ 14.16 engine. | ||
Requires Node.js ≥ 16 engine. | ||
@@ -38,0 +39,0 @@ ## API |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318
48439
27
17
640
Updatedpeek-readable@^5.1.3