mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
add type yazl
This commit is contained in:
46
types/yazl/index.d.ts
vendored
Normal file
46
types/yazl/index.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// Type definitions for yazl 2.4
|
||||
// Project: https://github.com/thejoshwolfe/yazl
|
||||
// Definitions by: taoqf <https://github.com/taoqf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Readable, Writable } from 'stream';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
export interface Options {
|
||||
mtime: Date;
|
||||
mode: number;
|
||||
compress: boolean;
|
||||
forceZip64Format: boolean;
|
||||
}
|
||||
|
||||
export interface ReadStreamOptions extends Options {
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface DirectoryOptions {
|
||||
mtime: Date;
|
||||
mode: number;
|
||||
}
|
||||
|
||||
export interface EndOptions {
|
||||
forceZip64Format: boolean;
|
||||
}
|
||||
|
||||
export interface DosDateTime {
|
||||
date: number;
|
||||
time: number;
|
||||
}
|
||||
|
||||
export class ZipFile {
|
||||
addFile(realPath: string, metadataPath: string, options?: Partial<Options>): void;
|
||||
outputStream: Writable;
|
||||
addReadStream(input: Readable, metadataPath: string, options?: Partial<ReadStreamOptions>): void;
|
||||
addBuffer(buffer: Buffer, metadataPath: string, options?: Partial<Options>): void;
|
||||
end(optoins?: EndOptions, finalSizeCallback?: () => void): void;
|
||||
|
||||
addEmptyDirectory(metadataPath: string, options?: Partial<DirectoryOptions>): void;
|
||||
dateToDosDateTime(jsDate: Date): DosDateTime;
|
||||
}
|
||||
23
types/yazl/tsconfig.json
Normal file
23
types/yazl/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"yazl-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/yazl/tslint.json
Normal file
1
types/yazl/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
22
types/yazl/yazl-tests.ts
Normal file
22
types/yazl/yazl-tests.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { ZipFile } from "yazl";
|
||||
import fs = require('fs');
|
||||
|
||||
const zipfile = new ZipFile();
|
||||
zipfile.addFile("file1.txt", "file1.txt");
|
||||
// (add only files, not directories)
|
||||
zipfile.addFile("path/to/file.txt", "path/in/zipfile.txt");
|
||||
// pipe() can be called any time after the constructor
|
||||
zipfile.outputStream.pipe(fs.createWriteStream("output.zip")).on("close", () => {
|
||||
console.log("done");
|
||||
});
|
||||
// alternate apis for adding files:
|
||||
zipfile.addReadStream(process.stdin, "stdin.txt", {
|
||||
mtime: new Date(),
|
||||
mode: parseInt("0100664", 8), // -rw-rw-r--
|
||||
});
|
||||
zipfile.addBuffer(new Buffer("hello"), "hello.txt", {
|
||||
mtime: new Date(),
|
||||
mode: parseInt("0100664", 8), // -rw-rw-r--
|
||||
});
|
||||
// call end() after all the files have been added
|
||||
zipfile.end();
|
||||
Reference in New Issue
Block a user