diff --git a/src/mol-util/_spec/zip.spec.ts b/src/mol-util/_spec/zip.spec.ts index 2e17ab40f8b97ad8567b947cb80855efcc3f6482..6696274ec0d503bc0c3a14735d31ebdeac321f06 100644 --- a/src/mol-util/_spec/zip.spec.ts +++ b/src/mol-util/_spec/zip.spec.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { deflate, inflate, parse, encode } from '../zip/zip' +import { deflate, inflate, unzip, zip } from '../zip/zip' describe('zip', () => { it('roundtrip deflate/inflate', () => { @@ -16,11 +16,11 @@ describe('zip', () => { }) it('roundtrip zip', () => { - const zipped = encode({ + const zipped = zip({ 'test.foo': new Uint8Array([1, 2, 3, 4, 5, 6, 7]) }) console.log(zipped) - const unzipped = parse(zipped) + const unzipped = unzip(zipped) console.log(unzipped) }) }) \ No newline at end of file diff --git a/src/mol-util/data-source.ts b/src/mol-util/data-source.ts index 6a8fe0c47216fbf57ef7e2e4d069800ccf80f125..45d7a9dfd83f5f3df93d2cab8b701e8a6a8ada91 100644 --- a/src/mol-util/data-source.ts +++ b/src/mol-util/data-source.ts @@ -8,8 +8,7 @@ */ import { Task, RuntimeContext } from '../mol-task'; -import { parse, ungzip } from './zip/zip'; -// import { inflate, inflateRaw, parse } from 'uzip-module'; +import { unzip, ungzip } from './zip/zip'; import { utf8Read } from '../mol-io/common/utf8'; // polyfill XMLHttpRequest in node.js @@ -125,7 +124,7 @@ function decompress(data: Uint8Array, compression: DataCompressionMethod): Uint8 case DataCompressionMethod.None: return data case DataCompressionMethod.Gzip: return ungzip(data) case DataCompressionMethod.Zip: - const parsed = parse(data.buffer) + const parsed = unzip(data.buffer) const names = Object.keys(parsed) if (names.length !== 1) throw new Error('can only decompress zip files with a single entry') return parsed[names[0]] as Uint8Array diff --git a/src/mol-util/zip/zip.ts b/src/mol-util/zip/zip.ts index 04c1829a3d015d5e925e8079eb6b9c821b88984a..f5f5e4aaf9ba5b652958f741d1e6c43562cad3e3 100644 --- a/src/mol-util/zip/zip.ts +++ b/src/mol-util/zip/zip.ts @@ -14,7 +14,7 @@ import { crc, adler } from './checksum'; import { _inflate } from './inflate'; import { _deflateRaw } from './deflate'; -export function parse(buf: ArrayBuffer, onlyNames = false) { +export function unzip(buf: ArrayBuffer, onlyNames = false) { const out: { [k: string]: Uint8Array | { size: number, csize: number } } = Object.create(null); const data = new Uint8Array(buf); let eocd = data.length-4; @@ -200,7 +200,7 @@ function deflateRaw(data: Uint8Array, opts?: { level: number }) { return new Uint8Array(buf.buffer, 0, off); } -export function encode(obj: { [k: string]: Uint8Array }, noCmpr = false) { +export function zip(obj: { [k: string]: Uint8Array }, noCmpr = false) { let tot = 0; const zpd: { [k: string]: { cpr: boolean, usize: number, crc: number, file: Uint8Array } } = {}; for(const p in obj) {