Skip to content

Instantly share code, notes, and snippets.

@kmaher9
Created October 12, 2018 19:35
Show Gist options
  • Save kmaher9/7dc13c3a64116541c6bf191c49800110 to your computer and use it in GitHub Desktop.
Save kmaher9/7dc13c3a64116541c6bf191c49800110 to your computer and use it in GitHub Desktop.
open: function(filePath) {
return new Promise(
function(resolve, reject) {
const zip = new StreamZip({
file: filePath,
storeEntries: true
})
zip.on('ready', () => {
var chunks = []
var content = ''
zip.stream('word/document.xml', (err, stream) => {
if (err) {
reject(err)
}
stream.on('data', function(chunk) {
chunks.push(chunk)
})
stream.on('end', function() {
content = Buffer.concat(chunks)
zip.close()
resolve(content.toString())
})
})
})
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment