-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathpass-any.js
More file actions
27 lines (24 loc) · 726 Bytes
/
pass-any.js
File metadata and controls
27 lines (24 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @module 101/pass-any
*/
var isFunction = require('./is-function');
/**
* Muxes arguments across many functions and ||'s the results
* @function module:101/pass-any
* @param {function} funcs... - functions which return a boolean
* @return {function} function which accepts args which it applies to funcs and ||s the results
*/
module.exports = passAny;
function passAny (/* funcs */) {
var funcs = Array.prototype.slice.call(arguments);
if (!funcs.every(isFunction)) {
throw new TypeError('all funcs should be functions');
}
return function (/* arguments */) {
var args = arguments;
var self = this;
return funcs.some(function (func) {
return func.apply(self, args);
});
};
}