web-storages
Emulating localStorage and sessionStorage if not exist.
Install
Install with npm:
npm install web-storages
API - Set functions by args
// On node.js, storages will attached to global automatically. // Take care for that exporting storages are not equals global storages. ; // localStorage localStorage; localStorage; console; // => 'Hello,hoge!' console; // => 'hoge' console; // => 2 localStorage; console); // => null console; // => 1 localStorageclear; console); // => null console; // => 0 // sessionStorage sessionStorage; sessionStorage; console; // => 'Hello,hoge!' console; // => 'hoge' console; // => 2 sessionStorage; console); // => null console; // => 1 sessionStorageclear; console); // => null console; // => 0
also use on browser
On browser, storages will attached to window automatically.
Now, almost all browsers have implemented web-storage, so that
native module is used in natural.
If you want to use this storages on a modern browser,
you have to prepare "module.exports" object or "global" object
on window namespace.
Ways to import module with using "require-js"
or "foonyah" is awesome way for importing module.
And more, 4 functions to access "document.cookie" are attached to exports.
docCookie(document)
... change cookie document to arguments[0] provided.
keyCookie()
... get cookies key array.
setCookie(key, value, options)
... set a cookie value. options accepts or to given days of period.
getCookie(key)
.. get a cookie value.