本文整理汇总了TypeScript中byline类的典型用法代码示例。如果您正苦于以下问题:TypeScript byline类的具体用法?TypeScript byline怎么用?TypeScript byline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了byline类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: GitLFSProgressParser
return process => {
if (lfsProgressPath) {
const lfsParser = new GitLFSProgressParser()
const disposable = tailByLine(lfsProgressPath, line => {
const progress = lfsParser.parse(line)
progressCallback(progress)
})
process.on('close', () => {
disposable.dispose()
// the order of these callbacks is important because
// - unlink can only be done on files
// - rmdir can only be done when the directory is empty
// - we don't want to surface errors to the user if something goes
// wrong (these files can stay in TEMP and be cleaned up eventually)
Fs.unlink(lfsProgressPath, err => {
if (err == null) {
const directory = Path.dirname(lfsProgressPath)
Fs.rmdir(directory, () => {})
}
})
})
}
byline(process.stderr).on('data', (line: string) => {
progressCallback(parser.parse(line))
})
}
示例2: byline
return new Promise<boolean>((c, e) => {
const fileStream = fs.createReadStream(filename, { encoding: 'utf8' });
const stream = byline(fileStream);
stream.on('data', (line: string) => {
if (pattern.test(line)) {
fileStream.close();
c(true);
}
});
stream.on('error', e);
stream.on('end', () => c(false));
});
示例3: createStream
private createStream(file) {
if (this.handleGzip(file)) {
const lineStream = new LineStream();
fs.createReadStream(file)
.pipe(zlib.createGunzip())
.pipe(lineStream);
return lineStream;
}
return byline(fs.createReadStream(file, {
encoding: 'utf-8'
}));
}
示例4: GitLFSProgressParser
return process => {
if (lfsProgressPath) {
const lfsParser = new GitLFSProgressParser()
const disposable = tailByLine(lfsProgressPath, line => {
const progress = lfsParser.parse(line)
progressCallback(progress)
})
process.on('close', () => {
disposable.dispose()
// NB: We don't really care about errors deleting the file, but Node
// gets kinda bothered if we don't provide a callback.
Fs.unlink(lfsProgressPath, () => {})
})
}
byline(process.stderr).on('data', (line: string) => {
progressCallback(parser.parse(line))
})
}
示例5: byline
return process => {
byline(process.stderr).on('data', (line: string) => {
progressCallback(parser.parse(line))
})
}