Skip to content

Soup.swig()

github-actions[bot] edited this page Sep 30, 2024 · 2 revisions

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

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


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


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


Stews Docs 🍲

🛈 Stew 🛈 Soup
🛈 Noodle 🛈 random

Clone this wiki locally