Files
codeql-action/node_modules/@sinonjs/commons/lib/every.js
T

27 lines
665 B
JavaScript
Raw Normal View History

2020-06-24 14:33:55 +01:00
"use strict";
/**
* Returns true when fn returns true for all members of obj.
* This is an every implementation that works for all iterables
*
* @param {object} obj
* @param {Function} fn
* @returns {boolean}
*/
module.exports = function every(obj, fn) {
var pass = true;
try {
2021-07-27 22:26:09 +00:00
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
2020-06-24 14:33:55 +01:00
obj.forEach(function() {
if (!fn.apply(this, arguments)) {
// Throwing an error is the only way to break `forEach`
throw new Error();
}
});
} catch (e) {
pass = false;
}
return pass;
};