Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/object.js>filterEntries

A JavaScript extension package for building strong and modern applications.
Latest
function filterEntries
import { filterEntries } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/object.js";

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

import { filterEntries } from "@ayonli/jsext/object";

const obj = { foo: "Hello", bar: "World" };
const result = filterEntries(obj, ([key]) => key === "foo");

console.log(result); // { foo: "Hello" }

Parameters

obj
predicate