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.1.2 to 6.2.0

118

lib/index-browser.es.js
import Promise from 'pouchdb-promise';
import getArguments from 'argsarray';
import debug from 'debug';
import { Map } from 'pouchdb-collections';
import { EventEmitter } from 'events';
import inherits from 'inherits';
import { nextTick } from 'pouchdb-utils';
import immediate from 'immediate';
import { BAD_REQUEST, INVALID_ID, MISSING_ID, RESERVED_ID, createError } from 'pouchdb-errors';
import immediate from 'immediate';

@@ -157,27 +155,25 @@ function isBinaryObject(object) {

var log = debug('pouchdb:api');
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (self.constructor.listeners('debug').length) {
var logArgs = ['api', self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
self.constructor.emit('debug', logArgs);
function adapterFun(name, callback) {
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (log.enabled) {
var logArgs = [self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
log.apply(null, logArgs);
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = [self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
log.apply(null, responseArgs);
origCallback(err, res);
};
}
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = ['api', self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
self.constructor.emit('debug', responseArgs);
origCallback(err, res);
};
}
}
function adapterFun(name, callback) {
return toPromise(getArguments(function (args) {

@@ -373,2 +369,14 @@ if (this._closed) {

// 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.
inherits(Changes, EventEmitter);

@@ -439,3 +447,3 @@

if (inprogress === 'waiting') {
nextTick(eventFunction);
immediate(eventFunction);
}

@@ -494,3 +502,3 @@ inprogress = false;

// In order to not exceed maxTimeout, pick a random value between half of maxTimeout and maxTimeout
if(max > maxTimeout) {
if (max > maxTimeout) {
min = maxTimeout >> 1; // divide by two

@@ -649,2 +657,27 @@ max = maxTimeout;

// 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.
function isRemote(db) {
if (typeof db._remote === 'boolean') {
return db._remote;
}
/* istanbul ignore next */
if (typeof db.type === 'function') {
guardedConsole('warn',
'db.type() is deprecated and will be removed in ' +
'a future version of PouchDB');
return db.type() === 'http';
}
/* istanbul ignore next */
return false;
}
function listenerCount(ee, type) {

@@ -655,14 +688,2 @@ return 'listenerCount' in ee ? ee.listenerCount(type) :

// 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.
function parseDesignDocFunctionName(s) {

@@ -721,2 +742,19 @@ if (!s) {

// Based on https://github.com/alexdavid/scope-eval v0.0.3
// (source: https://unpkg.com/scope-eval@0.0.3/scope_eval.js)
// This is basically just a wrapper around new Function()
function scopeEval(source, scope) {
var keys = [];
var values = [];
for (var key in scope) {
if (scope.hasOwnProperty(key)) {
keys.push(key);
values.push(scope[key]);
}
}
keys.push(source);
return Function.apply(null, keys).apply(null, values);
}
// this is essentially the "update sugar" function from daleharvey/pouchdb#1388

@@ -847,2 +885,2 @@ // the diffFun tells us what delta to apply to the doc. it either returns

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

@@ -9,9 +9,7 @@ 'use strict';

var getArguments = _interopDefault(require('argsarray'));
var debug = _interopDefault(require('debug'));
var pouchdbCollections = require('pouchdb-collections');
var events = require('events');
var inherits = _interopDefault(require('inherits'));
var pouchdbUtils = require('pouchdb-utils');
var immediate = _interopDefault(require('immediate'));
var pouchdbErrors = require('pouchdb-errors');
var immediate = _interopDefault(require('immediate'));

@@ -164,27 +162,25 @@ function isBinaryObject(object) {

var log = debug('pouchdb:api');
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (self.constructor.listeners('debug').length) {
var logArgs = ['api', self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
self.constructor.emit('debug', logArgs);
function adapterFun(name, callback) {
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (log.enabled) {
var logArgs = [self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
log.apply(null, logArgs);
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = [self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
log.apply(null, responseArgs);
origCallback(err, res);
};
}
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = ['api', self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
self.constructor.emit('debug', responseArgs);
origCallback(err, res);
};
}
}
function adapterFun(name, callback) {
return toPromise(getArguments(function (args) {

@@ -380,2 +376,14 @@ if (this._closed) {

// 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.
inherits(Changes, events.EventEmitter);

@@ -446,3 +454,3 @@

if (inprogress === 'waiting') {
pouchdbUtils.nextTick(eventFunction);
immediate(eventFunction);
}

@@ -501,3 +509,3 @@ inprogress = false;

// In order to not exceed maxTimeout, pick a random value between half of maxTimeout and maxTimeout
if(max > maxTimeout) {
if (max > maxTimeout) {
min = maxTimeout >> 1; // divide by two

@@ -656,2 +664,27 @@ max = maxTimeout;

// 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.
function isRemote(db) {
if (typeof db._remote === 'boolean') {
return db._remote;
}
/* istanbul ignore next */
if (typeof db.type === 'function') {
guardedConsole('warn',
'db.type() is deprecated and will be removed in ' +
'a future version of PouchDB');
return db.type() === 'http';
}
/* istanbul ignore next */
return false;
}
function listenerCount(ee, type) {

@@ -662,14 +695,2 @@ return 'listenerCount' in ee ? ee.listenerCount(type) :

// 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.
function parseDesignDocFunctionName(s) {

@@ -728,2 +749,19 @@ if (!s) {

// Based on https://github.com/alexdavid/scope-eval v0.0.3
// (source: https://unpkg.com/scope-eval@0.0.3/scope_eval.js)
// This is basically just a wrapper around new Function()
function scopeEval(source, scope) {
var keys = [];
var values = [];
for (var key in scope) {
if (scope.hasOwnProperty(key)) {
keys.push(key);
values.push(scope[key]);
}
}
keys.push(source);
return Function.apply(null, keys).apply(null, values);
}
// this is essentially the "update sugar" function from daleharvey/pouchdb#1388

@@ -869,2 +907,3 @@ // the diffFun tells us what delta to apply to the doc. it either returns

exports.isCordova = isCordova;
exports.isRemote = isRemote;
exports.listenerCount = listenerCount;

@@ -877,4 +916,5 @@ exports.nextTick = immediate;

exports.pick = pick;
exports.scopeEval = scopeEval;
exports.toPromise = toPromise;
exports.upsert = upsert;
exports.uuid = uuid;
import Promise from 'pouchdb-promise';
import getArguments from 'argsarray';
import cloneBuffer from 'clone-buffer';
import debug from 'debug';
import { Map } from 'pouchdb-collections';
import { EventEmitter } from 'events';
import inherits from 'inherits';
import { nextTick } from 'pouchdb-utils';
import { BAD_REQUEST, INVALID_ID, MISSING_ID, RESERVED_ID, createError } from 'pouchdb-errors';

@@ -130,27 +128,25 @@

var log = debug('pouchdb:api');
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (self.constructor.listeners('debug').length) {
var logArgs = ['api', self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
self.constructor.emit('debug', logArgs);
function adapterFun(name, callback) {
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (log.enabled) {
var logArgs = [self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
log.apply(null, logArgs);
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = [self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
log.apply(null, responseArgs);
origCallback(err, res);
};
}
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = ['api', self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
self.constructor.emit('debug', responseArgs);
origCallback(err, res);
};
}
}
function adapterFun(name, callback) {
return toPromise(getArguments(function (args) {

@@ -333,2 +329,6 @@ if (this._closed) {

function nextTick(fn) {
process.nextTick(fn);
}
inherits(Changes, EventEmitter);

@@ -453,3 +453,3 @@

// In order to not exceed maxTimeout, pick a random value between half of maxTimeout and maxTimeout
if(max > maxTimeout) {
if (max > maxTimeout) {
min = maxTimeout >> 1; // divide by two

@@ -605,2 +605,27 @@ max = maxTimeout;

// 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.
function isRemote(db) {
if (typeof db._remote === 'boolean') {
return db._remote;
}
/* istanbul ignore next */
if (typeof db.type === 'function') {
guardedConsole('warn',
'db.type() is deprecated and will be removed in ' +
'a future version of PouchDB');
return db.type() === 'http';
}
/* istanbul ignore next */
return false;
}
function listenerCount(ee, type) {

@@ -611,6 +636,2 @@ return 'listenerCount' in ee ? ee.listenerCount(type) :

function nextTick$1(fn) {
process.nextTick(fn);
}
function parseDesignDocFunctionName(s) {

@@ -669,2 +690,19 @@ if (!s) {

// Based on https://github.com/alexdavid/scope-eval v0.0.3
// (source: https://unpkg.com/scope-eval@0.0.3/scope_eval.js)
// This is basically just a wrapper around new Function()
function scopeEval(source, scope) {
var keys = [];
var values = [];
for (var key in scope) {
if (scope.hasOwnProperty(key)) {
keys.push(key);
values.push(scope[key]);
}
}
keys.push(source);
return Function.apply(null, keys).apply(null, values);
}
// this is essentially the "update sugar" function from daleharvey/pouchdb#1388

@@ -795,2 +833,2 @@ // the diffFun tells us what delta to apply to the doc. it either returns

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

@@ -10,7 +10,5 @@ 'use strict';

var cloneBuffer = _interopDefault(require('clone-buffer'));
var debug = _interopDefault(require('debug'));
var pouchdbCollections = require('pouchdb-collections');
var events = require('events');
var inherits = _interopDefault(require('inherits'));
var pouchdbUtils = require('pouchdb-utils');
var pouchdbErrors = require('pouchdb-errors');

@@ -137,27 +135,25 @@

var log = debug('pouchdb:api');
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (self.constructor.listeners('debug').length) {
var logArgs = ['api', self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
self.constructor.emit('debug', logArgs);
function adapterFun(name, callback) {
function logApiCall(self, name, args) {
/* istanbul ignore if */
if (log.enabled) {
var logArgs = [self.name, name];
for (var i = 0; i < args.length - 1; i++) {
logArgs.push(args[i]);
}
log.apply(null, logArgs);
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = [self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
log.apply(null, responseArgs);
origCallback(err, res);
};
}
// override the callback itself to log the response
var origCallback = args[args.length - 1];
args[args.length - 1] = function (err, res) {
var responseArgs = ['api', self.name, name];
responseArgs = responseArgs.concat(
err ? ['error', err] : ['success', res]
);
self.constructor.emit('debug', responseArgs);
origCallback(err, res);
};
}
}
function adapterFun(name, callback) {
return toPromise(getArguments(function (args) {

@@ -340,2 +336,6 @@ if (this._closed) {

function nextTick(fn) {
process.nextTick(fn);
}
inherits(Changes, events.EventEmitter);

@@ -406,3 +406,3 @@

if (inprogress === 'waiting') {
pouchdbUtils.nextTick(eventFunction);
nextTick(eventFunction);
}

@@ -461,3 +461,3 @@ inprogress = false;

// In order to not exceed maxTimeout, pick a random value between half of maxTimeout and maxTimeout
if(max > maxTimeout) {
if (max > maxTimeout) {
min = maxTimeout >> 1; // divide by two

@@ -613,2 +613,27 @@ max = maxTimeout;

// 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.
function isRemote(db) {
if (typeof db._remote === 'boolean') {
return db._remote;
}
/* istanbul ignore next */
if (typeof db.type === 'function') {
guardedConsole('warn',
'db.type() is deprecated and will be removed in ' +
'a future version of PouchDB');
return db.type() === 'http';
}
/* istanbul ignore next */
return false;
}
function listenerCount(ee, type) {

@@ -619,6 +644,2 @@ return 'listenerCount' in ee ? ee.listenerCount(type) :

function nextTick$1(fn) {
process.nextTick(fn);
}
function parseDesignDocFunctionName(s) {

@@ -677,2 +698,19 @@ if (!s) {

// Based on https://github.com/alexdavid/scope-eval v0.0.3
// (source: https://unpkg.com/scope-eval@0.0.3/scope_eval.js)
// This is basically just a wrapper around new Function()
function scopeEval(source, scope) {
var keys = [];
var values = [];
for (var key in scope) {
if (scope.hasOwnProperty(key)) {
keys.push(key);
values.push(scope[key]);
}
}
keys.push(source);
return Function.apply(null, keys).apply(null, values);
}
// this is essentially the "update sugar" function from daleharvey/pouchdb#1388

@@ -818,4 +856,5 @@ // the diffFun tells us what delta to apply to the doc. it either returns

exports.isCordova = isCordova;
exports.isRemote = isRemote;
exports.listenerCount = listenerCount;
exports.nextTick = nextTick$1;
exports.nextTick = nextTick;
exports.normalizeDdocFunctionName = normalizeDesignDocFunctionName;

@@ -826,4 +865,5 @@ exports.once = once;

exports.pick = pick;
exports.scopeEval = scopeEval;
exports.toPromise = toPromise;
exports.upsert = upsert;
exports.uuid = uuid;
{
"name": "pouchdb-utils",
"version": "6.1.2",
"version": "6.2.0",
"description": "Unassorted utilities used by PouchDB.",

@@ -18,8 +18,7 @@ "main": "./lib/index.js",

"clone-buffer": "1.0.0",
"debug": "2.6.0",
"immediate": "3.0.6",
"inherits": "2.0.3",
"pouchdb-collections": "6.1.2",
"pouchdb-errors": "6.1.2",
"pouchdb-promise": "6.1.2"
"pouchdb-collections": "6.2.0",
"pouchdb-errors": "6.2.0",
"pouchdb-promise": "6.2.0"
},

@@ -26,0 +25,0 @@ "files": [

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