pouchdb-collections
Advanced tools
Comparing version 6.0.7 to 6.1.0
@@ -13,11 +13,11 @@ 'use strict'; | ||
function LazyMap() { | ||
this.store = {}; | ||
this._store = {}; | ||
} | ||
LazyMap.prototype.get = function (key) { | ||
var mangled = mangle(key); | ||
return this.store[mangled]; | ||
return this._store[mangled]; | ||
}; | ||
LazyMap.prototype.set = function (key, value) { | ||
var mangled = mangle(key); | ||
this.store[mangled] = value; | ||
this._store[mangled] = value; | ||
return true; | ||
@@ -27,15 +27,15 @@ }; | ||
var mangled = mangle(key); | ||
return mangled in this.store; | ||
return mangled in this._store; | ||
}; | ||
LazyMap.prototype.delete = function (key) { | ||
var mangled = mangle(key); | ||
var res = mangled in this.store; | ||
delete this.store[mangled]; | ||
var res = mangled in this._store; | ||
delete this._store[mangled]; | ||
return res; | ||
}; | ||
LazyMap.prototype.forEach = function (cb) { | ||
var keys = Object.keys(this.store); | ||
var keys = Object.keys(this._store); | ||
for (var i = 0, len = keys.length; i < len; i++) { | ||
var key = keys[i]; | ||
var value = this.store[key]; | ||
var value = this._store[key]; | ||
key = unmangle(key); | ||
@@ -45,5 +45,10 @@ cb(value, key); | ||
}; | ||
Object.defineProperty(LazyMap.prototype, 'size', { | ||
get: function () { | ||
return Object.keys(this._store).length; | ||
} | ||
}); | ||
function LazySet(array) { | ||
this.store = new LazyMap(); | ||
this._store = new LazyMap(); | ||
@@ -58,6 +63,6 @@ // init with an array | ||
LazySet.prototype.add = function (key) { | ||
return this.store.set(key, true); | ||
return this._store.set(key, true); | ||
}; | ||
LazySet.prototype.has = function (key) { | ||
return this.store.has(key); | ||
return this._store.has(key); | ||
}; | ||
@@ -64,0 +69,0 @@ |
{ | ||
"name": "pouchdb-collections", | ||
"version": "6.0.7", | ||
"version": "6.1.0", | ||
"description": "Map and Set shims for PouchDB", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -9,11 +9,11 @@ // based on https://github.com/montagejs/collections | ||
function LazyMap() { | ||
this.store = {}; | ||
this._store = {}; | ||
} | ||
LazyMap.prototype.get = function (key) { | ||
var mangled = mangle(key); | ||
return this.store[mangled]; | ||
return this._store[mangled]; | ||
}; | ||
LazyMap.prototype.set = function (key, value) { | ||
var mangled = mangle(key); | ||
this.store[mangled] = value; | ||
this._store[mangled] = value; | ||
return true; | ||
@@ -23,15 +23,15 @@ }; | ||
var mangled = mangle(key); | ||
return mangled in this.store; | ||
return mangled in this._store; | ||
}; | ||
LazyMap.prototype.delete = function (key) { | ||
var mangled = mangle(key); | ||
var res = mangled in this.store; | ||
delete this.store[mangled]; | ||
var res = mangled in this._store; | ||
delete this._store[mangled]; | ||
return res; | ||
}; | ||
LazyMap.prototype.forEach = function (cb) { | ||
var keys = Object.keys(this.store); | ||
var keys = Object.keys(this._store); | ||
for (var i = 0, len = keys.length; i < len; i++) { | ||
var key = keys[i]; | ||
var value = this.store[key]; | ||
var value = this._store[key]; | ||
key = unmangle(key); | ||
@@ -41,5 +41,10 @@ cb(value, key); | ||
}; | ||
Object.defineProperty(LazyMap.prototype, 'size', { | ||
get: function () { | ||
return Object.keys(this._store).length; | ||
} | ||
}); | ||
function LazySet(array) { | ||
this.store = new LazyMap(); | ||
this._store = new LazyMap(); | ||
@@ -54,6 +59,6 @@ // init with an array | ||
LazySet.prototype.add = function (key) { | ||
return this.store.set(key, true); | ||
return this._store.set(key, true); | ||
}; | ||
LazySet.prototype.has = function (key) { | ||
return this.store.has(key); | ||
return this._store.has(key); | ||
}; | ||
@@ -60,0 +65,0 @@ |
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
15706
123