Skip to content

ndemianc/idb-keyval-with-coffee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IDB-Keyval written in CoffeeScript

This is implementation of the idb-keyval using CoffeeScript.

Original idea and code for idb-keyval taken from here: https://www.npmjs.com/package/idb-keyval

I like idea of idb-keyval, really super-simple-small keyval store build on top of IndexedDB

I just cannot stop myself from making it even smaller, so I made a port of the idb-keyval to CoffeeScript :)

How to compile:

npm install
coffee --compile idb-keyval.coffee

How to use:

Well the same way as original idb-keyval

set:

idbKeyval.set('hello', 'world');
idbKeyval.set('foo', 'bar');

Since this is IDB-backed, you can store anything structured-clonable (numbers, arrays, objects, dates, blobs etc).

All methods return promises:

idbKeyval.set('hello', 'world')
  .then(() => console.log('It worked!'))
  .catch(err => console.log('It failed!', err));

get:

// logs: "world"
idbKeyval.get('hello').then(val => console.log(val));

keys:

// logs: ["hello", "foo"]
idbKeyval.keys().then(keys => console.log(keys));

delete:

idbKeyval.delete('hello');

clear:

idbKeyval.clear();

This is port of idb-keyval (https://github.com/jakearchibald/idb-keyval) to CoffeeScript!

And there You have it: 43 lines :)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published