node-localstorage
Advanced tools
Comparing version 0.3.6 to 0.4.0
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
var LocalStorage, QUOTA_EXCEEDED_ERR, fs, path, _emptyDirectory, _rm, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
__hasProp = {}.hasOwnProperty; | ||
@@ -34,4 +34,4 @@ path = require('path'); | ||
function QUOTA_EXCEEDED_ERR(message) { | ||
this.message = message != null ? message : 'Unknown error.'; | ||
function QUOTA_EXCEEDED_ERR(_at_message) { | ||
this.message = _at_message != null ? _at_message : 'Unknown error.'; | ||
if (Error.captureStackTrace != null) { | ||
@@ -44,3 +44,3 @@ Error.captureStackTrace(this, this.constructor); | ||
QUOTA_EXCEEDED_ERR.prototype.toString = function() { | ||
return "" + this.name + ": " + this.message; | ||
return this.name + ": " + this.message; | ||
}; | ||
@@ -53,5 +53,5 @@ | ||
LocalStorage = (function() { | ||
function LocalStorage(location, quota) { | ||
this.location = location; | ||
this.quota = quota != null ? quota : 5 * 1024 * 1024; | ||
function LocalStorage(_at_location, _at_quota) { | ||
this.location = _at_location; | ||
this.quota = _at_quota != null ? _at_quota : 5 * 1024 * 1024; | ||
if (!(this instanceof LocalStorage)) { | ||
@@ -84,5 +84,5 @@ return new LocalStorage(this.location, this.quota); | ||
k = _ref[_i]; | ||
value = this.getItem(k); | ||
if ((value != null ? value.length : void 0) != null) { | ||
_results.push(this.bytesInUse += value.length); | ||
value = this.getStat(k); | ||
if ((value != null ? value.size : void 0) != null) { | ||
_results.push(this.bytesInUse += value.size); | ||
} else { | ||
@@ -103,3 +103,3 @@ _results.push(void 0); | ||
if (existsBeforeSet) { | ||
oldLength = this.getItem(key).length; | ||
oldLength = this.getStat(key).size; | ||
} else { | ||
@@ -130,2 +130,13 @@ oldLength = 0; | ||
LocalStorage.prototype.getStat = function(key) { | ||
var filename; | ||
key = key.toString(); | ||
filename = path.join(this.location, encodeURIComponent(key)); | ||
if (fs.existsSync(filename)) { | ||
return fs.statSync(filename, 'utf8'); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
LocalStorage.prototype.removeItem = function(key) { | ||
@@ -132,0 +143,0 @@ var filename; |
{ | ||
"name": "node-localstorage", | ||
"version": "0.3.6", | ||
"version": "0.4.0", | ||
"main": "./LocalStorage", | ||
@@ -25,3 +25,3 @@ "description": "A drop-in substitute for the browser native localStorage API that runs on node.js.", | ||
"devDependencies": { | ||
"coffee-script": "^1.8.0", | ||
"coffee-script": "^1.9.0", | ||
"nodeunit": "~0.9.0" | ||
@@ -28,0 +28,0 @@ }, |
@@ -62,2 +62,3 @@ [![build status](https://secure.travis-ci.org/lmaccherone/node-localstorage.png)](http://travis-ci.org/lmaccherone/node-localstorage) | ||
* 0.4.0 - 2015-02-02 - Uses more efficient fs.statSync to set initial size (thanks, sudheer594) | ||
* 0.3.6 - 2014-12-24 - Allows usage without `new` | ||
@@ -64,0 +65,0 @@ * 0.3.5 - 2014-12-23 - Fixed toString() for QuotaExceededError |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18032
12
152
91