pouchdb-mapreduce-utils
Advanced tools
Comparing version 6.1.0 to 6.1.1
@@ -9,4 +9,5 @@ 'use strict'; | ||
var pouchdbUtils = require('pouchdb-utils'); | ||
var pouchdbCollections = require('pouchdb-collections'); | ||
var promisedCallback = function (promise, callback) { | ||
function promisedCallback(promise, callback) { | ||
if (callback) { | ||
@@ -24,5 +25,5 @@ promise.then(function (res) { | ||
return promise; | ||
}; | ||
} | ||
var callbackify = function (fun) { | ||
function callbackify(fun) { | ||
return argsarray(function (args) { | ||
@@ -36,6 +37,6 @@ var cb = args.pop(); | ||
}); | ||
}; | ||
} | ||
// Promise finally util similar to Q.finally | ||
var fin = function (promise, finalPromiseFactory) { | ||
function fin(promise, finalPromiseFactory) { | ||
return promise.then(function (res) { | ||
@@ -50,5 +51,5 @@ return finalPromiseFactory().then(function () { | ||
}); | ||
}; | ||
} | ||
var sequentialize = function (queue, promiseFactory) { | ||
function sequentialize(queue, promiseFactory) { | ||
return function () { | ||
@@ -61,22 +62,25 @@ var args = arguments; | ||
}; | ||
}; | ||
} | ||
// uniq an array of strings, order not guaranteed | ||
// similar to underscore/lodash _.uniq | ||
var uniq = function (arr) { | ||
var map = {}; | ||
function uniq(arr) { | ||
var theSet = new pouchdbCollections.Set(arr); | ||
var result = new Array(theSet.size); | ||
var index = -1; | ||
theSet.forEach(function (value) { | ||
result[++index] = value; | ||
}); | ||
return result; | ||
} | ||
for (var i = 0, len = arr.length; i < len; i++) { | ||
map['$' + arr[i]] = true; | ||
} | ||
function mapToKeysArray(map) { | ||
var result = new Array(map.size); | ||
var index = -1; | ||
map.forEach(function (value, key) { | ||
result[++index] = key; | ||
}); | ||
return result; | ||
} | ||
var keys = Object.keys(map); | ||
var output = new Array(keys.length); | ||
for (i = 0, len = keys.length; i < len; i++) { | ||
output[i] = keys[i].substring(1); | ||
} | ||
return output; | ||
}; | ||
exports.uniq = uniq; | ||
@@ -86,2 +90,3 @@ exports.sequentialize = sequentialize; | ||
exports.callbackify = callbackify; | ||
exports.promisedCallback = promisedCallback; | ||
exports.promisedCallback = promisedCallback; | ||
exports.mapToKeysArray = mapToKeysArray; |
{ | ||
"name": "pouchdb-mapreduce-utils", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"description": "PouchDB utilities used by pouchdb-mapreduce.", | ||
@@ -17,4 +17,5 @@ "main": "./lib/index.js", | ||
"argsarray": "0.0.1", | ||
"pouchdb-utils": "6.1.0" | ||
"pouchdb-collections": "6.1.1", | ||
"pouchdb-utils": "6.1.1" | ||
} | ||
} |
import argsarray from 'argsarray'; | ||
import { nextTick } from 'pouchdb-utils'; | ||
import { Set } from 'pouchdb-collections'; | ||
var promisedCallback = function (promise, callback) { | ||
function promisedCallback(promise, callback) { | ||
if (callback) { | ||
@@ -17,5 +18,5 @@ promise.then(function (res) { | ||
return promise; | ||
}; | ||
} | ||
var callbackify = function (fun) { | ||
function callbackify(fun) { | ||
return argsarray(function (args) { | ||
@@ -29,6 +30,6 @@ var cb = args.pop(); | ||
}); | ||
}; | ||
} | ||
// Promise finally util similar to Q.finally | ||
var fin = function (promise, finalPromiseFactory) { | ||
function fin(promise, finalPromiseFactory) { | ||
return promise.then(function (res) { | ||
@@ -43,5 +44,5 @@ return finalPromiseFactory().then(function () { | ||
}); | ||
}; | ||
} | ||
var sequentialize = function (queue, promiseFactory) { | ||
function sequentialize(queue, promiseFactory) { | ||
return function () { | ||
@@ -54,22 +55,25 @@ var args = arguments; | ||
}; | ||
}; | ||
} | ||
// uniq an array of strings, order not guaranteed | ||
// similar to underscore/lodash _.uniq | ||
var uniq = function (arr) { | ||
var map = {}; | ||
function uniq(arr) { | ||
var theSet = new Set(arr); | ||
var result = new Array(theSet.size); | ||
var index = -1; | ||
theSet.forEach(function (value) { | ||
result[++index] = value; | ||
}); | ||
return result; | ||
} | ||
for (var i = 0, len = arr.length; i < len; i++) { | ||
map['$' + arr[i]] = true; | ||
} | ||
function mapToKeysArray(map) { | ||
var result = new Array(map.size); | ||
var index = -1; | ||
map.forEach(function (value, key) { | ||
result[++index] = key; | ||
}); | ||
return result; | ||
} | ||
var keys = Object.keys(map); | ||
var output = new Array(keys.length); | ||
for (i = 0, len = keys.length; i < len; i++) { | ||
output[i] = keys[i].substring(1); | ||
} | ||
return output; | ||
}; | ||
export { | ||
@@ -80,3 +84,4 @@ uniq, | ||
callbackify, | ||
promisedCallback | ||
promisedCallback, | ||
mapToKeysArray | ||
}; |
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
16185
150
3
1
+ Addedpouchdb-collections@6.1.1
+ Addeddebug@2.6.0(transitive)
+ Addedpouchdb-collections@6.1.1(transitive)
+ Addedpouchdb-errors@6.1.1(transitive)
+ Addedpouchdb-promise@6.1.1(transitive)
+ Addedpouchdb-utils@6.1.1(transitive)
- Removeddebug@2.3.2(transitive)
- Removedpouchdb-collections@6.1.0(transitive)
- Removedpouchdb-errors@6.1.0(transitive)
- Removedpouchdb-promise@6.1.0(transitive)
- Removedpouchdb-utils@6.1.0(transitive)
Updatedpouchdb-utils@6.1.1