MCPcopy Create free account
hub / github.com/Snapchat/Valdi / filterObject

Function filterObject

valdi/vscode_debugger/src/common/objUtils.ts:82–94  ·  view source on GitHub ↗
(
  obj: Readonly<{ [key: string]: T }>,
  predicate: (key: string, value: T) => boolean,
)

Source from the content-addressed store, hash-verified

80 * Filters the object to the key-value pairs where the predicate returns true.
81 */
82export function filterObject<T>(
83 obj: Readonly<{ [key: string]: T }>,
84 predicate: (key: string, value: T) => boolean,
85): { [key: string]: T } {
86 const next: { [key: string]: T } = {};
87 for (const key of Object.keys(obj)) {
88 if (predicate(key, obj[key])) {
89 next[key] = obj[key];
90 }
91 }
92
93 return next;
94}
95
96/**
97 * Sorts the object keys using the given sorting function.

Callers 1

Calls 1

keysMethod · 0.65

Tested by

no test coverage detected