Soup.filterBy() - shysolocup/stews GitHub Wiki

removes entries that don't pass a check function in another object
type: Function

arguments:

  • object Any:
    object to go through
  • checker Function:
    goes through every entry of the given object with the function
    if it returns false it removes that entry in the main soup
    see Soup.forEach() for more info

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


let arr = new Soup([ "abc", "def", "ghi" ]);
let arr2 = new Soup([ 1, 2, 3 ]);


console.log(arr.filterBy( arr2, (v, i) => {
    // if it's equal to 2 remove it
    return v != 2
}));
const { Soup } = require('stews');


let obj = new Soup({ key1: "val1", key2: "val2", key3: "val3" });


console.log(obj.filterBy( obj.values, (k, v, i) => {
    // if it's equal to "val2" remove it
    return v != "val2";
}));
Soup(2) [ "abc", "ghi" ] 
Soup(2) { key1: "val1", key3: "val3" }


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