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.

13 lines (11 loc) 316 B
export const pWhile = async <T>( condition: (value: T | undefined) => boolean, action: () => T | PromiseLike<T> ): Promise<void> => { const loop = async (actionResult: T | undefined): Promise<void> => { if (condition(actionResult)) { return loop(await action()) } } return loop(undefined) }