本文整理汇总了TypeScript中unzip.Parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Parse函数的具体用法?TypeScript Parse怎么用?TypeScript Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Parse函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return new Promise<void>((resolve, reject) => {
readStream
.pipe(unzip.Parse())
.pipe(writeStream)
.on('close', resolve)
.on('error', reject);
});
示例2:
response.on('end', () => {
Debug.info('PHPStubs Download Complete');
Debug.info(`Unzipping to ${this.getStubsDir()}`);
fs.createReadStream(tmp)
.pipe(unzip.Parse())
.pipe(fstream.Writer(this.getStubsDir()));
window.showInformationMessage('PHP Library Stubs downloaded and installed. You may need to re-index the workspace for them to work correctly.', 'Rebuild Now').then(item => {
this.rebuildProject();
});
});
示例3: Promise
return new Promise(resolve => {
createReadStream(file.getPath(requestState))
.pipe(unzip.Parse())
.on('entry', entry => {
if (entry.type === 'File') {
archive.append(entry, {
name: this.getArchivedFilename(entry.path, file.name),
});
} else {
entry.autodrain();
}
})
.on('error', (err: Error) => logger.info(requestState, 'Error extracting from zip: %s', err.message))
.on('close', resolve);
});
示例4: Error
}, (res) => {
if (res.statusCode !== 200) {
console.error("Couldn't download the release:");
const err = new Error(`Unexpected status code: ${res.statusCode}`);
console.error(err.stack);
process.exit(1);
}
let rootFolderName: string;
res.pipe(unzip.Parse())
.on("entry", (entry: any) => {
if (rootFolderName == null) {
rootFolderName = entry.path;
return;
}
const entryPath = `${downloadPath}/${entry.path.replace(rootFolderName, "")}`;
if (entry.type === "Directory") mkdirp.sync(entryPath);
else entry.pipe(fs.createWriteStream(entryPath));
})
.on("close", () => { callback(); });
});
示例5:
import * as unzip from 'unzip';
import * as fs from 'fs';
fs.createReadStream('path/to/archive.zip')
.pipe(unzip.Extract({ path: 'output/path' }));
fs.createReadStream('path/to/archive.zip')
.pipe(unzip.Parse())
.on('entry', (entry: unzip.Entry) => {
const fileName = entry.path;
const type = entry.type; // 'Directory' or 'File'
const size = entry.size;
if (fileName === "this IS the file I'm looking for") {
entry.pipe(fs.createWriteStream('output/path'));
} else {
entry.autodrain();
}
});