Skip to main content
Go to Latest
function filterEntries
import { filterEntries } from "https://deno.land/std@0.102.0/collections/filter_entries.ts";

Returns a new record with all entries of the given record except the ones that do not match the given predicate

Example:

const menu = {
    'Salad': 11,
    'Soup': 8,
    'Pasta': 13,
}
const myOptions = filterEntries(menu,
    ([ item, price ]) => item !== 'Pasta' && price < 10,
)

console.assert(myOptions === {
    'Soup': 8,
})

Parameters

record: Record<string, T>
predicate: Predicate<[string, T]>

Returns

Record<string, T>