# ut-function.interpolate

> Interpolation function

Latest version **1.1.3** (published 2020-11-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ut-function.interpolate
pnpm add ut-function.interpolate
yarn add ut-function.interpolate
bun add ut-function.interpolate
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2020-11-15 |
| First published | 2019-11-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | kalin.krustev |

## Links

- npm: https://www.npmjs.com/package/ut-function.interpolate
- Repository: https://github.com/softwaregroup-bg/ut-function
- Homepage: https://github.com/softwaregroup-bg/ut-function#readme
- Issues: https://github.com/softwaregroup-bg/ut-function/issues
- npm.io page: https://npm.io/package/ut-function.interpolate

## Dependencies (1)

- [dot-prop](https://npm.io/package/dot-prop.md) 6.0.0

## Recent versions

- 1.1.3 (latest) — 2020-11-15
- 1.1.2 — 2020-02-25
- 1.1.1 — 2020-01-15
- 1.1.0 — 2019-11-19

## README

# ut-function.interpolate

function signature:

`interpolate(what, params, inline, matcher)`

* `what` [required] - what to be interpolated `string`, `object` or `array`
* `params` [required] - interpolation data source
* `inline` [optional] (default true) - whether the interpolation to be inline or
  not. E.g. `{x}` with params `{x: true}` will become `"true"` if inline or
  `true` otherwise
* `matcher` [optional] (default `/{([^}]+)}/g`) - the interpolation matcher

Examples:

```js
const result = interpolate("x {y} z", {"y":"y"});
// result = "x y z"
```

```js
const result = interpolate("x {y} z", {});
// result = "x {y} z"
```

```js
const result = interpolate("x {y.y} z", {"y":{"y":"y"}});
// result = "x y z"
```

```js
const result = interpolate("x {{y}} z", {"y":"y"}, true, /{{([^}]+)}}/g);
// result = "x y z"
```

```js
const result = interpolate("{x}", {"x":true}, false);
// result = true
```

```js
const result = interpolate("{x}", {}, false);
// result = "{x}"
```

```js
const result = interpolate("{x.y}", {"x":{"y":{"z":true}}}, false);
// result = {"z":true}
```

```js
const result = interpolate({"x":{"y":"x {y} z"}}, {"y":"y"});
// result = {"x":{"y":"x y z"}}
```

```js
const result = interpolate([{"x":{"y":"x {y} z"}}], {"y":"y"});
// result = [{"x":{"y":"x y z"}}]
```

```js
const result = interpolate({"x":{"y":"{y}"}}, {"y":true}, false);
// result = {"x":{"y":true}}
```

```js
const result = interpolate([{"x":{"y":"{y}"}}], {"y":true}, false);
// result = [{"x":{"y":true}}]
```

---
_Source: https://npm.io/package/ut-function.interpolate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
