UNPKG

@segment/analytics-core

Version:

This package represents core 'shared' functionality that is shared by analytics packages. This is not designed to be used directly, but internal to analytics-node and analytics-browser.

9 lines (8 loc) 258 B
export const pickBy = <T extends object, K extends keyof T>( obj: T, fn: (key: K, v: T[K]) => boolean ) => { return (Object.keys(obj) as K[]) .filter((k) => fn(k, obj[k])) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {} as Partial<T>) }