@dash0/sdk-web
Version:
Dash0's Web SDK to collect telemetry from end-users' web browsers
18 lines (17 loc) • 550 B
JavaScript
/**
* Creates a new object by picking specified properties from the source object.
* Similar to TypeScript's Pick<T, K> utility type but as a runtime function.
*
* @param obj - The source object to pick properties from
* @param keys - Array of property keys to pick from the source object
* @returns A new object containing only the specified properties
*/
export function pick(obj, keys) {
const result = {};
for (const key of keys) {
if (key in obj) {
result[key] = obj[key];
}
}
return result;
}