0.1.2 • Published 2 years ago

dynamic-string v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Dynamic string

Reuse string interpolation in JavaScript. dynamic-string is a a curried dynamic template string.

You can use it to replace id's in API endpoints, username's in greetings or whatever your imagination leads to :)

Install

yarn add dynamic-string

npm i dynamic-string

Getting started

Import dynamicString from dynamic-string .

import { dynamicTemplate } from 'dynamic-string'

This curried function receives two positional arguments:

  • A string template with '${}' for interpolation
  • An object with the variables to be interpolated as keys.

You can use it directly or not, as in:

const string = dynamicTemplate('https://api.com/${id}', { id: '12101909' }) // https://api.com/12101909

const stringFn = dynamicTemplate('Hey ${name}') // fn ({name}) => `Hey ${name}`

Other examples

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.12

2 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago