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

pouchdb-utils

Package Overview
Dependencies
Maintainers
3
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.0.7 to 6.1.0

src/nextTick-browser.js

52

lib/index-browser.js

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

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');
var immediate = _interopDefault(require('immediate'));

@@ -128,15 +131,4 @@ function isBinaryObject(object) {

var self = this;
var tempCB =
(typeof args[args.length - 1] === 'function') ? args.pop() : false;
// if the last argument is a function, assume its a callback
var usedCB;
if (tempCB) {
// if it was a callback, create a new callback which calls it,
// but do so async so we don't trap any errors
usedCB = function (err, resp) {
process.nextTick(function () {
tempCB(err, resp);
});
};
}
var usedCB = (typeof args[args.length - 1] === 'function') ? args.pop() : false;
var promise = new Promise(function (fulfill, reject) {

@@ -254,12 +246,12 @@ var resp;

// consolidate into one request per doc if possible
var requestsById = {};
var requestsById = new pouchdbCollections.Map();
requests.forEach(function (request) {
if (request.id in requestsById) {
requestsById[request.id].push(request);
if (requestsById.has(request.id)) {
requestsById.get(request.id).push(request);
} else {
requestsById[request.id] = [request];
requestsById.set(request.id, [request]);
}
});
var numDocs = Object.keys(requestsById).length;
var numDocs = requestsById.size;
var numDone = 0;

@@ -292,3 +284,6 @@ var perDocResults = new Array(numDocs);

var allRequests = Object.keys(requestsById);
var allRequests = [];
requestsById.forEach(function (value, key) {
allRequests.push(key);
});

@@ -312,3 +307,3 @@ var i = 0;

var docIdx = offset + j;
var docRequests = requestsById[docId];
var docRequests = requestsById.get(docId);

@@ -342,3 +337,3 @@ // just use the first request as the "template"

// globally-supplied options
['revs', 'attachments', 'binary', 'ajax'].forEach(function (param) {
['revs', 'attachments', 'binary', 'ajax', 'latest'].forEach(function (param) {
if (param in opts) {

@@ -454,5 +449,3 @@ docOpts[param] = opts[param];

if (inprogress === 'waiting') {
setTimeout(function (){
eventFunction();
},0);
pouchdbUtils.nextTick(eventFunction);
}

@@ -689,2 +682,14 @@ inprogress = false;

// 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) {

@@ -885,2 +890,3 @@ if (!s) {

exports.listenerCount = listenerCount;
exports.nextTick = immediate;
exports.normalizeDdocFunctionName = normalizeDesignDocFunctionName;

@@ -887,0 +893,0 @@ exports.once = once;

@@ -9,5 +9,8 @@ 'use strict';

var getArguments = _interopDefault(require('argsarray'));
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');

@@ -19,8 +22,2 @@

function cloneBinaryObject(object) {
var copy = new Buffer(object.length);
object.copy(copy);
return copy;
}
// most of this is borrowed from lodash.isPlainObject:

@@ -68,3 +65,3 @@ // https://github.com/fis-components/lodash.isplainobject/

if (isBinaryObject(object)) {
return cloneBinaryObject(object);
return cloneBuffer(object);
}

@@ -109,15 +106,4 @@

var self = this;
var tempCB =
(typeof args[args.length - 1] === 'function') ? args.pop() : false;
// if the last argument is a function, assume its a callback
var usedCB;
if (tempCB) {
// if it was a callback, create a new callback which calls it,
// but do so async so we don't trap any errors
usedCB = function (err, resp) {
process.nextTick(function () {
tempCB(err, resp);
});
};
}
var usedCB = (typeof args[args.length - 1] === 'function') ? args.pop() : false;
var promise = new Promise(function (fulfill, reject) {

@@ -235,12 +221,12 @@ var resp;

// consolidate into one request per doc if possible
var requestsById = {};
var requestsById = new pouchdbCollections.Map();
requests.forEach(function (request) {
if (request.id in requestsById) {
requestsById[request.id].push(request);
if (requestsById.has(request.id)) {
requestsById.get(request.id).push(request);
} else {
requestsById[request.id] = [request];
requestsById.set(request.id, [request]);
}
});
var numDocs = Object.keys(requestsById).length;
var numDocs = requestsById.size;
var numDone = 0;

@@ -273,3 +259,6 @@ var perDocResults = new Array(numDocs);

var allRequests = Object.keys(requestsById);
var allRequests = [];
requestsById.forEach(function (value, key) {
allRequests.push(key);
});

@@ -293,3 +282,3 @@ var i = 0;

var docIdx = offset + j;
var docRequests = requestsById[docId];
var docRequests = requestsById.get(docId);

@@ -323,3 +312,3 @@ // just use the first request as the "template"

// globally-supplied options
['revs', 'attachments', 'binary', 'ajax'].forEach(function (param) {
['revs', 'attachments', 'binary', 'ajax', 'latest'].forEach(function (param) {
if (param in opts) {

@@ -422,5 +411,3 @@ docOpts[param] = opts[param];

if (inprogress === 'waiting') {
setTimeout(function (){
eventFunction();
},0);
pouchdbUtils.nextTick(eventFunction);
}

@@ -654,2 +641,6 @@ inprogress = false;

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

@@ -850,2 +841,3 @@ if (!s) {

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

@@ -852,0 +844,0 @@ exports.once = once;

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

@@ -21,11 +21,15 @@ "main": "./lib/index.js",

"./src/explainError.js": "./src/explainError-browser.js",
"./src/isBinaryObject.js": "./src/isBinaryObject-browser.js"
"./src/isBinaryObject.js": "./src/isBinaryObject-browser.js",
"./src/nextTick.js": "./src/nextTick-browser.js"
},
"dependencies": {
"argsarray": "0.0.1",
"debug": "2.2.0",
"clone-buffer": "1.0.0",
"debug": "2.3.2",
"immediate": "3.0.6",
"inherits": "2.0.3",
"pouchdb-errors": "6.0.7",
"pouchdb-promise": "6.0.7"
"pouchdb-collections": "6.1.0",
"pouchdb-errors": "6.1.0",
"pouchdb-promise": "6.1.0"
}
}
import pick from './pick';
import { Map } from 'pouchdb-collections';

@@ -23,12 +24,12 @@ // Most browsers throttle concurrent requests at 6, so it's silly

// consolidate into one request per doc if possible
var requestsById = {};
var requestsById = new Map();
requests.forEach(function (request) {
if (request.id in requestsById) {
requestsById[request.id].push(request);
if (requestsById.has(request.id)) {
requestsById.get(request.id).push(request);
} else {
requestsById[request.id] = [request];
requestsById.set(request.id, [request]);
}
});
var numDocs = Object.keys(requestsById).length;
var numDocs = requestsById.size;
var numDone = 0;

@@ -61,3 +62,6 @@ var perDocResults = new Array(numDocs);

var allRequests = Object.keys(requestsById);
var allRequests = [];
requestsById.forEach(function (value, key) {
allRequests.push(key);
});

@@ -81,3 +85,3 @@ var i = 0;

var docIdx = offset + j;
var docRequests = requestsById[docId];
var docRequests = requestsById.get(docId);

@@ -111,3 +115,3 @@ // just use the first request as the "template"

// globally-supplied options
['revs', 'attachments', 'binary', 'ajax'].forEach(function (param) {
['revs', 'attachments', 'binary', 'ajax', 'latest'].forEach(function (param) {
if (param in opts) {

@@ -114,0 +118,0 @@ docOpts[param] = opts[param];

@@ -6,2 +6,3 @@ import { EventEmitter as EventEmitter } from 'events';

import pick from './pick';
import { nextTick } from 'pouchdb-utils';

@@ -73,5 +74,3 @@ inherits(Changes, EventEmitter);

if (inprogress === 'waiting') {
setTimeout(function (){
eventFunction();
},0);
nextTick(eventFunction);
}

@@ -78,0 +77,0 @@ inprogress = false;

@@ -1,7 +0,2 @@

function cloneBinaryObject(object) {
var copy = new Buffer(object.length);
object.copy(copy);
return copy;
}
export default cloneBinaryObject;
import cloneBuffer from 'clone-buffer'; // correctly uses Buffer.from when available
export default cloneBuffer;

@@ -18,2 +18,3 @@ import adapterFun from './adapterFun';

import listenerCount from './listenerCount';
import nextTick from './nextTick';
import normalizeDdocFunctionName from './normalizeDdocFunctionName';

@@ -46,2 +47,3 @@ import once from './once';

listenerCount,
nextTick,
normalizeDdocFunctionName,

@@ -48,0 +50,0 @@ once,

@@ -12,15 +12,4 @@ import Promise from 'pouchdb-promise';

var self = this;
var tempCB =
(typeof args[args.length - 1] === 'function') ? args.pop() : false;
// if the last argument is a function, assume its a callback
var usedCB;
if (tempCB) {
// if it was a callback, create a new callback which calls it,
// but do so async so we don't trap any errors
usedCB = function (err, resp) {
process.nextTick(function () {
tempCB(err, resp);
});
};
}
var usedCB = (typeof args[args.length - 1] === 'function') ? args.pop() : false;
var promise = new Promise(function (fulfill, reject) {

@@ -27,0 +16,0 @@ var resp;

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