1.1.4 • Published 1 year ago

josm-interpolate-string v1.1.4

Weekly downloads
40
License
ISC
Repository
github
Last release
1 year ago

Josm interpolate string

Josm string interpolation.

Please not that Josm interpolate string is currently under development and not yet suited for production

Installation

 $ npm i josm-interpolate-string

Usage

Simple. Very simmilar to the native js implementation.

import interpolate from "josm-interpolate-string"

interpolate("Hello ${name}", { userName: "Max" }).get() // Hello Max

With changing values

import { DataBase } from "josm"

const lang = new DataBase({ 
  en: {
    greeting: "Hello",
    user: {
      handle: "Max"
    }
  }
})
 
const data = interpolate("${greeting} ${user.handle}", lang.en)

data.get() // Hello Max
lang.en.user.handle.set("John")
data.get() // Hello John

// or subscribe to changes
data.get((text) => {
  console.log(text) // Hello John [...]
})

Contribute

All feedback is appreciated. Create a pull request or write an issue.

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago