@mikesven/re_place_er
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

RE_PLACE_ER

re_place_er is a simple tool for replacing tokens in a string with their corresponding values. It provides a function that takes a source string and a list of replacements, and returns a new string with the tokens replaced.

Installation

You can install Token Replacer using npm:

npm install @mikesven/re_place_er

Usage

To use Token Replacer, you need to create a ReplacerJob object that contains the source string and a list of replacements. Each replacement is a key-value pair, where the key is the token to be replaced and the value is the replacement value.

import {
  re_place_er,
  ReplacerOptions,
  Replacement,
} from "@mikesven/re_place_er";

const source = "Hello, {{name}}! Your age is {{age}}.";
const replacements: Replacement[] = [
  { name: "John", age: 30 },
  { name: "Jane", age: 25 },
];

const options: ReplacerOptions = {
  openToken: "{{",
  endToken: "}}",
  job: { source, replacements },
};

const result = re_place_er(options);
console.log(result);

This will output:

['Hello, John! Your age is 30.', 'Hello, Jane! Your age is 25.']

Readme

Keywords

none

Package Sidebar

Install

npm i @mikesven/re_place_er

Weekly Downloads

39

Version

0.0.3

License

Unlicense

Unpacked Size

16.9 kB

Total Files

17

Last publish

Collaborators

  • mikesven