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

async-deco

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-deco - npm Package Compare versions

Comparing version 8.3.0 to 8.4.0

.eslintrc.js

10

callback/atomic.js

@@ -1,8 +0,8 @@

var _atomic = require('../src/atomic');
var wrapper = require('../src/noop');
var _atomic = require('../src/atomic')
var wrapper = require('../src/callback-translator')
function atomic(opts) {
return _atomic(wrapper, opts);
function atomic (opts) {
return _atomic(wrapper, opts)
}
module.exports = atomic;
module.exports = atomic

@@ -1,8 +0,8 @@

var _balance = require('../src/balance');
var wrapper = require('../src/noop');
var _balance = require('../src/balance')
var wrapper = require('../src/callback-translator')
function balance(policy) {
return _balance(wrapper, policy);
function balance (policy) {
return _balance(wrapper, policy)
}
module.exports = balance;
module.exports = balance

@@ -1,8 +0,8 @@

var _cache = require('../src/cache');
var wrapper = require('../src/noop');
var _cache = require('../src/cache')
var wrapper = require('../src/callback-translator')
function cache(cache, opts) {
return _cache(wrapper, cache, opts);
function cache (cache, opts) {
return _cache(wrapper, cache, opts)
}
module.exports = cache;
module.exports = cache

@@ -1,8 +0,8 @@

var _debounce = require('../src/debounce').debounce;
var wrapper = require('../src/noop');
var _debounce = require('../src/debounce').debounce
var wrapper = require('../src/callback-translator')
function debounce(wait, debounceOpts, getKey, cacheOpts) {
return _debounce(wrapper, wait, debounceOpts, getKey, cacheOpts);
function debounce (wait, debounceOpts, getKey, cacheOpts) {
return _debounce(wrapper, wait, debounceOpts, getKey, cacheOpts)
}
module.exports = debounce;
module.exports = debounce

@@ -1,8 +0,8 @@

var _dedupe = require('../src/dedupe');
var wrapper = require('../src/noop');
var _dedupe = require('../src/dedupe')
var wrapper = require('../src/callback-translator')
function dedupe(opts) {
return _dedupe(wrapper, opts);
function dedupe (opts) {
return _dedupe(wrapper, opts)
}
module.exports = dedupe;
module.exports = dedupe

@@ -1,8 +0,8 @@

var _fallbackCache = require('../src/fallback-cache');
var wrapper = require('../src/noop');
var _fallbackCache = require('../src/fallback-cache')
var wrapper = require('../src/callback-translator')
function fallbackCache(cache, opts) {
return _fallbackCache(wrapper, cache, opts);
function fallbackCache (cache, opts) {
return _fallbackCache(wrapper, cache, opts)
}
module.exports = fallbackCache;
module.exports = fallbackCache

@@ -1,8 +0,8 @@

var _fallbackValue = require('../src/fallback-value');
var wrapper = require('../src/noop');
var _fallbackValue = require('../src/fallback-value')
var wrapper = require('../src/callback-translator')
function fallbackValue(value, error) {
return _fallbackValue(wrapper, value, error);
function fallbackValue (value, error) {
return _fallbackValue(wrapper, value, error)
}
module.exports = fallbackValue;
module.exports = fallbackValue

@@ -1,8 +0,8 @@

var _fallback = require('../src/fallback');
var wrapper = require('../src/noop');
var _fallback = require('../src/fallback')
var wrapper = require('../src/callback-translator')
function fallback(fallbackFunction, error) {
return _fallback(wrapper, fallbackFunction, error);
function fallback (fallbackFunction, error) {
return _fallback(wrapper, fallbackFunction, error)
}
module.exports = fallback;
module.exports = fallback

@@ -1,8 +0,8 @@

var _limit = require('../src/limit');
var wrapper = require('../src/noop');
var _limit = require('../src/limit')
var wrapper = require('../src/callback-translator')
function limit(max, getKey, getPriority) {
return _limit(wrapper, max, getKey, getPriority);
function limit (max, getKey, getPriority) {
return _limit(wrapper, max, getKey, getPriority)
}
module.exports = limit;
module.exports = limit

@@ -1,8 +0,8 @@

var _log = require('../src/log');
var wrapper = require('../src/noop');
var _log = require('../src/log')
var wrapper = require('../src/callback-translator')
function log(prefix) {
return _log(wrapper, prefix);
function log (prefix) {
return _log(wrapper, prefix)
}
module.exports = log;
module.exports = log

@@ -1,8 +0,8 @@

var _memoize = require('../src/memoize');
var wrapper = require('../src/noop');
var _memoize = require('../src/memoize')
var wrapper = require('../src/callback-translator')
function memoize(getKey) {
return _memoize(wrapper, getKey);
function memoize (getKey) {
return _memoize(wrapper, getKey)
}
module.exports = memoize;
module.exports = memoize

@@ -1,2 +0,4 @@

var _parallel = require('../src/parallel');
module.exports = _parallel;
var _parallel = require('../src/parallel')
var wrapper = require('../src/callback-translator')
module.exports = wrapper(_parallel)

@@ -1,8 +0,8 @@

var _proxy = require('../src/proxy');
var wrapper = require('../src/noop');
var _proxy = require('../src/proxy')
var wrapper = require('../src/callback-translator')
function proxy(guard) {
return _proxy(wrapper, guard);
function proxy (guard) {
return _proxy(wrapper, guard)
}
module.exports = proxy;
module.exports = proxy

@@ -1,8 +0,8 @@

var _purgeCache = require('../src/purge-cache');
var wrapper = require('../src/noop');
var _purgeCache = require('../src/purge-cache')
var wrapper = require('../src/callback-translator')
function purgeCache(cache, opts) {
return _purgeCache(wrapper, cache, opts);
function purgeCache (cache, opts) {
return _purgeCache(wrapper, cache, opts)
}
module.exports = purgeCache;
module.exports = purgeCache

@@ -1,2 +0,4 @@

var _race = require('../src/race');
module.exports = _race;
var _race = require('../src/race')
var wrapper = require('../src/callback-translator')
module.exports = wrapper(_race)

@@ -1,8 +0,8 @@

var _retry = require('../src/retry');
var wrapper = require('../src/noop');
var _retry = require('../src/retry')
var wrapper = require('../src/callback-translator')
function retry(times, interval, error) {
return _retry(wrapper, times, interval, error);
function retry (times, interval, error) {
return _retry(wrapper, times, interval, error)
}
module.exports = retry;
module.exports = retry

@@ -1,8 +0,8 @@

var _throttle = require('../src/debounce').throttle;
var wrapper = require('../src/noop');
var _throttle = require('../src/debounce').throttle
var wrapper = require('../src/callback-translator')
function throttle(wait, throttleOpts, getKey, cacheOpts) {
return _throttle(wrapper, wait, throttleOpts, getKey, cacheOpts);
function throttle (wait, throttleOpts, getKey, cacheOpts) {
return _throttle(wrapper, wait, throttleOpts, getKey, cacheOpts)
}
module.exports = throttle;
module.exports = throttle

@@ -1,8 +0,8 @@

var _timeout = require('../src/timeout');
var wrapper = require('../src/noop');
var _timeout = require('../src/timeout')
var wrapper = require('../src/callback-translator')
function timeout(ms) {
return _timeout(wrapper, ms);
function timeout (ms) {
return _timeout(wrapper, ms)
}
module.exports = timeout;
module.exports = timeout

@@ -1,9 +0,9 @@

var _validator = require('../src/validator');
var wrapper = require('../src/noop');
var _validator = require('../src/validator')
var wrapper = require('../src/callback-translator')
function validator() {
var args = Array.prototype.slice.call(arguments, 0);
return _validator(wrapper, args);
function validator () {
var args = Array.prototype.slice.call(arguments, 0)
return _validator(wrapper, args)
}
module.exports = validator;
module.exports = validator

@@ -1,2 +0,4 @@

var _waterfall = require('../src/waterfall');
module.exports = _waterfall;
var _waterfall = require('../src/waterfall')
var wrapper = require('../src/callback-translator')
module.exports = wrapper(_waterfall)

@@ -1,10 +0,10 @@

function LimitError(message) {
this.name = 'LimitError';
this.message = message || 'LimitError';
this.stack = (new Error()).stack;
function LimitError (message) {
this.name = 'LimitError'
this.message = message || 'LimitError'
this.stack = (new Error()).stack
}
LimitError.prototype = Object.create(Error.prototype);
LimitError.prototype.constructor = LimitError;
LimitError.prototype = Object.create(Error.prototype)
LimitError.prototype.constructor = LimitError
module.exports = LimitError;
module.exports = LimitError

@@ -1,10 +0,10 @@

function TimeoutError(message) {
this.name = 'TimeoutError';
this.message = message || 'TimeoutError';
this.stack = (new Error()).stack;
function TimeoutError (message) {
this.name = 'TimeoutError'
this.message = message || 'TimeoutError'
this.stack = (new Error()).stack
}
TimeoutError.prototype = Object.create(Error.prototype);
TimeoutError.prototype.constructor = TimeoutError;
TimeoutError.prototype = Object.create(Error.prototype)
TimeoutError.prototype.constructor = TimeoutError
module.exports = TimeoutError;
module.exports = TimeoutError

@@ -1,6 +0,6 @@

var utils = require('require-all')(__dirname + '/utils');
var callback = require('require-all')(__dirname + '/callback');
var promise = require('require-all')(__dirname + '/promise');
var path = require('path')
var utils = require('require-all')(path.join(__dirname, 'utils'))
var callback = require('require-all')(path.join(__dirname, 'callback'))
var promise = require('require-all')(path.join(__dirname, 'promise'))
module.exports = {

@@ -10,2 +10,2 @@ utils: utils,

promise: promise
};
}
{
"name": "async-deco",
"version": "8.3.0",
"version": "8.4.0",
"description": "A collection of decorators for adding features to asynchronous functions (callback or promise based).",

@@ -9,6 +9,6 @@ "main": "index.js",

"watch": "npm run test -- -w",
"lint": "./node_modules/.bin/eslint --ext .js ./src ./tests",
"release:major": "./node_modules/.bin/npm-release major",
"release:minor": "./node_modules/.bin/npm-release minor",
"release:patch": "./node_modules/.bin/npm-release patch",
"lint": "eslint --fix --ext .js ./src ./tests ./callback ./errors ./promise ./utils",
"release:major": "npm-release major",
"release:minor": "npm-release minor",
"release:patch": "npm-release patch",
"precommit": "npm run lint",

@@ -26,21 +26,26 @@ "prepush": "npm run test"

"devDependencies": {
"chai": "^1.10.0",
"eslint": "^1.10.3",
"husky": "^0.10.2",
"chai": "^4.1.2",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"husky": "^0.14.3",
"memoize-cache": "^5.0.1",
"mocha": "^2.1.0",
"mocha": "^5.0.5",
"npm-release": "^1.0.0",
"redis": "^2.8.0",
"redlock": "^3.1.0"
"redlock": "^3.1.2"
},
"dependencies": {
"es6-promisify": "^3.0.0",
"little-ds-toolkit": "0.4.0",
"lodash": "^4.13.1",
"es6-promisify": "^6.0.0",
"little-ds-toolkit": "^0.4.0",
"lodash": "^4.17.5",
"memoize-cache-utils": "^0.1.1",
"occamsrazor-match": "^4.1.0",
"require-all": "^2.0.0",
"setimmediate": "^1.0.4",
"uuid": "^2.0.2"
"require-all": "^2.2.0",
"setimmediate": "^1.0.5",
"uuid": "^3.2.1"
}
}

@@ -1,8 +0,8 @@

var _atomic = require('../src/atomic');
var wrapper = require('../src/promise-translator');
var _atomic = require('../src/atomic')
var wrapper = require('../src/promise-translator')
function atomic(opts) {
return _atomic(wrapper, opts);
function atomic (opts) {
return _atomic(wrapper, opts)
}
module.exports = atomic;
module.exports = atomic

@@ -1,8 +0,8 @@

var _balance = require('../src/balance');
var wrapper = require('../src/promise-translator');
var _balance = require('../src/balance')
var wrapper = require('../src/promise-translator')
function balance(policy) {
return _balance(wrapper, policy);
function balance (policy) {
return _balance(wrapper, policy)
}
module.exports = balance;
module.exports = balance

@@ -1,8 +0,8 @@

var _cache = require('../src/cache');
var wrapper = require('../src/promise-translator');
var _cache = require('../src/cache')
var wrapper = require('../src/promise-translator')
function cache(cache, opts) {
return _cache(wrapper, cache, opts);
function cache (cache, opts) {
return _cache(wrapper, cache, opts)
}
module.exports = cache;
module.exports = cache

@@ -1,8 +0,8 @@

var _debounce = require('../src/debounce').debounce;
var wrapper = require('../src/promise-translator');
var _debounce = require('../src/debounce').debounce
var wrapper = require('../src/promise-translator')
function debounce(wait, debounceOpts, getKey, cacheOpts) {
return _debounce(wrapper, wait, debounceOpts, getKey, cacheOpts);
function debounce (wait, debounceOpts, getKey, cacheOpts) {
return _debounce(wrapper, wait, debounceOpts, getKey, cacheOpts)
}
module.exports = debounce;
module.exports = debounce

@@ -1,8 +0,8 @@

var _dedupe = require('../src/dedupe');
var wrapper = require('../src/promise-translator');
var _dedupe = require('../src/dedupe')
var wrapper = require('../src/promise-translator')
function dedupe(opts) {
return _dedupe(wrapper, opts);
function dedupe (opts) {
return _dedupe(wrapper, opts)
}
module.exports = dedupe;
module.exports = dedupe

@@ -1,8 +0,8 @@

var _fallbackCache = require('../src/fallback-cache');
var wrapper = require('../src/promise-translator');
var _fallbackCache = require('../src/fallback-cache')
var wrapper = require('../src/promise-translator')
function fallbackCache(cache, opts) {
return _fallbackCache(wrapper, cache, opts);
function fallbackCache (cache, opts) {
return _fallbackCache(wrapper, cache, opts)
}
module.exports = fallbackCache;
module.exports = fallbackCache

@@ -1,8 +0,8 @@

var _fallbackValue = require('../src/fallback-value');
var wrapper = require('../src/promise-translator');
var _fallbackValue = require('../src/fallback-value')
var wrapper = require('../src/promise-translator')
function fallbackValue(value, error) {
return _fallbackValue(wrapper, value, error);
function fallbackValue (value, error) {
return _fallbackValue(wrapper, value, error)
}
module.exports = fallbackValue;
module.exports = fallbackValue

@@ -1,8 +0,8 @@

var _fallback = require('../src/fallback');
var wrapper = require('../src/promise-translator');
var _fallback = require('../src/fallback')
var wrapper = require('../src/promise-translator')
function fallback(fallbackFunction, error) {
return _fallback(wrapper, fallbackFunction, error);
function fallback (fallbackFunction, error) {
return _fallback(wrapper, fallbackFunction, error)
}
module.exports = fallback;
module.exports = fallback

@@ -1,8 +0,8 @@

var _limit = require('../src/limit');
var wrapper = require('../src/promise-translator');
var _limit = require('../src/limit')
var wrapper = require('../src/promise-translator')
function limit(max, getKey, getPriority) {
return _limit(wrapper, max, getKey, getPriority);
function limit (max, getKey, getPriority) {
return _limit(wrapper, max, getKey, getPriority)
}
module.exports = limit;
module.exports = limit

@@ -1,8 +0,8 @@

var _log = require('../src/log');
var wrapper = require('../src/promise-translator');
var _log = require('../src/log')
var wrapper = require('../src/promise-translator')
function log(prefix) {
return _log(wrapper, prefix);
function log (prefix) {
return _log(wrapper, prefix)
}
module.exports = log;
module.exports = log

@@ -1,8 +0,8 @@

var _memoize = require('../src/memoize');
var wrapper = require('../src/promise-translator');
var _memoize = require('../src/memoize')
var wrapper = require('../src/promise-translator')
function memoize(getKey) {
return _memoize(wrapper, getKey);
function memoize (getKey) {
return _memoize(wrapper, getKey)
}
module.exports = memoize;
module.exports = memoize

@@ -1,4 +0,4 @@

var _parallel = require('../src/parallel');
var wrapper = require('../src/promise-translator');
var _parallel = require('../src/parallel')
var wrapper = require('../src/promise-translator')
module.exports = wrapper(_parallel);
module.exports = wrapper(_parallel)

@@ -1,8 +0,8 @@

var _proxy = require('../src/proxy');
var wrapper = require('../src/promise-translator');
var _proxy = require('../src/proxy')
var wrapper = require('../src/promise-translator')
function proxy(guard) {
return _proxy(wrapper, guard);
function proxy (guard) {
return _proxy(wrapper, guard)
}
module.exports = proxy;
module.exports = proxy

@@ -1,8 +0,8 @@

var _purgeCache = require('../src/purge-cache');
var wrapper = require('../src/promise-translator');
var _purgeCache = require('../src/purge-cache')
var wrapper = require('../src/promise-translator')
function purgeCache(cache, opts) {
return _purgeCache(wrapper, cache, opts);
function purgeCache (cache, opts) {
return _purgeCache(wrapper, cache, opts)
}
module.exports = purgeCache;
module.exports = purgeCache

@@ -1,4 +0,4 @@

var _race = require('../src/race');
var wrapper = require('../src/promise-translator');
var _race = require('../src/race')
var wrapper = require('../src/promise-translator')
module.exports = wrapper(_race);
module.exports = wrapper(_race)

@@ -1,8 +0,8 @@

var _retry = require('../src/retry');
var wrapper = require('../src/promise-translator');
var _retry = require('../src/retry')
var wrapper = require('../src/promise-translator')
function retry(times, interval, error) {
return _retry(wrapper, times, interval, error);
function retry (times, interval, error) {
return _retry(wrapper, times, interval, error)
}
module.exports = retry;
module.exports = retry

@@ -1,8 +0,8 @@

var _throttle = require('../src/debounce').throttle;
var wrapper = require('../src/promise-translator');
var _throttle = require('../src/debounce').throttle
var wrapper = require('../src/promise-translator')
function throttle(wait, throttleOpts, getKey, cacheOpts) {
return _throttle(wrapper, wait, throttleOpts, getKey, cacheOpts);
function throttle (wait, throttleOpts, getKey, cacheOpts) {
return _throttle(wrapper, wait, throttleOpts, getKey, cacheOpts)
}
module.exports = throttle;
module.exports = throttle

@@ -1,8 +0,8 @@

var _timeout = require('../src/timeout');
var wrapper = require('../src/promise-translator');
var _timeout = require('../src/timeout')
var wrapper = require('../src/promise-translator')
function timeout(ms) {
return _timeout(wrapper, ms);
function timeout (ms) {
return _timeout(wrapper, ms)
}
module.exports = timeout;
module.exports = timeout

@@ -1,9 +0,9 @@

var _validator = require('../src/validator');
var wrapper = require('../src/promise-translator');
var _validator = require('../src/validator')
var wrapper = require('../src/promise-translator')
function validator() {
var args = Array.prototype.slice.call(arguments, 0);
return _validator(wrapper, args);
function validator () {
var args = Array.prototype.slice.call(arguments, 0)
return _validator(wrapper, args)
}
module.exports = validator;
module.exports = validator

@@ -1,4 +0,4 @@

var _waterfall = require('../src/waterfall');
var wrapper = require('../src/promise-translator');
var _waterfall = require('../src/waterfall')
var wrapper = require('../src/promise-translator')
module.exports = wrapper(_waterfall);
module.exports = wrapper(_waterfall)

@@ -730,2 +730,18 @@ async-deco

```
funcRenamer
-----------
It is a decorator that changes the name of the resulting function.
```js
var funcRenamer = require('async-deco/utils/funcRenamer');
var rename = funcRenamer('hello')
var f = rename(function ciao () {})
// f.name === 'hello'
```
It can also decorate the name (setting the second argument to true):
```js
var funcRenamer = require('async-deco/utils/funcRenamer');
var rename = funcRenamer('hello', true)
var f = rename(function world () {})
// f.name === 'hello(world)'
```

@@ -732,0 +748,0 @@ Compose

@@ -1,51 +0,50 @@

var defaultLogger = require('../utils/default-logger');
var keyGetter = require('memoize-cache-utils/key-getter');
var Lock = require('../utils/lock');
var defaultLogger = require('../utils/default-logger')
var keyGetter = require('memoize-cache-utils/key-getter')
var Lock = require('../utils/lock')
function atomicDecorator(wrapper, opts) {
opts = opts || {};
var getKey = keyGetter(opts.getKey || function () { return '_default'; });
var lockObj = opts.lock || new Lock();
var ttl = opts.ttl || 1000;
function getAtomicDecorator (wrapper, opts) {
opts = opts || {}
var getKey = keyGetter(opts.getKey || function () { return '_default' })
var lockObj = opts.lock || new Lock()
var ttl = opts.ttl || 1000
return wrapper(function _atomicDecorator(func) {
return wrapper(function atomic (func) {
return function _atomic () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger
var cb = args[args.length - 1]
var cacheKey = getKey.apply(context, args)
return function _atomic() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger;
var cb = args[args.length - 1];
var cacheKey = getKey.apply(context, args);
if (cacheKey == null ) {
return func.apply(context, args);
if (cacheKey == null) {
return func.apply(context, args)
}
logger = defaultLogger.apply(context);
logger = defaultLogger.apply(context)
var logError = function (err) {
if (err) {
logger('atomic-lock-error', { error: err });
logger('atomic-lock-error', { error: err })
}
};
}
lockObj.lock(cacheKey, ttl, function (e, lock) {
logError(e);
logError(e)
args[args.length - 1] = function (err, res) {
lock.unlock(logError);
cb(err, res);
};
lock.unlock(logError)
cb(err, res)
}
try {
func.apply(context, args);
func.apply(context, args)
} catch (e) {
lock.unlock(logError);
throw e;
lock.unlock(logError)
throw e
}
});
};
});
})
}
})
}
module.exports = atomicDecorator;
module.exports = getAtomicDecorator

@@ -1,32 +0,30 @@

var defaultLogger = require('../utils/default-logger');
var balancePolicies = require('../utils/balance-policies');
var defaultLogger = require('../utils/default-logger')
var balancePolicies = require('../utils/balance-policies')
function balanceDecorator(wrapper, policy) {
policy = policy || balancePolicies.idlest;
return wrapper(function _balanceDecorator(funcs) {
var loads = funcs.map(function () {return 0;});
var executionNumber = 0;
function getBalanceDecorator (wrapper, policy) {
policy = policy || balancePolicies.idlest
return wrapper(function balance (funcs) {
var loads = funcs.map(function () { return 0 })
var executionNumber = 0
return function _balance() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
var selected = policy.call(context, executionNumber++, loads, args);
loads[selected]++;
return function _balance () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
var selected = policy.call(context, executionNumber++, loads, args)
loads[selected]++
args[args.length - 1] = function (err, res) {
loads[selected]--;
cb(err, res);
};
loads[selected]--
cb(err, res)
}
logger('balance-execute', {loads: loads, executing: selected});
logger('balance-execute', {loads: loads, executing: selected})
funcs[selected].apply(context, args);
};
});
funcs[selected].apply(context, args)
}
})
}
module.exports = balanceDecorator;
module.exports = getBalanceDecorator

@@ -1,46 +0,43 @@

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var defaultLogger = require('../utils/default-logger')
var getErrorCondition = require('./get-error-condition')
function cacheDecorator(wrapper, cache, opts) {
opts = opts || {};
var condition = getErrorCondition(opts.error);
function getCacheDecorator (wrapper, cacheObj, opts) {
opts = opts || {}
var condition = getErrorCondition(opts.error)
return wrapper(function _cacheDecorator(func) {
return function _cache() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
return wrapper(function cache (func) {
return function _cache () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
cache.query(args, function (err, cacheQuery) {
var key;
cacheObj.query(args, function (err, cacheQuery) {
var key
if (err) {
logger('cache-error', {cacheErr: err});
func.apply(context, args);
}
else if (cacheQuery.cached === true && !cacheQuery.stale) {
logger('cache-hit', {key: cacheQuery.key, result: cacheQuery, timing: cacheQuery.timing});
cb(null, cacheQuery.hit);
}
else if (cacheQuery.key === null) { // no cache
func.apply(context, args);
}
else {
logger('cache-miss', {key: cacheQuery.key, timing: cacheQuery.timing});
logger('cache-error', {cacheErr: err})
func.apply(context, args)
} else if (cacheQuery.cached === true && !cacheQuery.stale) {
logger('cache-hit', {key: cacheQuery.key, result: cacheQuery, timing: cacheQuery.timing})
cb(null, cacheQuery.hit)
} else if (cacheQuery.key === null) { // no cache
func.apply(context, args)
} else {
logger('cache-miss', {key: cacheQuery.key, timing: cacheQuery.timing})
args[args.length - 1] = function (err, res) {
if (!condition(err, res)) {
key = cache.push(args, res);
key = cacheObj.push(args, res)
if (key) {
logger('cache-set', {key: key.key, tags: key.tags, args: args, res: res});
logger('cache-set', {key: key.key, tags: key.tags, args: args, res: res})
}
}
cb(err, res);
};
func.apply(context, args);
cb(err, res)
}
func.apply(context, args)
}
});
};
});
})
}
})
}
module.exports = cacheDecorator;
module.exports = getCacheDecorator

@@ -1,28 +0,28 @@

var debounce = require('lodash/debounce');
var throttle = require('lodash/throttle');
var decoratorCacheFactory = require('../utils/decorator-cache-factory');
var debounce = require('lodash/debounce')
var throttle = require('lodash/throttle')
var decoratorCacheFactory = require('../utils/decorator-cache-factory')
function debounceCBDecorator(wait, opts) {
return function _debounceCBDecorator(func) {
return debounce(func, wait, opts);
};
function debounceCBDecorator (wait, opts) {
return function _debounceCBDecorator (func) {
return debounce(func, wait, opts)
}
}
function throttleCBDecorator(wait, opts) {
return function _throttleCBDecorator(func) {
return throttle(func, wait, opts);
};
function throttleCBDecorator (wait, opts) {
return function _throttleCBDecorator (func) {
return throttle(func, wait, opts)
}
}
function debounceDecorator(wrapper, wait, debounceOpts, getKey, cacheOpts) {
return decoratorCacheFactory(wrapper, debounceCBDecorator(wait, debounceOpts), getKey, cacheOpts);
function getDebounceDecorator (wrapper, wait, debounceOpts, getKey, cacheOpts) {
return decoratorCacheFactory(wrapper, debounceCBDecorator(wait, debounceOpts), getKey, cacheOpts)
}
function throttleDecorator(wrapper, wait, throttleOpts, getKey, cacheOpts) {
return decoratorCacheFactory(wrapper, throttleCBDecorator(wait, throttleOpts), getKey, cacheOpts);
function getThrottleDecorator (wrapper, wait, throttleOpts, getKey, cacheOpts) {
return decoratorCacheFactory(wrapper, throttleCBDecorator(wait, throttleOpts), getKey, cacheOpts)
}
module.exports = {
debounce: debounceDecorator,
throttle: throttleDecorator
};
debounce: getDebounceDecorator,
throttle: getThrottleDecorator
}

@@ -1,47 +0,46 @@

var defaultLogger = require('../utils/default-logger');
var keyGetter = require('memoize-cache-utils/key-getter');
var Lock = require('../utils/lock');
var FunctionBus = require('../utils/function-bus');
var defaultLogger = require('../utils/default-logger')
var keyGetter = require('memoize-cache-utils/key-getter')
var Lock = require('../utils/lock')
var FunctionBus = require('../utils/function-bus')
function dedupeDecorator(wrapper, opts) {
opts = opts || {};
opts = typeof opts === 'function' ? { getKey: opts } : opts;
var getKey = keyGetter(opts.getKey || function () { return '_default'; });
var lockObj = opts.lock || new Lock();
var functionBus = opts.functionBus || new FunctionBus();
var ttl = opts.ttl || 1000;
function getDedupeDecorator (wrapper, opts) {
opts = opts || {}
opts = typeof opts === 'function' ? { getKey: opts } : opts
var getKey = keyGetter(opts.getKey || function () { return '_default' })
var lockObj = opts.lock || new Lock()
var functionBus = opts.functionBus || new FunctionBus()
var ttl = opts.ttl || 1000
return wrapper(function (func) {
return wrapper(function dedupe (func) {
return function _dedupe () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
var cacheKey = getKey.apply(context, args)
return function () {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
var cacheKey = getKey.apply(context, args);
if (cacheKey == null) {
return func.apply(context, args);
return func.apply(context, args)
}
functionBus.onExecute(function (cacheKey, len) {
logger('dedupe-execute', { key: cacheKey, len: len });
});
logger('dedupe-execute', { key: cacheKey, len: len })
})
functionBus.queue(cacheKey, cb);
functionBus.queue(cacheKey, cb)
lockObj.lock(cacheKey, ttl, function (e, lock) {
if (functionBus.len(cacheKey)) {
args[args.length - 1] = function (err, res) {
functionBus.execute(cacheKey, [err, res]);
lock.unlock();
};
func.apply(context, args);
functionBus.execute(cacheKey, [err, res])
lock.unlock()
}
func.apply(context, args)
} else {
lock.unlock();
lock.unlock()
}
});
};
});
})
}
})
}
module.exports = dedupeDecorator;
module.exports = getDedupeDecorator

@@ -1,57 +0,52 @@

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var defaultLogger = require('../utils/default-logger')
var getErrorCondition = require('./get-error-condition')
function fallbackCacheDecorator(wrapper, cache, opts) {
opts = opts || {};
var error = opts.error || Error;
var useStale = opts.useStale;
var noPush = opts.noPush;
var condition = getErrorCondition(opts.error);
function getFallbackCacheDecorator (wrapper, cache, opts) {
opts = opts || {}
var useStale = opts.useStale
var noPush = opts.noPush
var condition = getErrorCondition(opts.error)
return wrapper(function _fallbackCacheDecorator(func) {
return function _fallbackCache() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
return wrapper(function fallbackCache (func) {
return function _fallbackCache () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
args[args.length - 1] = function (err, res) {
var key;
var key
if (condition(err, res)) {
cache.query(args, function (e, cacheQuery) {
if (e) {
logger('fallback-cache-error', {err: err, cacheErr: e});
cb(err, res);
}
else if (cacheQuery.cached === true &&
logger('fallback-cache-error', {err: err, cacheErr: e})
cb(err, res)
} else if (cacheQuery.cached === true &&
(!cacheQuery.stale || (useStale && cacheQuery.stale))) {
logger('fallback-cache-hit', {timing: cacheQuery.timing, key: cacheQuery.key, result: cacheQuery, actualResult: {err: err, res: res}});
cb(null, cacheQuery.hit);
logger('fallback-cache-hit', {timing: cacheQuery.timing, key: cacheQuery.key, result: cacheQuery, actualResult: {err: err, res: res}})
cb(null, cacheQuery.hit)
} else if (cacheQuery.key === null) { // no cache
cb(err, res)
} else {
logger('fallback-cache-miss', {timing: cacheQuery.timing, key: cacheQuery.key, actualResult: {err: err, res: res}})
cb(err, res)
}
else if (cacheQuery.key === null) { // no cache
cb(err, res);
}
else {
logger('fallback-cache-miss', {timing: cacheQuery.timing, key: cacheQuery.key, actualResult: {err: err, res: res}});
cb(err, res);
}
});
}
else {
})
} else {
if (!noPush) {
key = cache.push(args, res);
key = cache.push(args, res)
if (key) {
logger('fallback-cache-set', {key: key.key, tags: key.tags, args: args, res: res});
logger('fallback-cache-set', {key: key.key, tags: key.tags, args: args, res: res})
}
}
cb(err, res);
cb(err, res)
}
};
}
func.apply(context, args);
};
});
func.apply(context, args)
}
})
}
module.exports = fallbackCacheDecorator;
module.exports = getFallbackCacheDecorator

@@ -1,29 +0,28 @@

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var defaultLogger = require('../utils/default-logger')
var getErrorCondition = require('./get-error-condition')
function fallbackValueDecorator(wrapper, fallbackValue, error) {
var condition = getErrorCondition(error);
function getFallbackValueDecorator (wrapper, fallbackVal, error) {
var condition = getErrorCondition(error)
return wrapper(function _fallbackValueDecorator(func) {
return function _fallbackValue() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
return wrapper(function fallbackValue (func) {
return function _fallbackValue () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
args[args.length - 1] = function (err, dep) {
if (condition(err, dep)) {
logger('fallback', {actualResult: {err: err, res: dep}});
cb(null, fallbackValue);
logger('fallback', {actualResult: {err: err, res: dep}})
cb(null, fallbackVal)
} else {
cb(err, dep)
}
else {
cb(err, dep);
}
};
}
func.apply(context, args);
};
});
func.apply(context, args)
}
})
}
module.exports = fallbackValueDecorator;
module.exports = getFallbackValueDecorator

@@ -1,29 +0,28 @@

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var defaultLogger = require('../utils/default-logger')
var getErrorCondition = require('./get-error-condition')
function fallbackDecorator(wrapper, fallbackFunction, error) {
var condition = getErrorCondition(error);
function getFallbackDecorator (wrapper, fallbackFunction, error) {
var condition = getErrorCondition(error)
return wrapper(function _fallbackDecorator(func) {
return function _fallback() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
return wrapper(function fallback (func) {
return function _fallback () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
args[args.length - 1] = function (err, dep) {
if (condition(err, dep)) {
logger('fallback', {actualResult: {err: err, res: dep}});
fallbackFunction.apply(context, args.slice(0, -1).concat(cb));
logger('fallback', {actualResult: {err: err, res: dep}})
fallbackFunction.apply(context, args.slice(0, -1).concat(cb))
} else {
cb(err, dep)
}
else {
cb(err, dep);
}
};
}
func.apply(context, args);
};
});
func.apply(context, args)
}
})
}
module.exports = fallbackDecorator;
module.exports = getFallbackDecorator

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

module.exports = function getErrorCondition(ErrorClass) {
var error = ErrorClass || Error;
module.exports = function getErrorCondition (ErrorClass) {
var error = ErrorClass || Error
if (error === Error || Error.isPrototypeOf(error)) {
return function isError(err, res) { return err instanceof error; };
return function isError (err, res) { return err instanceof error }
}
return error;
};
return error
}

@@ -1,41 +0,40 @@

require('setimmediate');
var LimitError = require('../errors/limit-error');
var defaultLogger = require('../utils/default-logger');
var keyGetter = require('memoize-cache-utils/key-getter');
var TaskQueue = require('../utils/task-queue');
require('setimmediate')
var LimitError = require('../errors/limit-error')
var defaultLogger = require('../utils/default-logger')
var keyGetter = require('memoize-cache-utils/key-getter')
var TaskQueue = require('../utils/task-queue')
var queueFactory = TaskQueue.queueFactory;
var TaskQueueOverflowError = TaskQueue.TaskQueueOverflowError;
var queueFactory = TaskQueue.queueFactory
var TaskQueueOverflowError = TaskQueue.TaskQueueOverflowError
function limitDecorator(wrapper, max, getKey, getPriority) {
getKey = keyGetter(getKey || function () { return '_default'; });
max = max || 1;
var queueSize = Infinity;
function getLimitDecorator (wrapper, max, getKey, getPriority) {
getKey = keyGetter(getKey || function () { return '_default' })
max = max || 1
var queueSize = Infinity
if (typeof max === 'object') {
queueSize = max.queueSize;
max = max.limit;
queueSize = max.queueSize
max = max.limit
}
var executionNumbers = {};
var queues = {};
var executionNumbers = {}
var queues = {}
return wrapper(function _limitDecorator(func) {
return wrapper(function limit (func) {
return function _limit () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger
var cb = args[args.length - 1]
var cacheKey = getKey.apply(context, args)
return function _limit() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger;
var cb = args[args.length - 1];
var cacheKey = getKey.apply(context, args);
function runQueues() {
function runQueues () {
// should run ALL the queues
var cacheKey, f;
var cacheKey, f
for (cacheKey in executionNumbers) {
if (executionNumbers[cacheKey] >= max) {
continue;
continue
}
f = queues[cacheKey].shift();
f = queues[cacheKey].shift()
if (f) {
executionNumbers[cacheKey]++;
setImmediate(f);
executionNumbers[cacheKey]++
setImmediate(f)
}

@@ -45,46 +44,43 @@ }

if (cacheKey == null ) {
return func.apply(context, args);
if (cacheKey == null) {
return func.apply(context, args)
}
if (!(cacheKey in executionNumbers)) {
executionNumbers[cacheKey] = 0;
queues[cacheKey] = queueFactory(getPriority, queueSize);
executionNumbers[cacheKey] = 0
queues[cacheKey] = queueFactory(getPriority, queueSize)
}
args[args.length - 1] = function (err, dep) {
executionNumbers[cacheKey]--;
runQueues();
executionNumbers[cacheKey]--
runQueues()
if (executionNumbers[cacheKey] === 0) {
delete executionNumbers[cacheKey];
delete queues[cacheKey];
delete executionNumbers[cacheKey]
delete queues[cacheKey]
}
cb(err, dep);
};
cb(err, dep)
}
if (executionNumbers[cacheKey] < max) {
executionNumbers[cacheKey]++;
func.apply(context, args);
}
else {
executionNumbers[cacheKey]++
func.apply(context, args)
} else {
try {
queues[cacheKey].push(func, context, args, cb);
logger = defaultLogger.apply(context);
logger('limit-queue', { queueSize: queueSize, parallel: executionNumbers[cacheKey], key: cacheKey });
}
catch (e) {
queues[cacheKey].push(func, context, args, cb)
logger = defaultLogger.apply(context)
logger('limit-queue', { queueSize: queueSize, parallel: executionNumbers[cacheKey], key: cacheKey })
} catch (e) {
if (e instanceof TaskQueueOverflowError) {
logger = defaultLogger.apply(e.item.context);
logger('limit-drop', { queueSize: queueSize, parallel: executionNumbers[cacheKey], key: cacheKey });
e.item.cb(new LimitError('Max queue size reached (' + queueSize + ')'));
logger = defaultLogger.apply(e.item.context)
logger('limit-drop', { queueSize: queueSize, parallel: executionNumbers[cacheKey], key: cacheKey })
e.item.cb(new LimitError('Max queue size reached (' + queueSize + ')'))
} else {
throw e
}
else {
throw e;
}
}
}
};
});
}
})
}
module.exports = limitDecorator;
module.exports = getLimitDecorator

@@ -1,11 +0,11 @@

var defaultLogger = require('../utils/default-logger');
var defaultLogger = require('../utils/default-logger')
function logDecorator(wrapper, prefix) {
prefix = prefix || '';
return wrapper(function _logDecorator(func) {
return function _log() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
function getLogDecorator (wrapper, prefix) {
prefix = prefix || ''
return wrapper(function log (func) {
return function _log () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]

@@ -16,17 +16,16 @@ args[args.length - 1] = function (err, dep) {

err: err
});
}
else {
})
} else {
logger(prefix + 'log-end', {
result: dep
});
})
}
cb(err, dep);
};
logger(prefix + 'log-start', {args: args.slice(0, -1), context: context});
func.apply(context, args);
};
});
cb(err, dep)
}
logger(prefix + 'log-start', {args: args.slice(0, -1), context: context})
func.apply(context, args)
}
})
}
module.exports = logDecorator;
module.exports = getLogDecorator

@@ -1,32 +0,31 @@

var defaultLogger = require('../utils/default-logger');
var keyGetter = require('memoize-cache-utils/key-getter');
var defaultLogger = require('../utils/default-logger')
var keyGetter = require('memoize-cache-utils/key-getter')
function memoizeDecorator(wrapper, getKey) {
getKey = keyGetter(getKey || function () { return '_default'; });
var cache = {};
function getMemoizeDecorator (wrapper, getKey) {
getKey = keyGetter(getKey || function () { return '_default' })
var cache = {}
return wrapper(function _memoizeDecorator(func) {
return function _memoize() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
var cacheKey = getKey.apply(context, args);
return wrapper(function memoize (func) {
return function _memoize () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
var cacheKey = getKey.apply(context, args)
args[args.length - 1] = function (err, dep) {
if (!err && cacheKey !== null) {
cache[cacheKey] = dep;
cache[cacheKey] = dep
}
cb(err, dep);
};
cb(err, dep)
}
if (cacheKey !== null && cacheKey in cache) {
logger('memoize-hit', {key: cacheKey, result: cache[cacheKey]});
return cb(null, cache[cacheKey]);
logger('memoize-hit', {key: cacheKey, result: cache[cacheKey]})
return cb(null, cache[cacheKey])
} else {
func.apply(context, args)
}
else {
func.apply(context, args);
}
};
});
}
})
}
module.exports = memoizeDecorator;
module.exports = getMemoizeDecorator
function parallel(funcs) {
var len = funcs.length;
function parallel (funcs) {
var len = funcs.length
return function _parallel() {
var currentFunc;
var functions = funcs.slice(0);
var index = 0;
var done = false;
var results = Array(len);
var args = Array.prototype.slice.call(arguments, 0);
var cb = args[args.length - 1];
var context = this;
return function _parallel () {
var currentFunc
var functions = funcs.slice(0)
var index = 0
var done = false
var results = Array(len)
var args = Array.prototype.slice.call(arguments, 0)
var cb = args[args.length - 1]
var context = this
function callback(i) {
return function __parallel(err, res) {
len--;
function callback (i) {
return function __parallel (err, res) {
len--
if (done) {
return; // into the bitbucket
return // into the bitbucket
}
if (err) {
done = true;
return cb(err);
done = true
return cb(err)
}
results[i] = res;
results[i] = res
if (len === 0) {
return cb(null, results);
return cb(null, results)
}
};
}
}
while (functions.length) {
currentFunc = functions.shift();
args[args.length - 1] = callback(index);
index++;
currentFunc.apply(context, args);
currentFunc = functions.shift()
args[args.length - 1] = callback(index)
index++
currentFunc.apply(context, args)
}
};
}
}
module.exports = parallel;
module.exports = parallel

@@ -1,19 +0,28 @@

var promisify = require('es6-promisify');
var callbackify = require('../utils/callbackify');
var promisify = require('es6-promisify').promisify
var callbackify = require('../utils/callbackify')
var funcRenamer = require('../utils/func-renamer')
// it works for decorator(f) and decorator([f1, f2, f3 ...])
function promiseTranslator(decorator) {
return function (f) { // f returns a promise
var cb;
function getFuncName (func) {
return func.name || 'anonymous'
}
function promiseTranslator (decorator) {
var decoratorName = decorator.name
return function _getPromise (f) { // f returns a promise
var funcName
var cb
if (Array.isArray(f)) {
cb = f.map(callbackify);
cb = f.map(callbackify)
funcName = f.map(getFuncName).join(',')
} else {
cb = callbackify(f);
cb = callbackify(f)
funcName = getFuncName(f)
}
return promisify(decorator(cb));
};
var funcRename = funcRenamer(decoratorName + '(' + funcName + ')')
return funcRename(promisify(decorator(cb)))
}
}
module.exports = promiseTranslator;
module.exports = promiseTranslator

@@ -1,11 +0,11 @@

var defaultLogger = require('../utils/default-logger');
var defaultLogger = require('../utils/default-logger')
function proxyDecorator(wrapper, guard) {
return wrapper(function _proxyDecorator(func) {
return function _proxy() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var guardArgs = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
function getProxyDecorator (wrapper, guard) {
return wrapper(function proxy (func) {
return function _proxy () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var guardArgs = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]

@@ -16,15 +16,14 @@ guardArgs[args.length - 1] = function (err) {

err: err
});
cb(err);
})
cb(err)
} else {
func.apply(context, args)
}
else {
func.apply(context, args);
}
};
}
guard.apply(context, guardArgs);
};
});
guard.apply(context, guardArgs)
}
})
}
module.exports = proxyDecorator;
module.exports = getProxyDecorator

@@ -1,24 +0,24 @@

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var keysGetter = require('memoize-cache-utils/keys-getter');
var defaultLogger = require('../utils/default-logger')
var getErrorCondition = require('./get-error-condition')
var keysGetter = require('memoize-cache-utils/keys-getter')
function purgeCacheDecorator(wrapper, cache, opts) {
opts = opts || {};
var condition = getErrorCondition(opts.error);
var getCacheKeys = keysGetter(opts.keys);
var getTags = keysGetter(opts.tags);
function getPurgeCacheDecorator (wrapper, cache, opts) {
opts = opts || {}
var condition = getErrorCondition(opts.error)
var getCacheKeys = keysGetter(opts.keys)
var getTags = keysGetter(opts.tags)
return wrapper(function _purgeCacheDecorator(func) {
return function _purgeCache() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var keys = getCacheKeys.apply(this, args);
var tags = getTags.apply(this, args);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
return wrapper(function purgeCache (func) {
return function _purgeCache () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var keys = getCacheKeys.apply(this, args)
var tags = getTags.apply(this, args)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
var catchingError = function (err) {
if (err) logger('purge-cache-error', { cacheErr: err });
return !!err;
};
if (err) logger('purge-cache-error', { cacheErr: err })
return !!err
}

@@ -29,19 +29,19 @@ args[args.length - 1] = function (err, res) {

cache.purgeByTags(tags, function () {
if (!catchingError(err)) logger('purge-cache', { tags: tags });
});
if (!catchingError(err)) logger('purge-cache', { tags: tags })
})
} else if (keys && Array.isArray(keys) && keys.length) {
cache.purgeByKeys(keys, function () {
if (!catchingError(err)) logger('purge-cache', { keys: keys });
});
if (!catchingError(err)) logger('purge-cache', { keys: keys })
})
}
} else {
logger('purge-cache-miss', { err: err, res: res });
logger('purge-cache-miss', { err: err, res: res })
}
cb(err, res);
};
func.apply(context, args);
};
});
cb(err, res)
}
func.apply(context, args)
}
})
}
module.exports = purgeCacheDecorator;
module.exports = getPurgeCacheDecorator
function race(funcs) {
function race (funcs) {
return function _race () {
var currentFunc
var functions = funcs.slice(0)
var i = functions.length
var done = false
var args = Array.prototype.slice.call(arguments, 0)
var cb = args[args.length - 1]
var context = this
return function _race() {
var currentFunc;
var functions = funcs.slice(0);
var i = functions.length;
var done = false;
var args = Array.prototype.slice.call(arguments, 0);
var cb = args[args.length - 1];
var context = this;
args[args.length - 1] = function (err, res) {
if (done) {
return; // into the bitbucket
return // into the bitbucket
}
if (err && i === 0) {
i--;
return cb(err, res);
i--
return cb(err, res)
}
if (!err) {
done = true;
return cb(err, res);
done = true
return cb(err, res)
}
};
}
while (functions.length) {
currentFunc = functions.shift();
currentFunc.apply(context, args);
currentFunc = functions.shift()
currentFunc.apply(context, args)
}
};
}
}
module.exports = race;
module.exports = race

@@ -1,31 +0,30 @@

var defaultLogger = require('../utils/default-logger');
var getErrorCondition = require('./get-error-condition');
var defaultLogger = require('../utils/default-logger')
var getErrorCondition = require('./get-error-condition')
function retryDecorator(wrapper, times, interval, error) {
times = times || Infinity;
interval = interval || 0;
var intervalFunc = typeof interval === 'function' ?
interval :
function () { return interval; };
function getRetryDecorator (wrapper, times, interval, error) {
times = times || Infinity
interval = interval || 0
var intervalFunc = typeof interval === 'function'
? interval
: function () { return interval }
var condition = getErrorCondition(error);
var condition = getErrorCondition(error)
return wrapper(function _retryDecorator(func) {
return function _retry() {
var counter = 0;
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
return wrapper(function retry (func) {
return function _retry () {
var counter = 0
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
var retry = function __retry() {
var retry = function __retry () {
if (counter++ && intervalFunc(counter) > 0) { // do not wait for counter === 0
setTimeout(function () {
func.apply(context, args);
}, interval);
func.apply(context, args)
}, interval)
} else {
func.apply(context, args)
}
else {
func.apply(context, args);
}
};
}

@@ -37,14 +36,13 @@ args[args.length - 1] = function (err, dep) {

actualResult: {err: err, res: dep}
});
retry();
})
retry()
} else {
cb(err, dep)
}
else {
cb(err, dep);
}
};
retry();
};
});
}
retry()
}
})
}
module.exports = retryDecorator;
module.exports = getRetryDecorator

@@ -1,40 +0,39 @@

var TimeoutError = require('../errors/timeout-error');
var defaultLogger = require('../utils/default-logger');
var TimeoutError = require('../errors/timeout-error')
var defaultLogger = require('../utils/default-logger')
function timeoutDecorator(wrapper, ms) {
function getTimeoutDecorator (wrapper, ms) {
return wrapper(function timeout (func) {
return function _timeout () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
return wrapper(function _timeoutDecorator(func) {
return function _timeout() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
var timedout = false;
var timedout = false
var timeout = setTimeout(function () {
var err = new TimeoutError('TimeoutError: Service timed out after ' + ms.toString() + ' ms');
timedout = true;
var err = new TimeoutError('TimeoutError: Service timed out after ' + ms.toString() + ' ms')
timedout = true
logger('timeout', {
ms: ms
});
cb(err);
}, ms);
})
cb(err)
}, ms)
// new callback
args[args.length - 1] = function () {
var cb_context = this;
var cb_args = Array.prototype.slice.call(arguments, 0);
var cbContext = this
var cbArgs = Array.prototype.slice.call(arguments, 0)
if (timedout) {
return; // abort because has been already called
return // abort because has been already called
}
clearTimeout(timeout); // abort time out
cb.apply(cb_context, cb_args);
};
clearTimeout(timeout) // abort time out
cb.apply(cbContext, cbArgs)
}
func.apply(context, args);
};
});
func.apply(context, args)
}
})
}
module.exports = timeoutDecorator;
module.exports = getTimeoutDecorator

@@ -1,19 +0,18 @@

var defaultLogger = require('../utils/default-logger');
var ValidatorError = require('occamsrazor-match/validate-error');
var match = require('occamsrazor-match');
var and = require('occamsrazor-match/extra/and');
var validationErrors = require('occamsrazor-match/extra/validationErrors');
var defaultLogger = require('../utils/default-logger')
var ValidatorError = require('occamsrazor-match/validate-error')
var match = require('occamsrazor-match')
var validationErrors = require('occamsrazor-match/extra/validationErrors')
function validatorDecorator(wrapper, args) {
var validators = match(args);
return wrapper(function _validatorDecorator(func) {
return function _validator() {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cb = args[args.length - 1];
var argsToValidate = Array.prototype.slice.call(arguments, 0, args.length - 1);
var errors = validationErrors();
function getValidatorDecorator (wrapper, args) {
var validators = match(args)
return wrapper(function validator (func) {
return function _validator () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var logger = defaultLogger.apply(context)
var cb = args[args.length - 1]
var argsToValidate = Array.prototype.slice.call(arguments, 0, args.length - 1)
var errors = validationErrors()
if (validators(argsToValidate, errors)) {
func.apply(context, args);
func.apply(context, args)
} else {

@@ -24,9 +23,9 @@ logger('validation-error', {

errors: errors()
});
cb(new ValidatorError('Function called with wrong arguments: ' + validators.name, errors()));
})
cb(new ValidatorError('Function called with wrong arguments: ' + validators.name, errors()))
}
};
});
}
})
}
module.exports = validatorDecorator;
module.exports = getValidatorDecorator
function waterfall(funcs) {
function waterfall (funcs) {
return function _waterfall () {
var functions = funcs.slice(0)
var currentFunc
var args = Array.prototype.slice.call(arguments, 0)
var cb = args[args.length - 1]
var context = this
return function _waterfall() {
var functions = funcs.slice(0);
var currentFunc;
var args = Array.prototype.slice.call(arguments, 0);
var cb = args[args.length - 1];
var context = this;
function callback(err, res) {
function callback (err, res) {
if (err) {
return cb(err);
return cb(err)
}
if (functions.length === 0) {
return cb(null, res);
return cb(null, res)
}
currentFunc = functions.shift();
currentFunc.apply(context, [res, callback]);
currentFunc = functions.shift()
currentFunc.apply(context, [res, callback])
}
currentFunc = functions.shift();
args[args.length - 1] = callback;
currentFunc.apply(context, args);
};
currentFunc = functions.shift()
args[args.length - 1] = callback
currentFunc.apply(context, args)
}
}
module.exports = waterfall;
module.exports = waterfall

@@ -1,16 +0,16 @@

var buildLogger = require('./build-logger');
var keyGetter = require('memoize-cache-utils/key-getter');
var buildLogger = require('./build-logger')
var keyGetter = require('memoize-cache-utils/key-getter')
function addLogger(log, getKey) {
getKey = keyGetter(getKey || function () { return Math.floor(Math.random() * 10000000).toString(); });
return function (func) {
function getAddLogger (log, getKey) {
getKey = keyGetter(getKey || function () { return Math.floor(Math.random() * 10000000).toString() })
return function addLogger (func) {
return function () {
var args = Array.prototype.slice.call(arguments, 0);
var logKey = getKey.apply(this, args);
var context = buildLogger(this, log, logKey);
return func.apply(context, args);
};
};
var args = Array.prototype.slice.call(arguments, 0)
var logKey = getKey.apply(this, args)
var context = buildLogger(this, log, logKey)
return func.apply(context, args)
}
}
}
module.exports = addLogger;
module.exports = getAddLogger

@@ -1,16 +0,16 @@

var policies = {};
var policies = {}
policies.roundRobin = function (c, loads) {
return c % loads.length;
};
return c % loads.length
}
policies.random = function (c, loads) {
return Math.floor(Math.random() * loads.length);
};
return Math.floor(Math.random() * loads.length)
}
policies.idlest = function (c, loads) {
var min = Math.min.apply(null, loads);
return loads.indexOf(min);
};
var min = Math.min.apply(null, loads)
return loads.indexOf(min)
}
module.exports = policies;
module.exports = policies

@@ -6,3 +6,3 @@ // gets an object and a logger function.

function wrap(obj) {
function wrap (obj) {
var ObjWithLogger = function () {

@@ -12,30 +12,30 @@ Object.defineProperty(this, '__log_funcs', {

enumerable: false
});
})
Object.defineProperty(this, '__log', {
value: (function (evt, payload) {
var ts = Date.now();
var logger, logKey;
value: function (evt, payload) {
var ts = Date.now()
var logger, logKey
for (var i = 0; i < this.__log_funcs.length; i++) {
logger = this.__log_funcs[i].logger;
logKey = this.__log_funcs[i].logKey;
logger(evt, payload, ts, logKey);
logger = this.__log_funcs[i].logger
logKey = this.__log_funcs[i].logKey
logger(evt, payload, ts, logKey)
}
}).bind(this),
}.bind(this),
enumerable: false
});
};
})
}
ObjWithLogger.prototype = Object.create(obj || null);
ObjWithLogger.prototype.constructor = ObjWithLogger;
ObjWithLogger.prototype = Object.create(obj || null)
ObjWithLogger.prototype.constructor = ObjWithLogger
return new ObjWithLogger();
return new ObjWithLogger()
}
module.exports = function buildLogger(obj, logger, logKey) {
module.exports = function buildLogger (obj, logger, logKey) {
if (!(typeof obj === 'object' && '__log' in obj)) {
obj = wrap(obj); // it only decorate once
obj = wrap(obj) // it only decorate once
}
obj.__log_funcs.push({ logger: logger, logKey: logKey });
return obj;
};
obj.__log_funcs.push({ logger: logger, logKey: logKey })
return obj
}

@@ -1,32 +0,30 @@

function isPromise(obj) {
return typeof obj === 'object' && 'then' in obj;
function isPromise (obj) {
return typeof obj === 'object' && 'then' in obj
}
function callbackify(func) {
return function () {
function callbackify (func) {
return function _callbackify () {
// get arguments
var context = this;
var args = Array.prototype.slice.call(arguments, 0, -1);
var cb = arguments[arguments.length - 1];
var context = this
var args = Array.prototype.slice.call(arguments, 0, -1)
var cb = arguments[arguments.length - 1]
try {
var output = func.apply(context, args);
var output = func.apply(context, args)
} catch (e) {
return cb(e)
}
catch (e) {
return cb(e);
}
if (isPromise(output)) {
output.then(function (res) { // onfulfilled
cb(null, res);
cb(null, res)
},
function (error) { // onrejected
cb(error);
});
cb(error)
})
} else {
cb(null, output)
}
else {
cb(null, output);
}
};
}
}
module.exports = callbackify;
module.exports = callbackify
function compose() {
var fns = Array.prototype.slice.call(arguments);
function compose () {
var fns = Array.prototype.slice.call(arguments)
if (Array.isArray(fns[0])) {
fns = fns[0];
fns = fns[0]
}
fns = fns
.filter(function (f) {
return f;
});
.filter(function (f) {
return f
})
if (!fns.length) {
fns = [ function (f) {return f;} ];
fns = [ function (f) { return f } ]
}
return fns
.reduce(function (f, g) {
return function () {
return f(g.apply(this, arguments));
};
});
.reduce(function (f, g) {
return function () {
return f(g.apply(this, arguments))
}
})
}
module.exports = compose;
module.exports = compose

@@ -1,14 +0,14 @@

var compose = require('./compose');
var compose = require('./compose')
function decorate() {
var args = Array.prototype.slice.call(arguments, 0);
function decorate () {
var args = Array.prototype.slice.call(arguments, 0)
if (Array.isArray(args[0])) {
args = args[0];
args = args[0]
}
var dec = compose.apply(this, args.slice(0, -1));
return dec(args[args.length - 1]);
var dec = compose.apply(this, args.slice(0, -1))
return dec(args[args.length - 1])
}
module.exports = decorate;
module.exports = decorate

@@ -1,28 +0,26 @@

var defaultLogger = require('../utils/default-logger');
var keyGetter = require('memoize-cache-utils/key-getter');
var LRU = require('little-ds-toolkit/lib/lru-cache');
var keyGetter = require('memoize-cache-utils/key-getter')
var LRU = require('little-ds-toolkit/lib/lru-cache')
function decoratorCacheFactory(wrapper, decorator, getKey, cacheOpts) {
getKey = keyGetter(getKey || function () { return '_default'; });
var lru = new LRU(cacheOpts);
return wrapper(function (func) {
return function () {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var logger = defaultLogger.apply(context);
var cacheKey = getKey.apply(context, args);
function decoratorCacheFactory (wrapper, decorator, getKey, cacheOpts) {
getKey = keyGetter(getKey || function () { return '_default' })
var lru = new LRU(cacheOpts)
return wrapper(function throttle (func) {
return function _throttle () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var cacheKey = getKey.apply(context, args)
if (cacheKey === null) {
return func.apply(context, args);
return func.apply(context, args)
}
var f = lru.get(cacheKey);
var f = lru.get(cacheKey)
if (!f || typeof f !== 'function') {
f = decorator(func);
lru.set(cacheKey, f);
f = decorator(func)
lru.set(cacheKey, f)
}
f.apply(context, args);
};
});
f.apply(context, args)
}
})
}
module.exports = decoratorCacheFactory;
module.exports = decoratorCacheFactory
module.exports = function () {
if (typeof this === 'object' && '__log' in this) {
return this.__log;
return this.__log
}
return function () {};
};
return function () {}
}

@@ -1,30 +0,30 @@

require('setimmediate');
require('setimmediate')
function FunctionBus() {
this.callback_queues = {};
this.onExec = function () {};
function FunctionBus () {
this.callback_queues = {}
this.onExec = function () {}
}
FunctionBus.prototype.queue = function queue(key, cb) {
FunctionBus.prototype.queue = function queue (key, cb) {
if (this.callback_queues[key]) {
this.callback_queues[key].push(cb);
this.callback_queues[key].push(cb)
} else {
this.callback_queues[key] = [cb];
this.callback_queues[key] = [cb]
}
};
}
FunctionBus.prototype.onExecute = function onExecute(func) {
this.onExec = func;
};
FunctionBus.prototype.onExecute = function onExecute (func) {
this.onExec = func
}
FunctionBus.prototype.len = function len(key) {
return key in this.callback_queues ? this.callback_queues[key].length : 0;
};
FunctionBus.prototype.len = function len (key) {
return key in this.callback_queues ? this.callback_queues[key].length : 0
}
FunctionBus.prototype.execute = function execute(key, args) {
var len = this.len(key);
FunctionBus.prototype.execute = function execute (key, args) {
var len = this.len(key)
if (!len) return;
if (!len) return
this.onExec(key, len);
this.onExec(key, len)

@@ -34,9 +34,9 @@ for (var i = 0; i < len; i++) {

return function () {
f.apply(this, args);
};
})(this.callback_queues[key][i]));
f.apply(this, args)
}
})(this.callback_queues[key][i]))
}
delete this.callback_queues[key];
};
delete this.callback_queues[key]
}
module.exports = FunctionBus;
module.exports = FunctionBus

@@ -1,47 +0,47 @@

require('setimmediate');
require('setimmediate')
function Lock() {
this.locked = {};
this.queues = {};
this.timers = {};
function Lock () {
this.locked = {}
this.queues = {}
this.timers = {}
}
Lock.prototype.lock = function (resource, ttl, callback) {
callback = callback || function () {};
var that = this;
callback = callback || function () {}
var that = this
if (resource in this.locked) {
if (!(resource in this.queues)) {
this.queues[resource] = [];
this.queues[resource] = []
}
this.queues[resource].push({ callback: callback, ttl: ttl });
this.queues[resource].push({ callback: callback, ttl: ttl })
} else {
this.locked[resource] = true;
this.locked[resource] = true
this.timers[resource] = setTimeout(function () {
that.unlock(resource, function () {});
}, ttl);
that.unlock(resource, function () {})
}, ttl)
callback(null, { unlock: function (cb) {
that.unlock(resource, cb);
}});
that.unlock(resource, cb)
}})
}
};
}
Lock.prototype.unlock = function (resource, callback) {
callback = callback || function () {};
delete this.locked[resource];
clearTimeout(this.timers[resource]);
delete this.timers[resource];
callback = callback || function () {}
delete this.locked[resource]
clearTimeout(this.timers[resource])
delete this.timers[resource]
var that = this;
var item = (this.queues[resource] || []).shift();
var that = this
var item = (this.queues[resource] || []).shift()
if (item) {
setImmediate(function () {
that.lock(resource, item.ttl, item.callback, callback);
});
that.lock(resource, item.ttl, item.callback, callback)
})
} else {
delete this.queues[resource];
callback(null);
delete this.queues[resource]
callback(null)
}
};
}
module.exports = Lock;
module.exports = Lock

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

var promisify = require('es6-promisify');
module.exports = promisify;
var promisify = require('es6-promisify').promisify
module.exports = promisify
function safe(func) {
return function () {
var context = this;
var args = Array.prototype.slice.call(arguments, 0);
var cb = args[args.length - 1];
var alreadyFired = false;
function safe (func) {
return function _safe () {
var context = this
var args = Array.prototype.slice.call(arguments, 0)
var cb = args[args.length - 1]
var alreadyFired = false
args[args.length - 1] = function (err, res) {
if (alreadyFired) {
throw new Error('Callback fired twice');
throw new Error('Callback fired twice')
} else {
alreadyFired = true
cb(err, res)
}
else {
alreadyFired = true;
cb(err, res);
}
};
}
try {
func.apply(context, args);
}
catch (e) {
func.apply(context, args)
} catch (e) {
if (alreadyFired) {
throw e;
throw e
}
cb(e);
cb(e)
}
};
}
}
module.exports = safe;
module.exports = safe
function callback(output, time) {
var counter = 0;
var timeFunc = typeof time === 'function' ? time : function () { return time; };
var outputFunc = typeof output === 'function' ? output : function () { return output; };
function callback (output, time) {
var counter = 0
var timeFunc = typeof time === 'function' ? time : function () { return time }
var outputFunc = typeof output === 'function' ? output : function () { return output }
return function () {
var args = Array.prototype.slice.call(arguments, 0);
var cb = args[args.length - 1];
counter++;
var args = Array.prototype.slice.call(arguments, 0)
var cb = args[args.length - 1]
counter++
setTimeout((function (c) {
return function () {
var out = outputFunc(c);
var out = outputFunc(c)
if (out instanceof Error) {
cb(out);
cb(out)
} else {
cb(null, out)
}
else {
cb(null, out);
}
};
}(counter)), timeFunc(counter) || 0);
};
}
}(counter)), timeFunc(counter) || 0)
}
}
function promise(output, time) {
var cb = callback(output, time);
function promise (output, time) {
var cb = callback(output, time)
return function () {
return new Promise(function (resolve, reject) {
cb(function (err, res) {
cb(function (err, res) { // eslint-disable-line
if (err) {
reject(err);
reject(err)
} else {
resolve(res)
}
else {
resolve(res);
}
});
});
};
})
})
}
}

@@ -43,2 +41,2 @@

promise: promise
};
}

@@ -1,29 +0,28 @@

var Heap = require('little-ds-toolkit/lib/heap');
var MinMaxHeap = require('little-ds-toolkit/lib/min-max-heap');
var Heap = require('little-ds-toolkit/lib/heap')
var MinMaxHeap = require('little-ds-toolkit/lib/min-max-heap')
function minPriorityComparator(a, b) {
return a.priority - b.priority;
function minPriorityComparator (a, b) {
return a.priority - b.priority
}
function getFunction(item) {
if (!item) return;
function getFunction (item) {
if (!item) return
return function () {
item.func.apply(item.context, item.args);
};
item.func.apply(item.context, item.args)
}
}
function TaskQueueOverflowError(message, item) {
this.name = 'TaskQueueOverflowError';
this.message = message || 'TaskQueueOverflowError';
this.stack = (new Error()).stack;
this.item = item;
function TaskQueueOverflowError (message, item) {
this.name = 'TaskQueueOverflowError'
this.message = message || 'TaskQueueOverflowError'
this.stack = (new Error()).stack
this.item = item
}
TaskQueueOverflowError.prototype = Object.create(Error.prototype);
TaskQueueOverflowError.prototype.constructor = TaskQueueOverflowError;
TaskQueueOverflowError.prototype = Object.create(Error.prototype)
TaskQueueOverflowError.prototype.constructor = TaskQueueOverflowError
function Queue(queueSize) {
this.data = [];
this.queueSize = queueSize;
function Queue (queueSize) {
this.data = []
this.queueSize = queueSize
}

@@ -37,22 +36,22 @@

cb: cb
};
}
if (typeof this.queueSize !== 'undefined' && this.data.length === this.queueSize) {
throw new TaskQueueOverflowError('Queue full', item);
throw new TaskQueueOverflowError('Queue full', item)
}
this.data.push(item);
};
this.data.push(item)
}
Queue.prototype.shift = function () {
var item = this.data.shift();
return getFunction(item);
};
var item = this.data.shift()
return getFunction(item)
}
Queue.prototype.size = function () {
return this.data.length;
};
return this.data.length
}
function PriorityQueue(getPriority) {
this.getPriority = getPriority;
this.heap = new Heap(minPriorityComparator);
function PriorityQueue (getPriority) {
this.getPriority = getPriority
this.heap = new Heap(minPriorityComparator)
}

@@ -66,24 +65,24 @@

cb: cb
};
item.priority = this.getPriority.apply(item.context, item.args);
this.heap.push(item);
};
}
item.priority = this.getPriority.apply(item.context, item.args)
this.heap.push(item)
}
PriorityQueue.prototype.shift = function () {
var item = this.heap.pop();
return getFunction(item);
};
var item = this.heap.pop()
return getFunction(item)
}
PriorityQueue.prototype.size = function () {
return this.heap.size();
};
return this.heap.size()
}
function MinMaxPriorityQueue(getPriority, queueSize) {
this.getPriority = getPriority;
this.heap = new MinMaxHeap(minPriorityComparator);
this.queueSize = queueSize;
function MinMaxPriorityQueue (getPriority, queueSize) {
this.getPriority = getPriority
this.heap = new MinMaxHeap(minPriorityComparator)
this.queueSize = queueSize
}
MinMaxPriorityQueue.prototype.push = function (func, context, args, cb) {
var last;
var last
var item = {

@@ -94,29 +93,29 @@ func: func,

cb: cb
};
item.priority = this.getPriority.apply(item.context, item.args);
this.heap.push(item);
}
item.priority = this.getPriority.apply(item.context, item.args)
this.heap.push(item)
if (this.heap.size() > this.queueSize) {
last = this.heap.popMax();
throw new TaskQueueOverflowError('Queue full', last);
last = this.heap.popMax()
throw new TaskQueueOverflowError('Queue full', last)
}
};
}
MinMaxPriorityQueue.prototype.shift = function () {
var item = this.heap.popMin();
return getFunction(item);
};
var item = this.heap.popMin()
return getFunction(item)
}
MinMaxPriorityQueue.prototype.size = function () {
return this.heap.size();
};
return this.heap.size()
}
function queueFactory(getPriority, queueSize) {
function queueFactory (getPriority, queueSize) {
if (!getPriority) {
return new Queue(queueSize);
return new Queue(queueSize)
}
if (typeof queueSize === 'number' && queueSize !== Infinity) {
return new MinMaxPriorityQueue(getPriority, queueSize);
return new MinMaxPriorityQueue(getPriority, queueSize)
}
return new PriorityQueue(getPriority);
return new PriorityQueue(getPriority)
}

@@ -130,2 +129,2 @@

queueFactory: queueFactory
};
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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