Comparing version 3.0.6 to 3.1.0
@@ -5,4 +5,6 @@ /// <reference types="node" /> | ||
private fd; | ||
sourceFilePath: string; | ||
fileSize?: number; | ||
constructor(fd: number, fileSize?: number); | ||
static fromPath(sourceFilePath: string): Promise<FileTokenizer>; | ||
private constructor(); | ||
/** | ||
@@ -9,0 +11,0 @@ * Read buffer from file |
@@ -7,7 +7,16 @@ "use strict"; | ||
class FileTokenizer extends AbstractTokenizer_1.AbstractTokenizer { | ||
constructor(fd, fileSize) { | ||
constructor(fd, sourceFilePath, fileSize) { | ||
super(); | ||
this.fd = fd; | ||
this.sourceFilePath = sourceFilePath; | ||
this.fileSize = fileSize; | ||
} | ||
static async fromPath(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, sourceFilePath, stat.size); | ||
} | ||
/** | ||
@@ -14,0 +23,0 @@ * Read buffer from file |
@@ -11,3 +11,3 @@ /// <reference types="node" /> | ||
*/ | ||
export declare function fromFile(filePath: string): Promise<FileTokenizer>; | ||
export declare const fromFile: typeof FileTokenizer.fromPath; | ||
/** | ||
@@ -14,0 +14,0 @@ * Construct ReadStreamTokenizer from given Stream. |
@@ -12,13 +12,3 @@ "use strict"; | ||
*/ | ||
async function fromFile(filePath) { | ||
if (fs.pathExists(filePath)) { | ||
const stat = await fs.stat(filePath); | ||
const fd = await fs.open(filePath, "r"); | ||
return new FileTokenizer_1.FileTokenizer(fd, stat.size); | ||
} | ||
else { | ||
throw new Error(`File not found: ${filePath}`); | ||
} | ||
} | ||
exports.fromFile = fromFile; | ||
exports.fromFile = FileTokenizer_1.FileTokenizer.fromPath; | ||
/** | ||
@@ -25,0 +15,0 @@ * Construct ReadStreamTokenizer from given Stream. |
{ | ||
"name": "strtok3", | ||
"version": "3.0.6", | ||
"version": "3.1.0", | ||
"description": "A promise based streaming tokenizer", | ||
@@ -38,3 +38,3 @@ "author": { | ||
"devDependencies": { | ||
"@types/chai": "^4.2.4", | ||
"@types/chai": "^4.2.5", | ||
"@types/mocha": "^5.2.7", | ||
@@ -47,7 +47,7 @@ "@types/node": "^12.12.3", | ||
"nyc": "^14.1.1", | ||
"remark-cli": "^7.0.0", | ||
"remark-cli": "^7.0.1", | ||
"remark-preset-lint-recommended": "^3.0.3", | ||
"source-map-support": "^0.5.16", | ||
"ts-node": "^8.4.1", | ||
"tslint": "^5.20.0", | ||
"ts-node": "^8.5.0", | ||
"tslint": "^5.20.1", | ||
"typescript": "^3.6.4" | ||
@@ -54,0 +54,0 @@ }, |
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
36483
715