本文整理匯總了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))
})
}