Skip to main content
Module

x/scaffold/src/deps/npm.ts>objectEntries

scaffold your next project with style and 💗
Latest
function objectEntries
import { objectEntries } from "https://deno.land/x/scaffold@0.3.0/src/deps/npm.ts";

A strongly-typed version of Object.entries().

This is useful since Object.entries() always returns an array of Array<[string, T]>. This function returns a strongly-typed array of the entries of the given object.

Examples

Example 1

import {objectEntries} from 'ts-extras';

const stronglyTypedEntries = objectEntries({a: 1, b: 2, c: 3});
//=> Array<['a' | 'b' | 'c', number]>

const untypedEntries = Object.entries(items);
//=> Array<[string, number]>

Type Parameters

Type extends Record<PropertyKey, unknown>

Returns

Array<[ObjectKeys<Type>, Type[ObjectKeys<Type>]]>