pouchdb-utils
Advanced tools
Comparing version 7.2.2 to 7.3.0
@@ -7,2 +7,3 @@ import getArguments from 'argsarray'; | ||
import EventEmitter from 'events'; | ||
import { assign } from 'pouchdb-utils'; | ||
import { v4 } from 'uuid'; | ||
@@ -79,3 +80,3 @@ import { stringMd5 } from 'pouchdb-md5'; | ||
// and other backends, we automatically stringify Dates | ||
if (object instanceof Date) { | ||
if (object instanceof Date && isFinite(object)) { | ||
return object.toISOString(); | ||
@@ -490,10 +491,10 @@ } | ||
var assign; | ||
var assign$1; | ||
{ | ||
if (typeof Object.assign === 'function') { | ||
assign = Object.assign; | ||
assign$1 = Object.assign; | ||
} else { | ||
// lite Object.assign polyfill based on | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign | ||
assign = function (target) { | ||
assign$1 = function (target) { | ||
var to = Object(target); | ||
@@ -518,3 +519,3 @@ | ||
var assign$1 = assign; | ||
var assign$2 = assign$1; | ||
@@ -557,3 +558,3 @@ function tryFilter(filter, doc, req) { | ||
/* istanbul ignore else */ | ||
if (change.doc._attachments.hasOwnProperty(att)) { | ||
if (Object.prototype.hasOwnProperty.call(change.doc._attachments, att)) { | ||
change.doc._attachments[att].stub = true; | ||
@@ -673,3 +674,3 @@ } | ||
// use the "loose" parser | ||
/* eslint maxlen: 0, no-useless-escape: 0 */ | ||
/* eslint no-useless-escape: 0 */ | ||
var parser = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; | ||
@@ -707,3 +708,3 @@ | ||
for (var key in scope) { | ||
if (scope.hasOwnProperty(key)) { | ||
if (Object.prototype.hasOwnProperty.call(scope, key)) { | ||
keys.push(key); | ||
@@ -721,12 +722,11 @@ values.push(scope[key]); | ||
function upsert(db, docId, diffFun) { | ||
return new Promise(function (fulfill, reject) { | ||
db.get(docId, function (err, doc) { | ||
if (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
return reject(err); | ||
} | ||
doc = {}; | ||
return db.get(docId) | ||
.catch(function (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
throw err; | ||
} | ||
return {}; | ||
}) | ||
.then(function (doc) { | ||
// the user might change the _rev, so save it for posterity | ||
@@ -739,3 +739,3 @@ var docRev = doc._rev; | ||
// an optimization | ||
return fulfill({updated: false, rev: docRev}); | ||
return {updated: false, rev: docRev}; | ||
} | ||
@@ -747,5 +747,4 @@ | ||
newDoc._rev = docRev; | ||
fulfill(tryAndPut(db, newDoc, diffFun)); | ||
return tryAndPut(db, newDoc, diffFun); | ||
}); | ||
}); | ||
} | ||
@@ -768,4 +767,7 @@ | ||
/** | ||
* Creates a new revision string that does NOT include the revision height | ||
* For example '56649f1b0506c6ca9fda0746eb0cacdf' | ||
*/ | ||
function rev(doc, deterministic_revs) { | ||
var clonedDoc = clone(doc); | ||
if (!deterministic_revs) { | ||
@@ -775,4 +777,5 @@ return v4().replace(/-/g, '').toLowerCase(); | ||
delete clonedDoc._rev_tree; | ||
return stringMd5(JSON.stringify(clonedDoc)); | ||
var mutateableDoc = assign({}, doc); | ||
delete mutateableDoc._rev_tree; | ||
return stringMd5(JSON.stringify(mutateableDoc)); | ||
} | ||
@@ -782,2 +785,2 @@ | ||
export { adapterFun, assign$1 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone, defaultBackOff, explainError, filterChange, flatten, res$1 as functionName, guardedConsole, hasLocalStorage, invalidIdError, isRemote, listenerCount, immediate as nextTick, normalizeDesignDocFunctionName as normalizeDdocFunctionName, once, parseDesignDocFunctionName as parseDdocFunctionName, parseUri, pick, rev, scopeEval, toPromise, upsert, uuid }; | ||
export { adapterFun, assign$2 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone, defaultBackOff, explainError, filterChange, flatten, res$1 as functionName, guardedConsole, hasLocalStorage, invalidIdError, isRemote, listenerCount, immediate as nextTick, normalizeDesignDocFunctionName as normalizeDdocFunctionName, once, parseDesignDocFunctionName as parseDdocFunctionName, parseUri, pick, rev, scopeEval, toPromise, upsert, uuid }; |
@@ -13,2 +13,3 @@ 'use strict'; | ||
var EventEmitter = _interopDefault(require('events')); | ||
var pouchdbUtils = require('pouchdb-utils'); | ||
var uuid = require('uuid'); | ||
@@ -85,3 +86,3 @@ var pouchdbMd5 = require('pouchdb-md5'); | ||
// and other backends, we automatically stringify Dates | ||
if (object instanceof Date) { | ||
if (object instanceof Date && isFinite(object)) { | ||
return object.toISOString(); | ||
@@ -561,3 +562,3 @@ } | ||
/* istanbul ignore else */ | ||
if (change.doc._attachments.hasOwnProperty(att)) { | ||
if (Object.prototype.hasOwnProperty.call(change.doc._attachments, att)) { | ||
change.doc._attachments[att].stub = true; | ||
@@ -677,3 +678,3 @@ } | ||
// use the "loose" parser | ||
/* eslint maxlen: 0, no-useless-escape: 0 */ | ||
/* eslint no-useless-escape: 0 */ | ||
var parser = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; | ||
@@ -711,3 +712,3 @@ | ||
for (var key in scope) { | ||
if (scope.hasOwnProperty(key)) { | ||
if (Object.prototype.hasOwnProperty.call(scope, key)) { | ||
keys.push(key); | ||
@@ -725,12 +726,11 @@ values.push(scope[key]); | ||
function upsert(db, docId, diffFun) { | ||
return new Promise(function (fulfill, reject) { | ||
db.get(docId, function (err, doc) { | ||
if (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
return reject(err); | ||
} | ||
doc = {}; | ||
return db.get(docId) | ||
.catch(function (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
throw err; | ||
} | ||
return {}; | ||
}) | ||
.then(function (doc) { | ||
// the user might change the _rev, so save it for posterity | ||
@@ -743,3 +743,3 @@ var docRev = doc._rev; | ||
// an optimization | ||
return fulfill({updated: false, rev: docRev}); | ||
return {updated: false, rev: docRev}; | ||
} | ||
@@ -751,5 +751,4 @@ | ||
newDoc._rev = docRev; | ||
fulfill(tryAndPut(db, newDoc, diffFun)); | ||
return tryAndPut(db, newDoc, diffFun); | ||
}); | ||
}); | ||
} | ||
@@ -772,4 +771,7 @@ | ||
/** | ||
* Creates a new revision string that does NOT include the revision height | ||
* For example '56649f1b0506c6ca9fda0746eb0cacdf' | ||
*/ | ||
function rev(doc, deterministic_revs) { | ||
var clonedDoc = clone(doc); | ||
if (!deterministic_revs) { | ||
@@ -779,4 +781,5 @@ return uuid.v4().replace(/-/g, '').toLowerCase(); | ||
delete clonedDoc._rev_tree; | ||
return pouchdbMd5.stringMd5(JSON.stringify(clonedDoc)); | ||
var mutateableDoc = pouchdbUtils.assign({}, doc); | ||
delete mutateableDoc._rev_tree; | ||
return pouchdbMd5.stringMd5(JSON.stringify(mutateableDoc)); | ||
} | ||
@@ -783,0 +786,0 @@ |
@@ -7,2 +7,3 @@ import cloneBuffer from 'clone-buffer'; | ||
import EventEmitter from 'events'; | ||
import { assign } from 'pouchdb-utils'; | ||
import { v4 } from 'uuid'; | ||
@@ -52,3 +53,3 @@ import { stringMd5 } from 'pouchdb-md5'; | ||
// and other backends, we automatically stringify Dates | ||
if (object instanceof Date) { | ||
if (object instanceof Date && isFinite(object)) { | ||
return object.toISOString(); | ||
@@ -454,10 +455,10 @@ } | ||
var assign; | ||
var assign$1; | ||
{ | ||
if (typeof Object.assign === 'function') { | ||
assign = Object.assign; | ||
assign$1 = Object.assign; | ||
} else { | ||
// lite Object.assign polyfill based on | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign | ||
assign = function (target) { | ||
assign$1 = function (target) { | ||
var to = Object(target); | ||
@@ -482,3 +483,3 @@ | ||
var assign$1 = assign; | ||
var assign$2 = assign$1; | ||
@@ -521,3 +522,3 @@ function tryFilter(filter, doc, req) { | ||
/* istanbul ignore else */ | ||
if (change.doc._attachments.hasOwnProperty(att)) { | ||
if (Object.prototype.hasOwnProperty.call(change.doc._attachments, att)) { | ||
change.doc._attachments[att].stub = true; | ||
@@ -637,3 +638,3 @@ } | ||
// use the "loose" parser | ||
/* eslint maxlen: 0, no-useless-escape: 0 */ | ||
/* eslint no-useless-escape: 0 */ | ||
var parser = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; | ||
@@ -671,3 +672,3 @@ | ||
for (var key in scope) { | ||
if (scope.hasOwnProperty(key)) { | ||
if (Object.prototype.hasOwnProperty.call(scope, key)) { | ||
keys.push(key); | ||
@@ -685,12 +686,11 @@ values.push(scope[key]); | ||
function upsert(db, docId, diffFun) { | ||
return new Promise(function (fulfill, reject) { | ||
db.get(docId, function (err, doc) { | ||
if (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
return reject(err); | ||
} | ||
doc = {}; | ||
return db.get(docId) | ||
.catch(function (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
throw err; | ||
} | ||
return {}; | ||
}) | ||
.then(function (doc) { | ||
// the user might change the _rev, so save it for posterity | ||
@@ -703,3 +703,3 @@ var docRev = doc._rev; | ||
// an optimization | ||
return fulfill({updated: false, rev: docRev}); | ||
return {updated: false, rev: docRev}; | ||
} | ||
@@ -711,5 +711,4 @@ | ||
newDoc._rev = docRev; | ||
fulfill(tryAndPut(db, newDoc, diffFun)); | ||
return tryAndPut(db, newDoc, diffFun); | ||
}); | ||
}); | ||
} | ||
@@ -732,4 +731,7 @@ | ||
/** | ||
* Creates a new revision string that does NOT include the revision height | ||
* For example '56649f1b0506c6ca9fda0746eb0cacdf' | ||
*/ | ||
function rev(doc, deterministic_revs) { | ||
var clonedDoc = clone(doc); | ||
if (!deterministic_revs) { | ||
@@ -739,4 +741,5 @@ return v4().replace(/-/g, '').toLowerCase(); | ||
delete clonedDoc._rev_tree; | ||
return stringMd5(JSON.stringify(clonedDoc)); | ||
var mutateableDoc = assign({}, doc); | ||
delete mutateableDoc._rev_tree; | ||
return stringMd5(JSON.stringify(mutateableDoc)); | ||
} | ||
@@ -746,2 +749,2 @@ | ||
export { adapterFun, assign$1 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone, defaultBackOff, res as explainError, filterChange, flatten, res$2 as functionName, guardedConsole, hasLocalStorage, invalidIdError, isRemote, listenerCount, nextTick, normalizeDesignDocFunctionName as normalizeDdocFunctionName, once, parseDesignDocFunctionName as parseDdocFunctionName, parseUri, pick, rev, scopeEval, toPromise, upsert, uuid }; | ||
export { adapterFun, assign$2 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone, defaultBackOff, res as explainError, filterChange, flatten, res$2 as functionName, guardedConsole, hasLocalStorage, invalidIdError, isRemote, listenerCount, nextTick, normalizeDesignDocFunctionName as normalizeDdocFunctionName, once, parseDesignDocFunctionName as parseDdocFunctionName, parseUri, pick, rev, scopeEval, toPromise, upsert, uuid }; |
@@ -13,2 +13,3 @@ 'use strict'; | ||
var EventEmitter = _interopDefault(require('events')); | ||
var pouchdbUtils = require('pouchdb-utils'); | ||
var uuid = require('uuid'); | ||
@@ -58,3 +59,3 @@ var pouchdbMd5 = require('pouchdb-md5'); | ||
// and other backends, we automatically stringify Dates | ||
if (object instanceof Date) { | ||
if (object instanceof Date && isFinite(object)) { | ||
return object.toISOString(); | ||
@@ -525,3 +526,3 @@ } | ||
/* istanbul ignore else */ | ||
if (change.doc._attachments.hasOwnProperty(att)) { | ||
if (Object.prototype.hasOwnProperty.call(change.doc._attachments, att)) { | ||
change.doc._attachments[att].stub = true; | ||
@@ -641,3 +642,3 @@ } | ||
// use the "loose" parser | ||
/* eslint maxlen: 0, no-useless-escape: 0 */ | ||
/* eslint no-useless-escape: 0 */ | ||
var parser = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; | ||
@@ -675,3 +676,3 @@ | ||
for (var key in scope) { | ||
if (scope.hasOwnProperty(key)) { | ||
if (Object.prototype.hasOwnProperty.call(scope, key)) { | ||
keys.push(key); | ||
@@ -689,12 +690,11 @@ values.push(scope[key]); | ||
function upsert(db, docId, diffFun) { | ||
return new Promise(function (fulfill, reject) { | ||
db.get(docId, function (err, doc) { | ||
if (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
return reject(err); | ||
} | ||
doc = {}; | ||
return db.get(docId) | ||
.catch(function (err) { | ||
/* istanbul ignore next */ | ||
if (err.status !== 404) { | ||
throw err; | ||
} | ||
return {}; | ||
}) | ||
.then(function (doc) { | ||
// the user might change the _rev, so save it for posterity | ||
@@ -707,3 +707,3 @@ var docRev = doc._rev; | ||
// an optimization | ||
return fulfill({updated: false, rev: docRev}); | ||
return {updated: false, rev: docRev}; | ||
} | ||
@@ -715,5 +715,4 @@ | ||
newDoc._rev = docRev; | ||
fulfill(tryAndPut(db, newDoc, diffFun)); | ||
return tryAndPut(db, newDoc, diffFun); | ||
}); | ||
}); | ||
} | ||
@@ -736,4 +735,7 @@ | ||
/** | ||
* Creates a new revision string that does NOT include the revision height | ||
* For example '56649f1b0506c6ca9fda0746eb0cacdf' | ||
*/ | ||
function rev(doc, deterministic_revs) { | ||
var clonedDoc = clone(doc); | ||
if (!deterministic_revs) { | ||
@@ -743,4 +745,5 @@ return uuid.v4().replace(/-/g, '').toLowerCase(); | ||
delete clonedDoc._rev_tree; | ||
return pouchdbMd5.stringMd5(JSON.stringify(clonedDoc)); | ||
var mutateableDoc = pouchdbUtils.assign({}, doc); | ||
delete mutateableDoc._rev_tree; | ||
return pouchdbMd5.stringMd5(JSON.stringify(mutateableDoc)); | ||
} | ||
@@ -747,0 +750,0 @@ |
{ | ||
"name": "pouchdb-utils", | ||
"version": "7.2.2", | ||
"version": "7.3.0", | ||
"description": "Unassorted utilities used by PouchDB.", | ||
@@ -9,3 +9,7 @@ "main": "./lib/index.js", | ||
"license": "Apache-2.0", | ||
"repository": "https://github.com/pouchdb/pouchdb", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pouchdb/pouchdb.git", | ||
"directory": "packages/node_modules/pouchdb-utils" | ||
}, | ||
"jsnext:main": "./lib/index.es.js", | ||
@@ -21,6 +25,6 @@ "browser": { | ||
"inherits": "2.0.4", | ||
"pouchdb-collections": "7.2.2", | ||
"pouchdb-errors": "7.2.2", | ||
"pouchdb-md5": "7.2.2", | ||
"uuid": "8.1.0" | ||
"pouchdb-collections": "7.3.0", | ||
"pouchdb-errors": "7.3.0", | ||
"pouchdb-md5": "7.3.0", | ||
"uuid": "8.3.2" | ||
}, | ||
@@ -27,0 +31,0 @@ "module": "./lib/index.es.js", |
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
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
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
95197
2686
0
5
+ Addedbuffer-from@1.1.2(transitive)
+ Addedpouchdb-binary-utils@7.3.0(transitive)
+ Addedpouchdb-collections@7.3.0(transitive)
+ Addedpouchdb-errors@7.3.0(transitive)
+ Addedpouchdb-md5@7.3.0(transitive)
+ Addedspark-md5@3.0.2(transitive)
+ Addeduuid@8.3.2(transitive)
- Removedbuffer-from@1.1.1(transitive)
- Removedpouchdb-binary-utils@7.2.2(transitive)
- Removedpouchdb-collections@7.2.2(transitive)
- Removedpouchdb-errors@7.2.2(transitive)
- Removedpouchdb-md5@7.2.2(transitive)
- Removedspark-md5@3.0.1(transitive)
- Removeduuid@8.1.0(transitive)
Updatedpouchdb-collections@7.3.0
Updatedpouchdb-errors@7.3.0
Updatedpouchdb-md5@7.3.0
Updateduuid@8.3.2