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

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

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

Applies the given transformer to all entries in the given record and returns a new record containing the results.

This function is effectively as Object.fromEntries(Object.entries(obj).map(transformer)).

Examples

Example 1

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

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

console.log(result); // { foo: "HELLO", bar: "WORLD" }

Parameters

obj
transformer