Soup.filter() - shysolocup/stews GitHub Wiki

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

arguments:

  • checker Function:
    goes through every entry with the function
    if it returns false it removes that entry
    see Soup.forEach() for more info

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


let arr = new Soup([ "abc", "def", "abcdef" ]);


console.log(arr.filter( (v, i) => {
    // if it doesn't include "abc" remove it
    return v.includes("abc");
}));
const { Soup } = require('stews');


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


console.log(obj.filter( (k, v, i) => {
    // if it doesn't include "val" remove it
    return v.includes("val");
}));
Soup(2) [ "abc", "abcdef" ] 
Soup(2) { key1: "val1", key2: "valA" }


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