MCPcopy Create free account
hub / github.com/TruthHun/BookStack / openArrayBuffer

Function openArrayBuffer

static/word2md/mammoth.browser.js:3840–3870  ·  view source on GitHub ↗
(arrayBuffer)

Source from the content-addressed store, hash-verified

3838exports.joinPath = joinPath;
3839
3840function 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
3872function uint8ArrayToBuffer(array) {
3873 if (Buffer.from && Buffer.from !== Uint8Array.from) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected