Revert "Implement _.pick to simplify serialization (#763)" (#823)

Reason: Performance

- 40x slower slot serialisation using randomised data
- Overall 2-3x slower `graph.serialize()` on a 600 node graph

This reverts commit 77465113cd.
This commit is contained in:
filtered
2025-03-23 03:39:15 +11:00
committed by GitHub
parent 37ab504bdc
commit 5f03d9a3cf
2 changed files with 4 additions and 33 deletions

View File

@@ -3,21 +3,3 @@ export function omitBy<T extends object>(obj: T, predicate: (value: any) => bool
Object.entries(obj).filter(([_key, value]) => !predicate(value)),
) as Partial<T>
}
/**
* Creates an object composed of the picked object properties.
* Similar to lodash's pick function.
* @param obj The source object
* @param keys The property names to pick
* @returns A new object with just the picked properties
*/
export function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {
// Assertion: Required to avoid verbose runtime guards
const picked = {} as Pick<T, K>
for (const key of keys) {
if (key in obj) {
picked[key] = obj[key]
}
}
return picked
}