1.2.2 • Published 3 years ago

@tmware/variable-parser v1.2.2

Weekly downloads
31
License
MIT
Repository
github
Last release
3 years ago

Variable Parser

Variable Parser helps you translate in-string variables (i.e. {something} like this, where something would be a variable) to values.

Getting Started

Installation

With npm: npm install --save @tmware/variable-parser

With yarn: yarn add @tmware/variable-parser

Usage

const VariableParser = require('@tmware/variable-parser')

const YourParser = new VariableParser() // initialize without data
const YourParser = new VariableParser({
  testVariable: 'World',
  anotherOne: 'Hello',
  someNumber: 69
})
// initialize with data
console.log(
  YourParser.parse(
    '{anotherOne} {testVariable}! some text to show you that this works. {someNumber}'
  )
)
// => 'Hello World! some text to show you that this works. 69'

More advanced examples

Custom indicators (those things around the variables. default: {})

const YourParser = new VariableParser({ someVariable: 3 }, '[]')

const result = YourParser.parse('[someVariable]')

console.log(result)
// => '3'
// Note: This is still a string

License

Please refer to the LICENSE file.

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.0.2

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago