🤖 Merge PR #53739 update(7zip-min): type callbacks by @peterblazejewicz

- type NodeJS style callbacks
- update tests
- drop TS minimum

https://github.com/onikienko/7zip-min/blob/master/index.js#L57
https://github.com/onikienko/7zip-min/blob/master/index.js#L64

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz)
2021-06-28 15:30:42 +02:00
committed by GitHub
parent abb4d19ef1
commit ae9a4cff12
2 changed files with 13 additions and 21 deletions

View File

@@ -1,25 +1,18 @@
import _7z = require('7zip-min');
_7z.pack("index.d.ts", "archive.7z", (err: any) => { });
_7z.unpack("archive.7z", "./", (err: any) => { });
_7z.unpack("archive.7z", (err: any) => { });
_7z.list("archive.7z", (err: any, result: _7z.Result[]) => {
// $ExpectType void
_7z.pack('index.d.ts', 'archive.7z', err => {});
// $ExpectType void
_7z.unpack('archive.7z', './', err => {});
// $ExpectType void
_7z.unpack('archive.7z', err => {});
// $ExpectType void
_7z.list('archive.7z', (err, result) => {
if (err) {
return;
}
for (const item of result) {
// attr:'A'
// block:''
// compressed:'0'
// crc:''
// date:'2021-03-20'
// encrypted:'-'
// method:''
// name:'index.js'
// size:'0'
// time:'12:07:46'
item.attr; // $ExpectType string
item.block; // $ExpectType string
item.compressed; // $ExpectType string

View File

@@ -2,13 +2,12 @@
// Project: https://github.com/onikienko/7zip-min
// Definitions by: Tanandara <https://github.com/Tanandara>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.6
export function unpack(pathToArchive: string, whereToUnpack: string, errorCallback: (err: any) => void): void;
export function unpack(pathToArchive: string, errorCallback: (err: any) => void): void;
export function pack(pathToDirOrFile: string, pathToArchive: string, errorCallback: (err: any) => void): void;
export function list(pathToArchive: string, callback: (err: any, result: Result[]) => void): void;
export function cmd(command: string[], errorCallback: (err: any) => void): void;
export function unpack(pathToArchive: string, whereToUnpack: string, errorCallback: (err: Error | null) => void): void;
export function unpack(pathToArchive: string, errorCallback: (err: Error | null) => void): void;
export function pack(pathToDirOrFile: string, pathToArchive: string, errorCallback: (err: Error | null) => void): void;
export function list(pathToArchive: string, callback: (err: Error | null, result: Result[]) => void): void;
export function cmd(command: string[], errorCallback: (err: Error | null) => void): void;
export interface Result {
name: string;
date: string;