From 6936afdcc4ecb56f34c135c5a3085d1ed4d050b7 Mon Sep 17 00:00:00 2001 From: James P Date: Thu, 18 Apr 2024 14:38:30 -0500 Subject: [PATCH] Fixed default fs import for top-level await --- src/objects.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/objects.ts b/src/objects.ts index 31f7c4e..aae1277 100644 --- a/src/objects.ts +++ b/src/objects.ts @@ -1,15 +1,12 @@ -export function filterObject(object: T, ...keys: K[]): Omit { - const entries = <[K, T[K]][]>Object.entries(object); - return >(Object.fromEntries(entries.filter(([key]) => keys.includes(key)))); -} - import type * as FS from 'fs'; +// default fs for FileMap let _fs: typeof FS; -try { - _fs = await import('fs'); -} catch (e) { - _fs = null; +import('fs').then(_ => (_fs = _)); + +export function filterObject(object: T, ...keys: K[]): Omit { + const entries = <[K, T[K]][]>Object.entries(object); + return >(Object.fromEntries(entries.filter(([key]) => keys.includes(key)))); } export function isJSON(str: string) {