pouchdb-collections
Advanced tools
Comparing version 6.1.0 to 6.1.1
@@ -5,3 +5,2 @@ 'use strict'; | ||
// based on https://github.com/montagejs/collections | ||
function mangle(key) { | ||
@@ -13,10 +12,10 @@ return '$' + key; | ||
} | ||
function LazyMap() { | ||
function Map$1() { | ||
this._store = {}; | ||
} | ||
LazyMap.prototype.get = function (key) { | ||
Map$1.prototype.get = function (key) { | ||
var mangled = mangle(key); | ||
return this._store[mangled]; | ||
}; | ||
LazyMap.prototype.set = function (key, value) { | ||
Map$1.prototype.set = function (key, value) { | ||
var mangled = mangle(key); | ||
@@ -26,7 +25,7 @@ this._store[mangled] = value; | ||
}; | ||
LazyMap.prototype.has = function (key) { | ||
Map$1.prototype.has = function (key) { | ||
var mangled = mangle(key); | ||
return mangled in this._store; | ||
}; | ||
LazyMap.prototype.delete = function (key) { | ||
Map$1.prototype.delete = function (key) { | ||
var mangled = mangle(key); | ||
@@ -37,3 +36,3 @@ var res = mangled in this._store; | ||
}; | ||
LazyMap.prototype.forEach = function (cb) { | ||
Map$1.prototype.forEach = function (cb) { | ||
var keys = Object.keys(this._store); | ||
@@ -47,3 +46,3 @@ for (var i = 0, len = keys.length; i < len; i++) { | ||
}; | ||
Object.defineProperty(LazyMap.prototype, 'size', { | ||
Object.defineProperty(Map$1.prototype, 'size', { | ||
get: function () { | ||
@@ -54,4 +53,4 @@ return Object.keys(this._store).length; | ||
function LazySet(array) { | ||
this._store = new LazyMap(); | ||
function Set$1(array) { | ||
this._store = new Map$1(); | ||
@@ -65,10 +64,42 @@ // init with an array | ||
} | ||
LazySet.prototype.add = function (key) { | ||
Set$1.prototype.add = function (key) { | ||
return this._store.set(key, true); | ||
}; | ||
LazySet.prototype.has = function (key) { | ||
Set$1.prototype.has = function (key) { | ||
return this._store.has(key); | ||
}; | ||
Set$1.prototype.forEach = function (cb) { | ||
this._store.forEach(function (value, key) { | ||
cb(key); | ||
}); | ||
}; | ||
Object.defineProperty(Set$1.prototype, 'size', { | ||
get: function () { | ||
return this._store.size; | ||
} | ||
}); | ||
exports.Set = LazySet; | ||
exports.Map = LazyMap; | ||
/* global Map,Set,Symbol */ | ||
// Based on https://kangax.github.io/compat-table/es6/ we can sniff out | ||
// incomplete Map/Set implementations which would otherwise cause our tests to fail. | ||
// Notably they fail in IE11 and iOS 8.4, which this prevents. | ||
function supportsMapAndSet() { | ||
if (typeof Symbol === 'undefined' || typeof Map === 'undefined' || typeof Set === 'undefined') { | ||
return false; | ||
} | ||
var prop = Object.getOwnPropertyDescriptor(Map, Symbol.species); | ||
return prop && 'get' in prop && Map[Symbol.species] === Map; | ||
} | ||
// based on https://github.com/montagejs/collections | ||
/* global Map,Set */ | ||
{ | ||
if (supportsMapAndSet()) { // prefer built-in Map/Set | ||
exports.Set = Set; | ||
exports.Map = Map; | ||
} else { // fall back to our polyfill | ||
exports.Set = Set$1; | ||
exports.Map = Map$1; | ||
} | ||
} |
{ | ||
"name": "pouchdb-collections", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"description": "Map and Set shims for PouchDB", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
// based on https://github.com/montagejs/collections | ||
function mangle(key) { | ||
return '$' + key; | ||
} | ||
function unmangle(key) { | ||
return key.substring(1); | ||
} | ||
function LazyMap() { | ||
this._store = {}; | ||
} | ||
LazyMap.prototype.get = function (key) { | ||
var mangled = mangle(key); | ||
return this._store[mangled]; | ||
}; | ||
LazyMap.prototype.set = function (key, value) { | ||
var mangled = mangle(key); | ||
this._store[mangled] = value; | ||
return true; | ||
}; | ||
LazyMap.prototype.has = function (key) { | ||
var mangled = mangle(key); | ||
return mangled in this._store; | ||
}; | ||
LazyMap.prototype.delete = function (key) { | ||
var mangled = mangle(key); | ||
var res = mangled in this._store; | ||
delete this._store[mangled]; | ||
return res; | ||
}; | ||
LazyMap.prototype.forEach = function (cb) { | ||
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]; | ||
key = unmangle(key); | ||
cb(value, key); | ||
} | ||
}; | ||
Object.defineProperty(LazyMap.prototype, 'size', { | ||
get: function () { | ||
return Object.keys(this._store).length; | ||
} | ||
}); | ||
/* global Map,Set */ | ||
function LazySet(array) { | ||
this._store = new LazyMap(); | ||
import ShimmedMap from './Map'; | ||
import ShimmedSet from './Set'; | ||
import supportsMapAndSet from './supportsMapAndSet'; | ||
// init with an array | ||
if (array && Array.isArray(array)) { | ||
for (var i = 0, len = array.length; i < len; i++) { | ||
this.add(array[i]); | ||
} | ||
var ExportedSet; | ||
var ExportedMap; | ||
if (process.env.COVERAGE) { // don't penalize ourselves on coverage | ||
ExportedSet = ShimmedSet; | ||
ExportedMap = ShimmedMap; | ||
} else { | ||
if (supportsMapAndSet()) { // prefer built-in Map/Set | ||
ExportedSet = Set; | ||
ExportedMap = Map; | ||
} else { // fall back to our polyfill | ||
ExportedSet = ShimmedSet; | ||
ExportedMap = ShimmedMap; | ||
} | ||
} | ||
LazySet.prototype.add = function (key) { | ||
return this._store.set(key, true); | ||
}; | ||
LazySet.prototype.has = function (key) { | ||
return this._store.has(key); | ||
}; | ||
export { | ||
LazySet as Set, | ||
LazyMap as Map | ||
ExportedSet as Set, | ||
ExportedMap as Map | ||
}; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
17935
8
194
2
2