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.

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) }