Stew.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 Stew.forEach() for more info

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


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


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


let obj = new Stew({ 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");
}));
Stew(2) [ "abc", "abcdef" ] 
Stew(2) { key1: "val1", key2: "valA" }


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