An open API service indexing awesome lists of open source software.

https://github.com/nicomt/varsubst

Simple library to substitute variables into strings
https://github.com/nicomt/varsubst

envsubst substitution variables

Last synced: 3 months ago
JSON representation

Simple library to substitute variables into strings

Awesome Lists containing this project

README

          

# varsubst

> Simple library to substitute variables into strings

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install varsubst
```

## Usage

The API is simple

```js
const varsubst = require('varsubst')

varsubst('hello $var', { var: 'world' }) // hello world
varsubst('inThe${var}OfText', { var: 'Middle' }) // inTheMiddleOfText
varsubst('escaping $${var}', { var: 'noop' }) // escaping ${var}
varsubst('using ${var:-default}', {}) // using default
varsubst('using ${none:-$var} vars', {var: 'nested'}) // using nested vars
varsubst('${USER} is substituting env', process.env) // is substituting env
```