import { filterEntries } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";
Returns a new record with all entries of the given record except the ones that do not match the given predicate.
This function is effectively as
Object.fromEntries(Object.entries(obj).filter(predicate))
.
Examples
Example 1
Example 1
import { filterEntries } from "@ayonli/jsext/object";
const obj = { foo: "Hello", bar: "World" };
const result = filterEntries(obj, ([key]) => key === "foo");
console.log(result); // { foo: "Hello" }