@loopback/docs
Version:
Documentation for LoopBack 4
35 lines (22 loc) • 1.07 kB
Markdown
---
lang: en
title: 'API docs: context.transformvalueorpromise'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.context.transformvalueorpromise.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/context](./context.md) > [transformValueOrPromise](./context.transformvalueorpromise.md)
## transformValueOrPromise() function
Transform a value or promise with a function that produces a new value or promise
<b>Signature:</b>
```typescript
export declare function transformValueOrPromise<T, V>(valueOrPromise: ValueOrPromise<T>, transformer: (val: T) => ValueOrPromise<V>): ValueOrPromise<V>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| valueOrPromise | <code>ValueOrPromise<T></code> | The value or promise |
| transformer | <code>(val: T) => ValueOrPromise<V></code> | A function that maps the source value to a value or promise |
<b>Returns:</b>
`ValueOrPromise<V>`