1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-15 13:36:35 +02:00

Added function to filter object keys

This commit is contained in:
Maciej Lenartowicz
2019-09-26 09:39:07 +02:00
parent 8296c6129e
commit 497a1a0ad3
3 changed files with 10 additions and 2 deletions

View File

@ -18,3 +18,11 @@ export function withoutUndefinedKeys(instance) {
{},
);
}
/** Return copy of passed object that has only desired keys. */
export function onlySpecifiedKeys(object, desiredKeys) {
return desiredKeys.reduce(
(accumulator, key) => { accumulator[key] = object[key]; return accumulator; },
{},
);
}