diff options
Diffstat (limited to 'shared/core-utils')
-rw-r--r-- | shared/core-utils/index.ts | 1 | ||||
-rw-r--r-- | shared/core-utils/utils/index.ts | 1 | ||||
-rw-r--r-- | shared/core-utils/utils/object.ts | 15 |
3 files changed, 17 insertions, 0 deletions
diff --git a/shared/core-utils/index.ts b/shared/core-utils/index.ts index 66d50ef93..2a7d4d982 100644 --- a/shared/core-utils/index.ts +++ b/shared/core-utils/index.ts | |||
@@ -4,3 +4,4 @@ export * from './i18n' | |||
4 | export * from './plugins' | 4 | export * from './plugins' |
5 | export * from './renderer' | 5 | export * from './renderer' |
6 | export * from './users' | 6 | export * from './users' |
7 | export * from './utils' | ||
diff --git a/shared/core-utils/utils/index.ts b/shared/core-utils/utils/index.ts new file mode 100644 index 000000000..a71977d88 --- /dev/null +++ b/shared/core-utils/utils/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './object' | |||
diff --git a/shared/core-utils/utils/object.ts b/shared/core-utils/utils/object.ts new file mode 100644 index 000000000..7b2bb81d0 --- /dev/null +++ b/shared/core-utils/utils/object.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | function pick <T extends object> (object: T, keys: (keyof T)[]) { | ||
2 | const result: Partial<T> = {} | ||
3 | |||
4 | for (const key of keys) { | ||
5 | if (Object.prototype.hasOwnProperty.call(object, key)) { | ||
6 | result[key] = object[key] | ||
7 | } | ||
8 | } | ||
9 | |||
10 | return result | ||
11 | } | ||
12 | |||
13 | export { | ||
14 | pick | ||
15 | } | ||