New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dom-storage

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-storage - npm Package Compare versions

Comparing version

to
2.1.0

17

lib/index.js

@@ -11,9 +11,7 @@ // http://www.rajdeepd.com/articles/chrome/localstrg/LocalStorageSample.htm

var fs = require('fs')
;
var fs = require('fs');
function Storage(path, opts) {
opts = opts || {};
var db
;
var db;

@@ -92,9 +90,10 @@ Object.defineProperty(this, '___priv_bk___', {

Storage.prototype.__defineGetter__('length', function () {
return Object.keys(this).length;
Object.defineProperty(Storage.prototype, 'length', {
get: function() {
return Object.keys(this).length;
}
});
Storage.prototype.___save___ = function () {
var self = this
;
var self = this;

@@ -118,2 +117,4 @@ if (!this.___priv_bk___.path) {

if (e) {
console.error('Could not write to database', self.___priv_bk___.path);
console.error(e);
return;

@@ -120,0 +121,0 @@ }

{
"author": "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info)",
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)",
"homepage": "https://git.coolaj86.com/coolaj86/dom-storage.js",
"name": "dom-storage",
"description": "W3C DOM Storage (localStorage and sessionStorage) for Node.JS",
"version": "2.0.2",
"description": "W3C DOM Storage (localStorage and sessionStorage) for node.js",
"version": "2.1.0",
"repository": {
"type": "git",
"url": "git://github.com/coolaj86/node-dom-storage.git"
"url": "git://git.coolaj86.com/coolaj86/dom-storage.js.git"
},

@@ -15,4 +16,4 @@ "engines": {

"dependencies": {},
"license": "Apache2",
"license": "(MIT or Apache-2.0)",
"devDependencies": {}
}
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.

@@ -15,12 +22,11 @@

```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' };

@@ -55,11 +61,11 @@ localStorage.setItem('myKey', myValue);

0 === localStorage.length;
null === localStorage.getItem('doesn't exist');
undefined === localStorage['doesn't exist'];
null === localStorage.getItem('doesn\'t exist');
undefined === localStorage['doesn\'t exist'];
localStorage.setItem('myItem');
"undefined" === localStorage.getItem('myItem');
'undefined' === localStorage.getItem('myItem');
1 === localStorage.length;
localStorage.setItem('myItem', 0);
"0" === localStorage.getItem('myItem');
'0' === localStorage.getItem('myItem');

@@ -83,2 +89,8 @@ localStorage.removeItem('myItem', 0);

* [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.