diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2020-05-23 23:21:09 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-23 23:21:09 +0900 |
| commit | abc296cdcc73d0e039286a9107ea8b36f02ceae3 (patch) | |
| tree | 239105c1d81c9a009cfe2481b8daa2d24d3fe70e /src/prelude/array.ts | |
| parent | Drop support for Node v11, v13 (#6402) (diff) | |
| download | sharkey-abc296cdcc73d0e039286a9107ea8b36f02ceae3.tar.gz sharkey-abc296cdcc73d0e039286a9107ea8b36f02ceae3.tar.bz2 sharkey-abc296cdcc73d0e039286a9107ea8b36f02ceae3.zip | |
refactor: use Object.fromEntries() instead of in-house implementation (#6401)
* refactor: use Object.fromEntries()
instead of in-house implementation
* Remove extra type assertions
Diffstat (limited to 'src/prelude/array.ts')
| -rw-r--r-- | src/prelude/array.ts | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/src/prelude/array.ts b/src/prelude/array.ts index 9e1dfead53..d63f0475d0 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -129,21 +129,6 @@ export function cumulativeSum(xs: number[]): number[] { return ys; } -// Object.fromEntries() -export function fromEntries<T extends readonly (readonly [PropertyKey, any])[]>(xs: T): - T[number] extends infer U - ? - ( - U extends readonly any[] - ? (x: { [_ in U[0]]: U[1] }) => any - : never - ) extends (x: infer V) => any - ? V - : never - : never { - return xs.reduce((obj, [k, v]) => Object.assign(obj, { [k]: v }), {} as { [x: string]: any; }); -} - export function toArray<T>(x: T | T[] | undefined): T[] { return Array.isArray(x) ? x : x != null ? [x] : []; } |