JSPM

josm-interpolate-string

1.1.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q42644F
  • License ISC

Josm string interpolation.

Package Exports

  • josm-interpolate-string
  • josm-interpolate-string/app/dist/josmInterpolateString.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (josm-interpolate-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.