UNPKG

3.3 kBSource Map (JSON)View Raw
1{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../../../src/_utils/zip/zip.ts"],"names":[],"mappings":";;;;AAOA,qDAAoD;AAkBpD;IAAA;IAoCA,CAAC;IA5BgB,qCAAuB,GAApC,UAAqC,SAAiB,EAAE,KAAa,EAAE,GAAW;;;;;;;;wBAIxD,WAAM,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAA;;wBAA1D,eAAe,GAAG,SAAwC,CAAC;;;;wBAE3D,OAAO,CAAC,GAAG,CAAC,KAAG,CAAC,CAAC;wBACjB,WAAO,OAAO,CAAC,MAAM,CAAC,KAAG,CAAC,EAAC;;wBAGzB,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;wBAC1B,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;wBAIjD,MAAM,GAAG,IAAI,yBAAW,CAAC,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;wBAE7D,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBAE9B,GAAG,GAAqB;4BAC1B,MAAM,EAAE,eAAe,CAAC,MAAM;4BAC9B,KAAK,EAAE;;oCACH,WAAO,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,EAAC;;iCAC9D;4BACD,MAAM,QAAA;yBACT,CAAC;wBACF,WAAO,GAAG,EAAC;;;;KACd;IACL,UAAC;AAAD,CAAC,AApCD,IAoCC;AApCqB,kBAAG","sourcesContent":["// ==LICENSE-BEGIN==\n// Copyright 2017 European Digital Reading Lab. All rights reserved.\n// Licensed to the Readium Foundation under one or more contributor license agreements.\n// Use of this source code is governed by a BSD-style license\n// that can be found in the LICENSE file exposed on Github (readium) in the project repository.\n// ==LICENSE-END==\n\nimport { RangeStream } from \"../stream/RangeStream\";\n\nexport interface IStreamAndLength {\n stream: NodeJS.ReadableStream;\n length: number;\n reset: () => Promise<IStreamAndLength>;\n}\n\nexport interface IZip {\n hasEntries: () => boolean;\n entriesCount: () => number;\n hasEntry: (entryPath: string) => boolean;\n getEntries: () => Promise<string[]>;\n entryStreamPromise: (entryPath: string) => Promise<IStreamAndLength>;\n entryStreamRangePromise: (entryPath: string, begin: number, end: number) => Promise<IStreamAndLength>;\n freeDestroy: () => void;\n}\n\nexport abstract class Zip implements IZip {\n public abstract hasEntries(): boolean;\n public abstract entriesCount(): number;\n public abstract hasEntry(entryPath: string): boolean;\n public abstract getEntries(): Promise<string[]>;\n public abstract entryStreamPromise(entryPath: string): Promise<IStreamAndLength>;\n public abstract freeDestroy(): void;\n\n public async entryStreamRangePromise(entryPath: string, begin: number, end: number): Promise<IStreamAndLength> {\n\n let streamAndLength: IStreamAndLength;\n try {\n streamAndLength = await this.entryStreamPromise(entryPath);\n } catch (err) {\n console.log(err);\n return Promise.reject(err);\n }\n\n const b = begin < 0 ? 0 : begin;\n const e = end < 0 ? (streamAndLength.length - 1) : end;\n // const length = e - b + 1;\n // debug(`entryStreamRangePromise: ${b}-${e}/${streamAndLength.length}`);\n\n const stream = new RangeStream(b, e, streamAndLength.length);\n\n streamAndLength.stream.pipe(stream);\n\n const sal: IStreamAndLength = {\n length: streamAndLength.length,\n reset: async () => {\n return this.entryStreamRangePromise(entryPath, begin, end);\n },\n stream,\n };\n return sal;\n }\n}\n"]}
\No newline at end of file