1.0.6 • Published 2 years ago

@ananay-nag/text-formatter v1.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
2 years ago

TEXT-FORMATTER

@ananay-nag/text-formatter module is a comprehensive nodejs for format text / replace some text with following features:

  • Easy to use API
  • Easy to install

Versions-

@ananay-nag/text-formatter has released version 1.0.5.

It is still able to use v1 with @ananay-nag/text-formatter@1.0.5

// v1.0.5
const formatter = require("@ananay-nag/text-formatter");

Quick Start

Library

Installation

npm i --save @ananay-nag/text-formatter

Text formatter using a Object.

const formatter = require("@ananay-nag/text-formatter");

var user = {
  NAME: "Foo",
  POSITION: "Full Stack Developer",
  COMPANY: "Google"
};

var str = "{NAME} is working as {POSITION} in {COMPANY} company.";

try {
  let result = formatter.doFormatByObject(str, user);
  console.log(result);
  /*{ success: true,
  data: 'Foo is working as Full Stack Developer in Google company.',
  message: 'success',
  code: 200 }*/
} catch (e) {
  console.log(e);
}

Usage -

  • The key name must be same with repalce keyword.
  • The replace key must be in { }.
  • Valids - {_X} , {X_} , {X}
  • In-valids - { X} , { X } , {X }.
  • Space in {}will not be accepted.
  • Object key length must be equal to replace keys in String.