|
|
@ -1,6 +1,13 @@ |
|
|
|
sessionStorage & localStorage for NodeJS |
|
|
|
=== |
|
|
|
|
|
|
|
| **dom-storage** |
|
|
|
| [atob](https://git.coolaj86.com/coolaj86/atob.js) |
|
|
|
| [btoa](https://git.coolaj86.com/coolaj86/btoa.js) |
|
|
|
| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js) |
|
|
|
| Sponsored by [ppl](https://ppl.family) |
|
|
|
|
|
|
|
|
|
|
|
An inefficient, but as W3C-compliant as possible using only pure JavaScript, `DOMStorage` implementation. |
|
|
|
|
|
|
|
Purpose |
|
|
@ -12,16 +19,15 @@ Usage |
|
|
|
---- |
|
|
|
|
|
|
|
```javascript |
|
|
|
var Storage = require('dom-storage') |
|
|
|
var Storage = require('dom-storage'); |
|
|
|
|
|
|
|
// in-file, doesn't call `String(val)` on values (default) |
|
|
|
, localStorage = new Storage('./db.json', { strict: false, ws: ' ' }) |
|
|
|
// in-file, doesn't call `String(val)` on values (default) |
|
|
|
var localStorage = new Storage('./db.json', { strict: false, ws: ' ' }); |
|
|
|
|
|
|
|
// in-memory, does call `String(val)` on values (i.e. `{}` becomes `'[object Object]'` |
|
|
|
, sessionStorage = new Storage(null, { strict: true }) |
|
|
|
// in-memory, does call `String(val)` on values (i.e. `{}` becomes `'[object Object]'` |
|
|
|
var sessionStorage = new Storage(null, { strict: true }); |
|
|
|
|
|
|
|
, myValue = { foo: 'bar', baz: 'quux' } |
|
|
|
; |
|
|
|
var myValue = { foo: 'bar', baz: 'quux' }; |
|
|
|
|
|
|
|
localStorage.setItem('myKey', myValue); |
|
|
|
myValue = localStorage.getItem('myKey'); |
|
|
@ -78,4 +84,10 @@ Notes |
|
|
|
License |
|
|
|
------- |
|
|
|
|
|
|
|
* [Apache2](http://www.apache.org/licenses/LICENSE-2.0) |
|
|
|
Code copyright 2012-2018 AJ ONeal |
|
|
|
|
|
|
|
Dual-licensed MIT and Apache-2.0 |
|
|
|
|
|
|
|
Docs copyright 2012-2018 AJ ONeal |
|
|
|
|
|
|
|
Docs released under Creative Commons. |
|
|
|