MCPcopy
hub / github.com/loopbackio/loopback-next / transformValueOrPromise

Function transformValueOrPromise

packages/context/src/value-promise.ts:291–300  ·  view source on GitHub ↗
(
  valueOrPromise: ValueOrPromise<T>,
  transformer: (val: T) => ValueOrPromise<V>,
)

Source from the content-addressed store, hash-verified

289 * @param transformer - A function that maps the source value to a value or promise
290 */
291export 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

Callers 10

serviceFunction · 0.90
instantiateClassFunction · 0.90
toProviderMethod · 0.90
getValueOrPromiseMethod · 0.90
invokeNextInterceptorMethod · 0.90
greetFromAllFunction · 0.90
invokeExpressMiddlewareFunction · 0.85

Calls 1

isPromiseLikeFunction · 0.85

Tested by

no test coverage detected