mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
* Fix return type of Archive#open
`Archive.open(f, o)` calls `new Archive(f, o)` and returns `archive.open()`, which returns a `Promise<Archive>`.
So this method is actually synchronous.
Refs:
https://github.com/nika-begiashvili/libarchivejs#readme
d2c4d676e5/src/libarchive.js (L24-L30)
* Adjust test for `Archive#open`
Adjust tests to assert return type to be `Promise<Archive>`.
39 lines
1002 B
TypeScript
39 lines
1002 B
TypeScript
import { Archive } from 'libarchive.js/main';
|
|
|
|
let testFile: File = new File([""], "filename");
|
|
const testArchive = new Archive(testFile, { workerUrl: 'test'});
|
|
|
|
Archive.init({ workerUrl: 'test' });
|
|
Archive.open(testFile).then(e => void e);
|
|
Archive.open(testFile, { workerUrl: 'test' }).then(e => void e);
|
|
|
|
const FilesObject1: { [key: string]: any } = {
|
|
test2: testFile
|
|
};
|
|
|
|
let FilesObject2: { [key: string]: any } = {
|
|
test2: FilesObject1
|
|
};
|
|
|
|
let testArray: Array<{ file: any, path: string }> = [];
|
|
|
|
testArchive.hasEncryptedData().then((res) => {
|
|
console.log(res);
|
|
});
|
|
testArchive.usePassword('qwe').then(() => {});
|
|
testArchive.getFilesObject().then((res) => {
|
|
FilesObject2 = res;
|
|
});
|
|
testArchive.getFilesArray().then((res) => {
|
|
testArray = res;
|
|
});
|
|
testArchive.extractFiles((entry) => {
|
|
testArray.push(entry);
|
|
}).then(() => {});
|
|
testArchive.extractFiles().then((res) => {
|
|
FilesObject2 = res;
|
|
});
|
|
testArchive.extractSingleFile('qwe').then((res) => {
|
|
testFile = res;
|
|
});
|