( valueOrPromise: ValueOrPromise<T>, transformer: (val: T) => ValueOrPromise<V>, )
| 289 | * @param transformer - A function that maps the source value to a value or promise |
| 290 | */ |
| 291 | export function transformValueOrPromise<T, V>( |
| 292 | valueOrPromise: ValueOrPromise<T>, |
| 293 | transformer: (val: T) => ValueOrPromise<V>, |
| 294 | ): ValueOrPromise<V> { |
| 295 | if (isPromiseLike(valueOrPromise)) { |
| 296 | return valueOrPromise.then(transformer); |
| 297 | } else { |
| 298 | return transformer(valueOrPromise); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * A utility to generate uuid v4 |
no test coverage detected