Go to file
AJ ONeal d3538718b9 localStorage for Node.JS 2011-07-22 13:21:23 -06:00
lib localStorage for Node.JS 2011-07-22 13:21:23 -06:00
tests localStorage for Node.JS 2011-07-22 13:21:23 -06:00
README.md localStorage for Node.JS 2011-07-22 13:21:23 -06:00

README.md

localStorage

An inefficient, but as W3C-compliant as possible using only pure JavaScript, localStorage implementation.

var localStorage = require('localStorage');

API

  • getItem(key)
  • setItem(key, value)
  • removeItem(key)
  • clear()
  • key(n)
  • length

Tests

0 === localStorage.length;
null === localStorage.getItem('doesn't exist');
undefined === localStorage['doesn't exist'];

localStorage.setItem('myItem');
"undefined" === localStorage.getItem('myItem');
1 === localStorage.length;

localStorage.setItem('myItem', 0);
"0" === localStorage.getItem('myItem');

localStorage.removeItem('myItem', 0);
0 === localStorage.length;

localStorage.clear();
0 === localStorage.length;

TODO / Bugs

Does not persist. Doesn't not emit Storage events