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

x/ayonli_jsext/esm/object/index.js>partitionEntries

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

Returns a tuple of two records with the first one containing all entries of the given record that match the given predicate and the second one containing all that do not.

Examples

Example 1

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

const obj = { foo: "Hello", bar: "World" };
const [match, rest] = partitionEntries(obj, ([key]) => key === "foo");

console.log(match); // { foo: "Hello" }
console.log(rest); // { bar: "World" }

Parameters

record
predicate