(#6386) - replace argsarray with custom impl
diff --git a/bin/build-pouchdb.js b/bin/build-pouchdb.js index 480d6d0..42e4632 100644 --- a/bin/build-pouchdb.js +++ b/bin/build-pouchdb.js
@@ -18,7 +18,6 @@ var rimraf = denodeify(require('rimraf')); var mkdirp = denodeify(require('mkdirp')); var all = Promise.all.bind(Promise); -var argsarray = require('argsarray'); var buildUtils = require('./build-utils'); var addPath = buildUtils.addPath; var doUglify = buildUtils.doUglify; @@ -169,7 +168,8 @@ }); } -var rimrafMkdirp = argsarray(function (args) { +var rimrafMkdirp = function () { + var args = Array.prototype.slice.apply(arguments); return all(args.map(function (otherPath) { return rimraf(addPath('pouchdb', otherPath)); })).then(function () { @@ -177,15 +177,16 @@ return mkdirp(addPath('pouchdb', otherPath)); })); }); -}); +}; -var doAll = argsarray(function (args) { +var doAll = function () { + var args = Array.prototype.slice.apply(arguments); return function () { return all(args.map(function (promiseFactory) { return promiseFactory(); })); }; -}); +}; function doBuildNode() { return mkdirp(addPath('pouchdb', 'lib/plugins'))
diff --git a/package.json b/package.json index 4585e84..b038c8c 100644 --- a/package.json +++ b/package.json
@@ -34,7 +34,6 @@ "test-webpack": "bash bin/test-webpack.sh" }, "dependencies": { - "argsarray": "0.0.1", "buffer-from": "0.1.1", "clone-buffer": "1.0.0", "debug": "2.6.1", @@ -58,7 +57,6 @@ "websql": "0.4.4" }, "devDependencies": { - "argsarray": "0.0.1", "body-parser": "1.17.1", "browserify": "14.1.0", "browserify-incremental": "3.1.1",
diff --git a/packages/node_modules/pouchdb-adapter-http/src/index.js b/packages/node_modules/pouchdb-adapter-http/src/index.js index 8411fec..97472f8 100644 --- a/packages/node_modules/pouchdb-adapter-http/src/index.js +++ b/packages/node_modules/pouchdb-adapter-http/src/index.js
@@ -3,9 +3,8 @@ var supportsBulkGetMap = {}; -import { nextTick } from 'pouchdb-utils'; +import { nextTick, argsarray } from 'pouchdb-utils'; import ajaxCore from 'pouchdb-ajax'; -import getArguments from 'argsarray'; import { pick, @@ -188,7 +187,7 @@ } function adapterFun(name, fun) { - return coreAdapterFun(name, getArguments(function (args) { + return coreAdapterFun(name, argsarray(function (args) { setup().then(function () { return fun.apply(this, args); }).catch(function (e) {
diff --git a/packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js b/packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js index b7abdad..cf95d5a 100644 --- a/packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js +++ b/packages/node_modules/pouchdb-adapter-leveldb-core/src/index.js
@@ -1,7 +1,6 @@ import levelup from 'levelup'; import sublevel from 'sublevel-pouchdb'; import { obj as through } from 'through2'; -import getArguments from 'argsarray'; import Deque from 'double-ended-queue'; import bufferFrom from 'buffer-from'; // ponyfill for Node <6 import { @@ -10,7 +9,8 @@ filterChange, functionName, uuid, - nextTick + nextTick, + argsarray } from 'pouchdb-utils'; import { isDeleted, @@ -289,7 +289,7 @@ readTasks.forEach(function (readTask) { var args = readTask.args; var callback = args[args.length - 1]; - args[args.length - 1] = getArguments(function (cbArgs) { + args[args.length - 1] = argsarray(function (cbArgs) { callback.apply(null, cbArgs); if (++numDone === readTasks.length) { nextTick(function () { @@ -310,7 +310,7 @@ function runWriteOperation(firstTask) { var args = firstTask.args; var callback = args[args.length - 1]; - args[args.length - 1] = getArguments(function (cbArgs) { + args[args.length - 1] = argsarray(function (cbArgs) { callback.apply(null, cbArgs); nextTick(function () { db._queue.shift(); @@ -327,7 +327,7 @@ // as e.g. compaction needing to have a lock on the database while // it updates stuff. in the future we can revisit this. function writeLock(fun) { - return getArguments(function (args) { + return argsarray(function (args) { db._queue.push({ fun: fun, args: args, @@ -342,7 +342,7 @@ // same as the writelock, but multiple can run at once function readLock(fun) { - return getArguments(function (args) { + return argsarray(function (args) { db._queue.push({ fun: fun, args: args,
diff --git a/packages/node_modules/pouchdb-core/src/changes.js b/packages/node_modules/pouchdb-core/src/changes.js index 3f131f4..bbb86e0 100644 --- a/packages/node_modules/pouchdb-core/src/changes.js +++ b/packages/node_modules/pouchdb-core/src/changes.js
@@ -1,11 +1,11 @@ -import getArguments from 'argsarray'; import { clone, listenerCount, once, parseDdocFunctionName, normalizeDdocFunctionName, - guardedConsole + guardedConsole, + argsarray } from 'pouchdb-utils'; import { isDeleted, @@ -213,7 +213,7 @@ /* istanbul ignore else */ if (newPromise && typeof newPromise.cancel === 'function') { var cancel = self.cancel; - self.cancel = getArguments(function (args) { + self.cancel = argsarray(function (args) { newPromise.cancel(); cancel.apply(this, args); });
diff --git a/packages/node_modules/pouchdb-mapreduce-utils/src/index.js b/packages/node_modules/pouchdb-mapreduce-utils/src/index.js index 9eb4efc..13796a4 100644 --- a/packages/node_modules/pouchdb-mapreduce-utils/src/index.js +++ b/packages/node_modules/pouchdb-mapreduce-utils/src/index.js
@@ -1,5 +1,4 @@ -import argsarray from 'argsarray'; -import { nextTick } from 'pouchdb-utils'; +import { nextTick, argsarray } from 'pouchdb-utils'; import { QueryParseError, NotFoundError,
diff --git a/packages/node_modules/pouchdb-utils/src/adapterFun.js b/packages/node_modules/pouchdb-utils/src/adapterFun.js index 27e474e..3b62fa5 100644 --- a/packages/node_modules/pouchdb-utils/src/adapterFun.js +++ b/packages/node_modules/pouchdb-utils/src/adapterFun.js
@@ -1,5 +1,5 @@ import toPromise from './toPromise'; -import getArguments from 'argsarray'; +import getArguments from './argsarray'; function logApiCall(self, name, args) { /* istanbul ignore if */
diff --git a/packages/node_modules/pouchdb-utils/src/argsarray.js b/packages/node_modules/pouchdb-utils/src/argsarray.js new file mode 100644 index 0000000..ef66858 --- /dev/null +++ b/packages/node_modules/pouchdb-utils/src/argsarray.js
@@ -0,0 +1,15 @@ +// based on https://unpkg.com/argsarray@0.0.1/index.js + +function argsarray(fun) { + return function argsarrayInner() { + var len = arguments.length; + var args = []; + var i = -1; + while (++i < len) { + args[i] = arguments[i]; + } + return fun.call(this, args); + }; +} + +export default argsarray; \ No newline at end of file
diff --git a/packages/node_modules/pouchdb-utils/src/index.js b/packages/node_modules/pouchdb-utils/src/index.js index 880bc24..2812e76 100644 --- a/packages/node_modules/pouchdb-utils/src/index.js +++ b/packages/node_modules/pouchdb-utils/src/index.js
@@ -1,4 +1,5 @@ import adapterFun from './adapterFun'; +import argsarray from './argsarray'; import bulkGetShim from './bulkGetShim'; import changesHandler from './changesHandler'; import clone from './clone'; @@ -27,6 +28,7 @@ export { adapterFun, + argsarray, bulkGetShim, changesHandler, clone,
diff --git a/packages/node_modules/pouchdb-utils/src/once.js b/packages/node_modules/pouchdb-utils/src/once.js index b2d9c5b..db82e41 100644 --- a/packages/node_modules/pouchdb-utils/src/once.js +++ b/packages/node_modules/pouchdb-utils/src/once.js
@@ -1,4 +1,4 @@ -import getArguments from 'argsarray'; +import getArguments from './argsarray'; function once(fun) { var called = false;
diff --git a/packages/node_modules/pouchdb-utils/src/toPromise.js b/packages/node_modules/pouchdb-utils/src/toPromise.js index 2646da1..2791ed1 100644 --- a/packages/node_modules/pouchdb-utils/src/toPromise.js +++ b/packages/node_modules/pouchdb-utils/src/toPromise.js
@@ -1,4 +1,4 @@ -import getArguments from 'argsarray'; +import getArguments from './argsarray'; import clone from './clone'; import once from './once';