Stew.chug() - shysolocup/stews GitHub Wiki

checks if every entry passes a given check
alternative to Stew.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 Stew.forEach() for more info

list: pair:
const { Stew } = require('stews');


let arr = new Stew([ "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 { Stew } = require('stews');


let obj = new Stew({ 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


⚠️ **GitHub.com Fallback** ⚠️