UNPKG

@segment/analytics-next

Version:

Analytics Next (aka Analytics 2.0) is the latest version of Segment’s JavaScript SDK - enabling you to send your data to any tool without having to learn, test, or use a new API every time.

21 lines (19 loc) 553 B
import { QueryStringParams } from '.' /** * Returns an object containing only the properties prefixed by the input * string. * Ex: prefix('ajs_traits_', { ajs_traits_address: '123 St' }) * will return { address: '123 St' } **/ export function pickPrefix( prefix: string, object: QueryStringParams ): QueryStringParams { return Object.keys(object).reduce((acc: QueryStringParams, key: string) => { if (key.startsWith(prefix)) { const field = key.substr(prefix.length) acc[field] = object[key]! } return acc }, {}) }