Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pouchdb-utils

Package Overview
Dependencies
Maintainers
5
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pouchdb-utils - npm Package Compare versions

Comparing version 6.4.3 to 7.0.0

99

lib/index-browser.es.js
import getArguments from 'argsarray';
import Promise from 'pouchdb-promise';
import { Map } from 'pouchdb-collections';

@@ -9,2 +8,4 @@ import immediate from 'immediate';

import uuidV4 from 'uuid';
import { stringMd5 } from 'pouchdb-md5';
import { clone } from 'pouchdb-utils';

@@ -60,3 +61,3 @@ function isBinaryObject(object) {

function clone(object) {
function clone$1(object) {
var newObject;

@@ -73,3 +74,3 @@ var i;

for (i = 0, len = object.length; i < len; i++) {
newObject[i] = clone(object[i]);
newObject[i] = clone$1(object[i]);
}

@@ -97,3 +98,3 @@ return newObject;

if (Object.prototype.hasOwnProperty.call(object, i)) {
var value = clone(object[i]);
var value = clone$1(object[i]);
if (typeof value !== 'undefined') {

@@ -125,3 +126,3 @@ newObject[i] = value;

// Clone arguments
args = clone(args);
args = clone$1(args);
var self = this;

@@ -351,19 +352,9 @@ // if the last argument is a function, assume its a callback

function isChromeApp() {
return (typeof chrome !== "undefined" &&
typeof chrome.storage !== "undefined" &&
typeof chrome.storage.local !== "undefined");
}
var hasLocal;
if (isChromeApp()) {
try {
localStorage.setItem('_pouch_check_localstorage', 1);
hasLocal = !!localStorage.getItem('_pouch_check_localstorage');
} catch (e) {
hasLocal = false;
} else {
try {
localStorage.setItem('_pouch_check_localstorage', 1);
hasLocal = !!localStorage.getItem('_pouch_check_localstorage');
} catch (e) {
hasLocal = false;
}
}

@@ -376,12 +367,2 @@

// Custom nextTick() shim for browsers. In node, this will just be process.nextTick(). We
// avoid using process.nextTick() directly because the polyfill is very large and we don't
// need all of it (see: https://github.com/defunctzombie/node-process).
// "immediate" 3.0.8 is used by lie, and it's a smaller version of the latest "immediate"
// package, so it's the one we use.
// When we use nextTick() in our codebase, we only care about not releasing Zalgo
// (see: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony).
// Microtask vs macrotask doesn't matter to us. So we're free to use the fastest
// (least latency) option, which is "immediate" due to use of microtasks.
// All of our nextTicks are isolated to this one function so we can easily swap out one
// implementation for another.

@@ -392,20 +373,6 @@ inherits(Changes, EventEmitter);

function attachBrowserEvents(self) {
if (isChromeApp()) {
chrome.storage.onChanged.addListener(function (e) {
// make sure it's event addressed to us
if (e.db_name != null) {
//object only has oldValue, newValue members
self.emit(e.dbName.newValue);
}
if (hasLocalStorage()) {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else if (hasLocalStorage()) {
if (typeof addEventListener !== 'undefined') {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else { // old IE
window.attachEvent("storage", function (e) {
self.emit(e.key);
});
}
}

@@ -439,3 +406,3 @@ }

'style', 'include_docs', 'attachments', 'conflicts', 'filter',
'doc_ids', 'view', 'since', 'query_params', 'binary'
'doc_ids', 'view', 'since', 'query_params', 'binary', 'return_docs'
]);

@@ -479,5 +446,3 @@

//in order to get other windows's listeners to activate
if (isChromeApp()) {
chrome.storage.local.set({dbName: dbName});
} else if (hasLocalStorage()) {
if (hasLocalStorage()) {
localStorage[dbName] = (localStorage[dbName] === "a") ? "b" : "a";

@@ -633,3 +598,9 @@ }

res = function (fun) {
return fun.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
var match = fun.toString().match(/^\s*function\s*(?:(\S+)\s*)?\(/);
if (match && match[1]) {
return match[1];
}
else {
return '';
}
};

@@ -659,17 +630,3 @@ }

function isCordova() {
return (typeof cordova !== "undefined" ||
typeof PhoneGap !== "undefined" ||
typeof phonegap !== "undefined");
}
// Checks if a PouchDB object is "remote" or not. This is
// designed to opt-in to certain optimizations, such as
// avoiding checks for "dependentDbs" and other things that
// we know only apply to local databases. In general, "remote"
// should be true for the http adapter, and for third-party
// adapters with similar expensive boundaries to cross for
// every API call, such as socket-pouch and worker-pouch.
// Previously, this was handled via db.type() === 'http'
// which is now deprecated.

@@ -814,4 +771,10 @@ function isRemote(db) {

function rev() {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
function rev(doc, deterministic_revs) {
var clonedDoc = clone(doc);
if (!deterministic_revs) {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
}
delete clonedDoc._rev_tree;
return stringMd5(JSON.stringify(clonedDoc));
}

@@ -821,2 +784,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, isChromeApp, isCordova, isRemote, listenerCount, immediate as nextTick, normalizeDesignDocFunctionName as normalizeDdocFunctionName, once, parseDesignDocFunctionName as parseDdocFunctionName, parseUri, pick, rev, scopeEval, toPromise, upsert, uuid };
export { adapterFun, assign$1 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone$1 as 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 };

@@ -8,3 +8,2 @@ 'use strict';

var getArguments = _interopDefault(require('argsarray'));
var Promise = _interopDefault(require('pouchdb-promise'));
var pouchdbCollections = require('pouchdb-collections');

@@ -16,2 +15,4 @@ var immediate = _interopDefault(require('immediate'));

var uuidV4 = _interopDefault(require('uuid'));
var pouchdbMd5 = require('pouchdb-md5');
var pouchdbUtils = require('pouchdb-utils');

@@ -354,19 +355,9 @@ function isBinaryObject(object) {

function isChromeApp() {
return (typeof chrome !== "undefined" &&
typeof chrome.storage !== "undefined" &&
typeof chrome.storage.local !== "undefined");
}
var hasLocal;
if (isChromeApp()) {
try {
localStorage.setItem('_pouch_check_localstorage', 1);
hasLocal = !!localStorage.getItem('_pouch_check_localstorage');
} catch (e) {
hasLocal = false;
} else {
try {
localStorage.setItem('_pouch_check_localstorage', 1);
hasLocal = !!localStorage.getItem('_pouch_check_localstorage');
} catch (e) {
hasLocal = false;
}
}

@@ -379,12 +370,2 @@

// Custom nextTick() shim for browsers. In node, this will just be process.nextTick(). We
// avoid using process.nextTick() directly because the polyfill is very large and we don't
// need all of it (see: https://github.com/defunctzombie/node-process).
// "immediate" 3.0.8 is used by lie, and it's a smaller version of the latest "immediate"
// package, so it's the one we use.
// When we use nextTick() in our codebase, we only care about not releasing Zalgo
// (see: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony).
// Microtask vs macrotask doesn't matter to us. So we're free to use the fastest
// (least latency) option, which is "immediate" due to use of microtasks.
// All of our nextTicks are isolated to this one function so we can easily swap out one
// implementation for another.

@@ -395,20 +376,6 @@ inherits(Changes, events.EventEmitter);

function attachBrowserEvents(self) {
if (isChromeApp()) {
chrome.storage.onChanged.addListener(function (e) {
// make sure it's event addressed to us
if (e.db_name != null) {
//object only has oldValue, newValue members
self.emit(e.dbName.newValue);
}
if (hasLocalStorage()) {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else if (hasLocalStorage()) {
if (typeof addEventListener !== 'undefined') {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else { // old IE
window.attachEvent("storage", function (e) {
self.emit(e.key);
});
}
}

@@ -442,3 +409,3 @@ }

'style', 'include_docs', 'attachments', 'conflicts', 'filter',
'doc_ids', 'view', 'since', 'query_params', 'binary'
'doc_ids', 'view', 'since', 'query_params', 'binary', 'return_docs'
]);

@@ -482,5 +449,3 @@

//in order to get other windows's listeners to activate
if (isChromeApp()) {
chrome.storage.local.set({dbName: dbName});
} else if (hasLocalStorage()) {
if (hasLocalStorage()) {
localStorage[dbName] = (localStorage[dbName] === "a") ? "b" : "a";

@@ -636,3 +601,9 @@ }

res = function (fun) {
return fun.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
var match = fun.toString().match(/^\s*function\s*(?:(\S+)\s*)?\(/);
if (match && match[1]) {
return match[1];
}
else {
return '';
}
};

@@ -662,17 +633,3 @@ }

function isCordova() {
return (typeof cordova !== "undefined" ||
typeof PhoneGap !== "undefined" ||
typeof phonegap !== "undefined");
}
// Checks if a PouchDB object is "remote" or not. This is
// designed to opt-in to certain optimizations, such as
// avoiding checks for "dependentDbs" and other things that
// we know only apply to local databases. In general, "remote"
// should be true for the http adapter, and for third-party
// adapters with similar expensive boundaries to cross for
// every API call, such as socket-pouch and worker-pouch.
// Previously, this was handled via db.type() === 'http'
// which is now deprecated.

@@ -817,4 +774,10 @@ function isRemote(db) {

function rev() {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
function rev(doc, deterministic_revs) {
var clonedDoc = pouchdbUtils.clone(doc);
if (!deterministic_revs) {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
}
delete clonedDoc._rev_tree;
return pouchdbMd5.stringMd5(JSON.stringify(clonedDoc));
}

@@ -837,4 +800,2 @@

exports.invalidIdError = invalidIdError;
exports.isChromeApp = isChromeApp;
exports.isCordova = isCordova;
exports.isRemote = isRemote;

@@ -841,0 +802,0 @@ exports.listenerCount = listenerCount;

import cloneBuffer from 'clone-buffer';
import getArguments from 'argsarray';
import Promise from 'pouchdb-promise';
import { Map } from 'pouchdb-collections';

@@ -9,2 +8,4 @@ import { EventEmitter } from 'events';

import uuidV4 from 'uuid';
import { stringMd5 } from 'pouchdb-md5';
import { clone } from 'pouchdb-utils';

@@ -33,3 +34,3 @@ function isBinaryObject(object) {

function clone(object) {
function clone$1(object) {
var newObject;

@@ -46,3 +47,3 @@ var i;

for (i = 0, len = object.length; i < len; i++) {
newObject[i] = clone(object[i]);
newObject[i] = clone$1(object[i]);
}

@@ -70,3 +71,3 @@ return newObject;

if (Object.prototype.hasOwnProperty.call(object, i)) {
var value = clone(object[i]);
var value = clone$1(object[i]);
if (typeof value !== 'undefined') {

@@ -98,3 +99,3 @@ newObject[i] = value;

// Clone arguments
args = clone(args);
args = clone$1(args);
var self = this;

@@ -325,7 +326,2 @@ // if the last argument is a function, assume its a callback

// in Node of course this is false
function isChromeApp() {
return false;
}
// in Node of course this is false
function hasLocalStorage() {

@@ -343,20 +339,6 @@ return false;

function attachBrowserEvents(self) {
if (isChromeApp()) {
chrome.storage.onChanged.addListener(function (e) {
// make sure it's event addressed to us
if (e.db_name != null) {
//object only has oldValue, newValue members
self.emit(e.dbName.newValue);
}
if (hasLocalStorage()) {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else if (hasLocalStorage()) {
if (typeof addEventListener !== 'undefined') {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else { // old IE
window.attachEvent("storage", function (e) {
self.emit(e.key);
});
}
}

@@ -390,3 +372,3 @@ }

'style', 'include_docs', 'attachments', 'conflicts', 'filter',
'doc_ids', 'view', 'since', 'query_params', 'binary'
'doc_ids', 'view', 'since', 'query_params', 'binary', 'return_docs'
]);

@@ -430,5 +412,3 @@

//in order to get other windows's listeners to activate
if (isChromeApp()) {
chrome.storage.local.set({dbName: dbName});
} else if (hasLocalStorage()) {
if (hasLocalStorage()) {
localStorage[dbName] = (localStorage[dbName] === "a") ? "b" : "a";

@@ -571,3 +551,3 @@ }

var hasName = f.name;
var res$2;
var res$1;

@@ -577,12 +557,18 @@ // We dont run coverage in IE

if (hasName) {
res$2 = function (fun) {
res$1 = function (fun) {
return fun.name;
};
} else {
res$2 = function (fun) {
return fun.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
res$1 = function (fun) {
var match = fun.toString().match(/^\s*function\s*(?:(\S+)\s*)?\(/);
if (match && match[1]) {
return match[1];
}
else {
return '';
}
};
}
var res$3 = res$2;
var res$2 = res$1;

@@ -608,17 +594,3 @@ // Determine id an ID is valid

function isCordova() {
return (typeof cordova !== "undefined" ||
typeof PhoneGap !== "undefined" ||
typeof phonegap !== "undefined");
}
// Checks if a PouchDB object is "remote" or not. This is
// designed to opt-in to certain optimizations, such as
// avoiding checks for "dependentDbs" and other things that
// we know only apply to local databases. In general, "remote"
// should be true for the http adapter, and for third-party
// adapters with similar expensive boundaries to cross for
// every API call, such as socket-pouch and worker-pouch.
// Previously, this was handled via db.type() === 'http'
// which is now deprecated.

@@ -763,4 +735,10 @@ function isRemote(db) {

function rev() {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
function rev(doc, deterministic_revs) {
var clonedDoc = clone(doc);
if (!deterministic_revs) {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
}
delete clonedDoc._rev_tree;
return stringMd5(JSON.stringify(clonedDoc));
}

@@ -770,2 +748,2 @@

export { adapterFun, assign$1 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone, defaultBackOff, res as explainError, filterChange, flatten, res$3 as functionName, guardedConsole, hasLocalStorage, invalidIdError, isChromeApp, isCordova, isRemote, listenerCount, nextTick, normalizeDesignDocFunctionName as normalizeDdocFunctionName, once, parseDesignDocFunctionName as parseDdocFunctionName, parseUri, pick, rev, scopeEval, toPromise, upsert, uuid };
export { adapterFun, assign$1 as assign, bulkGet as bulkGetShim, Changes as changesHandler, clone$1 as 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 };

@@ -9,3 +9,2 @@ 'use strict';

var getArguments = _interopDefault(require('argsarray'));
var Promise = _interopDefault(require('pouchdb-promise'));
var pouchdbCollections = require('pouchdb-collections');

@@ -16,2 +15,4 @@ var events = require('events');

var uuidV4 = _interopDefault(require('uuid'));
var pouchdbMd5 = require('pouchdb-md5');
var pouchdbUtils = require('pouchdb-utils');

@@ -328,7 +329,2 @@ function isBinaryObject(object) {

// in Node of course this is false
function isChromeApp() {
return false;
}
// in Node of course this is false
function hasLocalStorage() {

@@ -346,20 +342,6 @@ return false;

function attachBrowserEvents(self) {
if (isChromeApp()) {
chrome.storage.onChanged.addListener(function (e) {
// make sure it's event addressed to us
if (e.db_name != null) {
//object only has oldValue, newValue members
self.emit(e.dbName.newValue);
}
if (hasLocalStorage()) {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else if (hasLocalStorage()) {
if (typeof addEventListener !== 'undefined') {
addEventListener("storage", function (e) {
self.emit(e.key);
});
} else { // old IE
window.attachEvent("storage", function (e) {
self.emit(e.key);
});
}
}

@@ -393,3 +375,3 @@ }

'style', 'include_docs', 'attachments', 'conflicts', 'filter',
'doc_ids', 'view', 'since', 'query_params', 'binary'
'doc_ids', 'view', 'since', 'query_params', 'binary', 'return_docs'
]);

@@ -433,5 +415,3 @@

//in order to get other windows's listeners to activate
if (isChromeApp()) {
chrome.storage.local.set({dbName: dbName});
} else if (hasLocalStorage()) {
if (hasLocalStorage()) {
localStorage[dbName] = (localStorage[dbName] === "a") ? "b" : "a";

@@ -574,3 +554,3 @@ }

var hasName = f.name;
var res$2;
var res$1;

@@ -580,12 +560,18 @@ // We dont run coverage in IE

if (hasName) {
res$2 = function (fun) {
res$1 = function (fun) {
return fun.name;
};
} else {
res$2 = function (fun) {
return fun.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];
res$1 = function (fun) {
var match = fun.toString().match(/^\s*function\s*(?:(\S+)\s*)?\(/);
if (match && match[1]) {
return match[1];
}
else {
return '';
}
};
}
var res$3 = res$2;
var res$2 = res$1;

@@ -611,17 +597,3 @@ // Determine id an ID is valid

function isCordova() {
return (typeof cordova !== "undefined" ||
typeof PhoneGap !== "undefined" ||
typeof phonegap !== "undefined");
}
// Checks if a PouchDB object is "remote" or not. This is
// designed to opt-in to certain optimizations, such as
// avoiding checks for "dependentDbs" and other things that
// we know only apply to local databases. In general, "remote"
// should be true for the http adapter, and for third-party
// adapters with similar expensive boundaries to cross for
// every API call, such as socket-pouch and worker-pouch.
// Previously, this was handled via db.type() === 'http'
// which is now deprecated.

@@ -766,4 +738,10 @@ function isRemote(db) {

function rev() {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
function rev(doc, deterministic_revs) {
var clonedDoc = pouchdbUtils.clone(doc);
if (!deterministic_revs) {
return uuidV4.v4().replace(/-/g, '').toLowerCase();
}
delete clonedDoc._rev_tree;
return pouchdbMd5.stringMd5(JSON.stringify(clonedDoc));
}

@@ -782,8 +760,6 @@

exports.flatten = flatten;
exports.functionName = res$3;
exports.functionName = res$2;
exports.guardedConsole = guardedConsole;
exports.hasLocalStorage = hasLocalStorage;
exports.invalidIdError = invalidIdError;
exports.isChromeApp = isChromeApp;
exports.isCordova = isCordova;
exports.isRemote = isRemote;

@@ -790,0 +766,0 @@ exports.listenerCount = listenerCount;

{
"name": "pouchdb-utils",
"version": "6.4.3",
"version": "7.0.0",
"description": "Unassorted utilities used by PouchDB.",

@@ -20,5 +20,5 @@ "main": "./lib/index.js",

"inherits": "2.0.3",
"pouchdb-collections": "6.4.3",
"pouchdb-errors": "6.4.3",
"pouchdb-promise": "6.4.3",
"pouchdb-collections": "7.0.0",
"pouchdb-errors": "7.0.0",
"pouchdb-md5": "7.0.0",
"uuid": "3.2.1"

@@ -25,0 +25,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc