diff --git a/zip.js/zip.js-tests.ts b/zip.js/zip.js-tests.ts index bacaf1cd6..fa085ca38 100644 --- a/zip.js/zip.js-tests.ts +++ b/zip.js/zip.js-tests.ts @@ -1,18 +1,18 @@ // create the blob object storing the data to compress -var blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { +var blob: Blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { type : "text/plain" }); // creates a zip storing the file "lorem.txt" with blob as data // the zip will be stored into a Blob object (zippedBlob) -zipBlob("lorem.txt", blob, function(zippedBlob) { +zipBlob("lorem.txt", blob, function(zippedBlob: Blob) { // unzip the first file from zipped data stored in zippedBlob - unzipBlob(zippedBlob, function(unzippedBlob) { + unzipBlob(zippedBlob, function(unzippedBlob: Blob) { // logs the uncompressed Blob console.log(unzippedBlob); }); }); -function zipBlob(filename, blob, callback) { +function zipBlob(filename: string, blob: Blob, callback: (blob: Blob) => void) { // use a zip.BlobWriter object to write zipped data into a Blob object zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) { // use a BlobReader object to read the data stored into blob variable @@ -20,24 +20,24 @@ function zipBlob(filename, blob, callback) { // close the writer and calls callback function zipWriter.close(callback); }); - }, onerror); + }, theErrorHandler); } -function unzipBlob(blob, callback) { +function unzipBlob(blob: Blob, callback: (unzippedBlob: Blob) => void) { // use a zip.BlobReader object to read zipped data stored into blob variable zip.createReader(new zip.BlobReader(blob), function(zipReader) { // get entries from the zip file - zipReader.getEntries(function(entries) { + zipReader.getEntries(function(entries: zip.Entry[]) { // get data from the first file - entries[0].getData(new zip.BlobWriter("text/plain"), function(data) { + entries[0].getData(new zip.BlobWriter("text/plain"), function(data: Blob) { // close the reader and calls callback function with uncompressed data as parameter zipReader.close(); callback(data); }); }); - }, onerror); + }, theErrorHandler); } -function onerror(message) { +function theErrorHandler(message) { console.error(message); } \ No newline at end of file