(arrayBuffer)
| 3838 | exports.joinPath = joinPath; |
| 3839 | |
| 3840 | function openArrayBuffer(arrayBuffer) { |
| 3841 | var zipFile = new JSZip(arrayBuffer); |
| 3842 | function exists(name) { |
| 3843 | return zipFile.file(name) !== null; |
| 3844 | } |
| 3845 | |
| 3846 | function read(name, encoding) { |
| 3847 | var array = zipFile.file(name).asUint8Array(); |
| 3848 | var buffer = uint8ArrayToBuffer(array); |
| 3849 | if (encoding) { |
| 3850 | return promises.when(buffer.toString(encoding)); |
| 3851 | } else { |
| 3852 | return promises.when(buffer); |
| 3853 | } |
| 3854 | } |
| 3855 | |
| 3856 | function write(name, contents) { |
| 3857 | zipFile.file(name, contents); |
| 3858 | } |
| 3859 | |
| 3860 | function toBuffer() { |
| 3861 | return zipFile.generate({type: "nodebuffer"}); |
| 3862 | } |
| 3863 | |
| 3864 | return { |
| 3865 | exists: exists, |
| 3866 | read: read, |
| 3867 | write: write, |
| 3868 | toBuffer: toBuffer |
| 3869 | }; |
| 3870 | } |
| 3871 | |
| 3872 | function uint8ArrayToBuffer(array) { |
| 3873 | if (Buffer.from && Buffer.from !== Uint8Array.from) { |
nothing calls this directly
no outgoing calls
no test coverage detected