本文整理匯總了TypeScript中unzipper.Parse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Parse函數的具體用法?TypeScript Parse怎麽用?TypeScript Parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Parse函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: process
function process(response: express.Response, filePath: string) {
let chapterPages = [] as shared.IApiChapter;
fs.createReadStream(filePath)
.pipe(unzipper.Parse())
.on('close', () => response.send(chapterPages))
.on('entry', (entry: unzipper.Entry) => {
chapterPages.push(entry.path);
entry.autodrain();
});
}
示例2: process
function process(request: express.Request, response: express.Response, filePath: string) {
fs.createReadStream(filePath)
.pipe(unzipper.Parse())
.on('close', () => {
if (response.headersSent) return;
response.sendStatus(404);
})
.on('entry', (entry: unzipper.Entry) => {
if (entry.path !== request.params.pageName) return entry.autodrain();
response.set('Content-Type', mime.getType(entry.path) || 'application/octet-stream');
return entry.pipe(response);
});
}
示例3: createReadStream
import { Parse, Open, Entry, CentralDirectory } from "unzipper";
import { createReadStream } from "fs";
import { get } from "http";
createReadStream("http://example.org/path/to/archive.zip")
.pipe(Parse())
.on("entry", (entry: Entry) => {
entry.buffer().then((b1: Buffer) => {});
const s1: string = entry.path;
const s2: string = entry.type;
const o1: {
signature?: number;
versionsNeededToExtract: number;
flags: number;
compressionMethod: number;
lastModifiedTime: number;
crc32: number;
compressedSize: number;
fileNameLength: number;
extraFieldLength: number;
} =
entry.vars;
const o2: {
signature: number;
partsize: number;
uncompressedSize: number;
compressedSize: number;
offset: number;
示例4: createReadStream
import {
Parse,
Open,
Entry,
CentralDirectory
} from 'unzipper';
import { createReadStream } from 'fs';
import { get } from 'http';
createReadStream(
'http://example.org/path/to/archive.zip'
).pipe(
Parse()
).on('entry', (entry: Entry) => {
entry.buffer.then((b1: Buffer) => {});
const s1: string = entry.path;
const s2: string = entry.type;
const o1: {
signature?: number;
versionsNeededToExtract: number;
flags: number;
compressionMethod: number;
lastModifiedTime: number;
crc32: number;
compressedSize: number;
fileNameLength: number;
extraFieldLength: number;
} = entry.vars;