1.0.3 • Published 6 years ago

format-string-builder v1.0.3

Weekly downloads
9
License
ISC
Repository
github
Last release
6 years ago

format-string-builder

Simple JS string builder

Installation

npm install format-string-builder

Initialization

var FormatStringBuilder = require("format-string-builder");
const Builder = new FormatStringBuilder();

Functions

constructor(str: string, nl: string)

Sets the string and new line delimiter. If none are supplied, uses empty string and "\n" as delimiter.

const Builder = new FormatStringBuilder("Test string");

append(str: string

Appends the given string to builder.

Builder.append("I forgot this part");

appendLn(str: string)

Appends the given string to builder with a newline.

Builder.appendLn("I am followed by a new line");

format(fullStr: str, arg1: str, arg2: str...)

Replaces placeholders with given arguments.

Builder.format("Hello {0}, my name is {1} {2}", "reader", "Uncle", "Bob");

The string is formatted as:

"Hello reader, my name is Uncle Bob"

clear()

Clears the string.

Builder.clear();

toString()

Returns the built string.

const builtString = Builder.toString();

Properties

newline

Returns the set newline delimiter.

length

Returns the length of the built string.

lines

Returns a split string array.

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago