@gehrbeck/gword
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

GWord – The GehrBeck Text Manipulation Helper

Why

We missed some functions in the default strings in JavaScript/TypeScript. That's why this library was created. There will be updates bringing more features soon.

Usage Guide

import using

import {GWord} from '@gehrbeck/gword';

const gword = require('@gehrbeck/gword');

GWord provides a fluent API which means you can chain multiple commands after each other. There are also two ways to create an instance. See following examples for a better understanding.

const instance = new GWord('your-base-string');
GWord.create('your-base-string');

After creating your instance you can call whatever function you like and retrieve the result with the get(); function.

const tag: string = GWord.create('maybeATag').wrapInDiamondBrackets().get();

Functions Overview

Function Description
create(string) Static function to create an instance of GWord.
removeAll(string) Removes all occurrences of a string in the GWord.
replaceAll(target, replacement) Replaces all occurrences of a string with the given replacement.
wrapIn(string) Wraps the GWord in a given string.
wrapInCurlyBrackets() Wraps the GWord in curly brackets.
wrapInDiamondBrackets() Wraps the GWord in diamond brackets.
prefixWith(string) Prefixes the GWord with a given string.
postfixWith(string) Postfixes the Gword with a given string.
escapeHtmlEntities() Escapes the most important html entities.
removeLastChar() Removes the last character
removeFirstChar() Removes the first character
get() Returns the final string after transformation.

Package Sidebar

Install

npm i @gehrbeck/gword

Weekly Downloads

13

Version

1.1.1

License

ISC

Unpacked Size

7.52 kB

Total Files

6

Last publish

Collaborators

  • mrspace