Skip to content

Instantly share code, notes, and snippets.

@royashbrook
Created September 16, 2020 14:09
Show Gist options
  • Save royashbrook/4ab180673a9d50e734bae481e176d8c4 to your computer and use it in GitHub Desktop.
Save royashbrook/4ab180673a9d50e734bae481e176d8c4 to your computer and use it in GitHub Desktop.
From JSZip to unzipit
//import or add cdn for global, url should be passed in somehow
fetch(url)
.then(r=>r.blob())
.then(JSZip.loadAsync)
.then(zip=>zip.files[Object.keys(zip.files)[0]].async('string'))
.then(JSON.parse)
//import or add cdn for global, url should be passed in somehow
unzip(url)
.then(x => x.entries[Object.keys(x.entries)[0]])
.then(x => x.blob())
.then(x => x.text())
.then(JSON.parse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment