Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-db/src/utils.ts
2497 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
export function filter(
8
obj: { [key: string]: any },
9
predicate: (key: string, value: any) => boolean,
10
): { [key: string]: any } {
11
const result = Object.create({}); // typeorm doesn't like Object.create(null)
12
for (const [key, value] of Object.entries(obj)) {
13
if (predicate(key, value)) {
14
result[key] = value;
15
}
16
}
17
return result;
18
}
19
20