Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Repository files navigation

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

constVariableParser=require('@tmware/variable-parser')constYourParser=newVariableParser()// initialize without data
constYourParser=newVariableParser({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: {})

constYourParser=newVariableParser({someVariable: 3},'[]')constresult=YourParser.parse('[someVariable]')console.log(result)// => '3'// Note: This is still a string

License

Please refer to the LICENSE file.

About

Variable Parser helps you translate in-string variables to preset values.

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages