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