-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add es6 module support #717
Comments
An example of how to use it in a web browser, which is not in their readme (@101arrowz): import { unzipSync, strFromU8 } from 'fflate'
/**
* Reads XLSX file in a browser.
* @param {File} file - A `File` object being uploaded in the browser.
* @return {Promise} Resolves to an object holding XLSX file entries.
*/
export default function unpackXlsxFile(file) {
return file.arrayBuffer().then((fileBuffer) => {
const archive = new Uint8Array(fileBuffer)
const contents = unzipSync(archive)
return getContents(contents)
// return new Promise((resolve, reject) => {
// unzip(archive, (error, contents) => {
// if (error) {
// return reject(error)
// }
// return resolve(getContents(contents))
// })
// })
})
}
function getContents(contents) {
const unzippedFiles = []
for (const key of Object.keys(contents)) {
unzippedFiles[key] = strFromU8(contents[key])
}
return unzippedFiles
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please add es6 module support
The text was updated successfully, but these errors were encountered: