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