Page Contents

Home > @loopback/context > transformValueOrPromise

transformValueOrPromise() function

Transform a value or promise with a function that produces a new value or promise

Signature:

export declare function transformValueOrPromise<T, V>(valueOrPromise: ValueOrPromise<T>, transformer: (val: T) => ValueOrPromise<V>): ValueOrPromise<V>;

Parameters

Parameter Type Description
valueOrPromise [ValueOrPromise](/doc/en/lb4/apidocs.context.valueorpromise.html)<T> The value or promise
transformer (val: T) => [ValueOrPromise](/doc/en/lb4/apidocs.context.valueorpromise.html)<V> A function that maps the source value to a value or promise

Returns:

ValueOrPromise<V>