From 614e59c6ed7ca2eecffcf0d8dd661cf68e566848 Mon Sep 17 00:00:00 2001 From: Kamaal Farah Date: Sat, 14 Sep 2024 17:53:06 +0200 Subject: [PATCH] Adding to entries --- src/objects/to-entries.ts | 9 +++++++++ src/types/index.ts | 1 + src/types/objects.ts | 3 +++ 3 files changed, 13 insertions(+) create mode 100644 src/objects/to-entries.ts create mode 100644 src/types/objects.ts diff --git a/src/objects/to-entries.ts b/src/objects/to-entries.ts new file mode 100644 index 0000000..d7187f5 --- /dev/null +++ b/src/objects/to-entries.ts @@ -0,0 +1,9 @@ +import type { Entry } from '../types'; + +function toEntries( + object: Target +): Array> { + return Object.entries(object) as Array>; +} + +export default toEntries; diff --git a/src/types/index.ts b/src/types/index.ts index 6b20e56..7a94eca 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,2 +1,3 @@ export * from './strings'; export * from './arrays'; +export * from './objects'; diff --git a/src/types/objects.ts b/src/types/objects.ts new file mode 100644 index 0000000..64d135e --- /dev/null +++ b/src/types/objects.ts @@ -0,0 +1,3 @@ +export type Entry = { + [K in keyof T]: [K, T[K]]; +}[keyof T];