mirror of
https://github.com/codedread/bitjs
synced 2025-10-04 01:59:15 +02:00
Add some unit tests for unarchivers. Provide a way to disconnect the impl from the host (for unit tests).
This commit is contained in:
parent
eba7042abe
commit
cf26e0a2de
17 changed files with 211 additions and 13 deletions
|
@ -781,8 +781,30 @@ const onmessage = function (event) {
|
|||
*/
|
||||
export function connect(port) {
|
||||
if (hostPort) {
|
||||
throw `hostPort already connected`;
|
||||
throw `hostPort already connected in unzip.js`;
|
||||
}
|
||||
|
||||
hostPort = port;
|
||||
port.onmessage = onmessage;
|
||||
}
|
||||
|
||||
export function disconnect() {
|
||||
if (!hostPort) {
|
||||
throw `hostPort was not connected in unzip.js`;
|
||||
}
|
||||
|
||||
hostPort = null;
|
||||
|
||||
unarchiveState = UnarchiveState.NOT_STARTED;
|
||||
bytestream = null;
|
||||
allLocalFiles = null;
|
||||
logToConsole = false;
|
||||
|
||||
// Progress variables.
|
||||
currentFilename = '';
|
||||
currentFileNumber = 0;
|
||||
currentBytesUnarchivedInFile = 0;
|
||||
currentBytesUnarchived = 0;
|
||||
totalUncompressedBytesInArchive = 0;
|
||||
totalFilesInArchive = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue