securityos/node_modules/strtok3/lib/index.js

21 lines
741 B
JavaScript

import * as fs from './FsPromise.js';
import * as core from './core.js';
export { fromFile } from './FileTokenizer.js';
export { EndOfStreamError, fromBuffer } from './core.js';
/**
* 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 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);
}