Soup.chug() - shysolocup/stews GitHub Wiki
checks if every entry passes a given check
alternative to Soup.swig()
type: Function
alt names:
- every()
arguments:
- checker
Function
:
goes through every entry with the function
if it returns false then the chug returns false
see Soup.forEach() for more info
list: | pair: |
const { Soup } = require('stews');
let arr = new Soup([ "abc", 123 ]);
console.log(arr.chug( (v, i) => {
// returns false because not every entry is number
return typeof v == "number";
}));
console.log(arr.chug( (v, i) => {
// returns true because every entry is not an object
return typeof v != "object";
})); |
const { Soup } = require('stews');
let obj = new Soup({ key1: "abc", key2: 123 });
console.log(obj.chug( (k, v, i) => {
// returns false because not every value is a number
return typeof v == "number";
}));
console.log(obj.chug( (k, v, i) => {
// returns true because every value is not an object
return typeof v != "object";
})); |
false
true |
false
true |