Skip to content
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

How to use it in a REPL? #297

Open
siddhsql opened this issue Aug 4, 2023 · 1 comment
Open

How to use it in a REPL? #297

siddhsql opened this issue Aug 4, 2023 · 1 comment

Comments

@siddhsql
Copy link

siddhsql commented Aug 4, 2023

I am new to this library and also indexeddb. Before using it - rather I mean before I write a lot of code using this library, I just want to test it out (test-drive) in a REPL. The library cannot be used in a Node REPL since IndexedDB does not exist in Node. It only exists in browser. And I cannot use it in browser REPL (chrome dev tools) as the import/require does not work. e.g.: this code won't work in chrome dev tools console:

const { openDB, deleteDB, wrap, unwrap } = require( 'idb' );

what is the best way to prototype/test out this library?

@jcbhmr
Copy link

jcbhmr commented Aug 10, 2023

You can use something like https://www.jsdelivr.com/esm or https://esm.sh/ to import packages in your browser's DevTools on any page you want! (as long as there's no CSP)

i like to use https://example.org or https://example.com since they have no CSP

let m; m = await import("https://esm.run/idb")
let db; db = await m.openDB("hello-world")

image

if you're more adventurous, you can use a browser-based ide like https://codesandbox.io/ or https://stackblitz.com/ or https://codepen.io/ depending on your needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants