Last active
October 7, 2017 03:07
-
-
Save allain/cf1e5abc9d1a22b65abbdfc0c4515e05 to your computer and use it in GitHub Desktop.
use npmjs from the browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('installed: need, crave') | |
crave = m => fetch(`https://wzrd.in/bundle/${m}@latest/`) | |
.then(r => r.text()) | |
.then(eval) | |
.then(() => require(m)) | |
need = m => {crave(m).then(r => { | |
window[m] = r | |
console.log(`installed: ${m}`) | |
})} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on: https://gist.github.com/mathisonian/c325dbe02ea4d6880c4e | |
// usage once run in the browser (using a bookmarklet: https://bookmarkify.it/7166) | |
// folktale gets downloaded but not made available globally | |
crave('folktale').then(console.log) | |
// folktale gets installed globally | |
need('folktale') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment