Skip to content

Commit

Permalink
Adding to entries
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaal111 committed Sep 14, 2024
1 parent efe6b67 commit 614e59c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/objects/to-entries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Entry } from '../types';

function toEntries<Target extends object>(
object: Target
): Array<Entry<Target>> {
return Object.entries(object) as Array<Entry<Target>>;
}

export default toEntries;
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './strings';
export * from './arrays';
export * from './objects';
3 changes: 3 additions & 0 deletions src/types/objects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type Entry<T> = {
[K in keyof T]: [K, T[K]];
}[keyof T];

0 comments on commit 614e59c

Please sign in to comment.