Add initial project files

This commit is contained in:
Igor Martyniuk
2026-09-01 13:03:41 +03:00
parent 22e111bb44
commit 74cb5b6176
1841 changed files with 242819 additions and 30 deletions
+24
View File
@@ -0,0 +1,24 @@
/**
* Pick specified keys from an object.
*
* @param names - An array of keys to pick from the object.
* @param obj - The object from which to pick the keys.
* @returns The new object with the specified keys picked.
*
* @example
* const input = { a: 1, b: 2, c: 3 };
* const pickedKeys = ['a', 'c'];
* const output = pick(pickedKeys, input);
* // output: { a: 1, c: 3 }
*/
export function pick(names: string[], obj: Record<string, unknown>): object {
const result: Record<string, unknown> = {};
let idx = 0;
while (idx < names.length) {
if (names[idx] in obj) result[names[idx]] = obj[names[idx]];
idx += 1;
}
return result;
}