Options
All
  • Public
  • Public/Protected
  • All
Menu

Module source/whitespace

Index

Variables

Variables

Const whitespace

whitespace: { removeAll: (str: string) => string; removeBreaks: (str: string) => string; removeTabs: (str: string) => string; replaceWith: (str: string, toReplace: IReplaceWith, newStr: string, single?: boolean) => string; singleSpace: (str: string) => string } = ...

Type declaration

  • removeAll: (str: string) => string
      • (str: string): string
      • Takes a string, removes all forms of witespace, and returns result

        Basic usage example:

        import {whitespace} from 'stringman' // or const whitespace = require('stringman').whitespace;
        const removed = whitespace.removeAll('this string\n   is gonne be\r a\t jumbled mess   !');
        console.log(removed); // 'thisstringisgonnabeajumbledmess!'
        

        Parameters

        • str: string

        Returns string

  • removeBreaks: (str: string) => string
      • (str: string): string
      • Takes a string and returns that string with all carriage returns and line breaks removed

        Basic usage example:

        import {whitespace} from 'stringman' // or const whitespace = require('stringman').whitespace;
        const removed = whitespace.removeBreaks('this line\n has a\r dumb amount of\n line breaks');
        console.log(removed); // 'this line has a dumb amount of line breaks'
        

        Parameters

        • str: string

        Returns string

  • removeTabs: (str: string) => string
      • (str: string): string
      • Takes a string, removes tabs, and returns result

        Basic usage example:

        import {whitespace} from 'stringman' // or const whitespace = require('stringman').whitespace;
        const removed = whitespace.removeTabs('this line   has some   tabs of \t multiple kinds');
        console.log(removed); // 'this line has some tabs of multiple kinds'
        

        Parameters

        • str: string

        Returns string

  • replaceWith: (str: string, toReplace: IReplaceWith, newStr: string, single?: boolean) => string
      • (str: string, toReplace: IReplaceWith, newStr: string, single?: boolean): string
      • Takes a string, an enumerable object with boolean values to detrermine what will be replaced, another string to replace things, and an optional 4th argument for whether it should be returned with multiple consecutive spaces changed to single spaces with and returns the result of replacing the values designated in the 2nd argument with the contents of the 3 argument

        Basic usage example:

        import {whitespace} from 'stringman' // or const whitespace = require('stringman').whitespace;
        const simple = whitespace.replaceWith('gonna just\n remove breaks\n from this\n', {breaks: true}, ' ' true);
        const goofy = whitespace.replaceWith('gonna   make\t a   \nridiculous example', {tabs: true, breaks: true, multiSpace: true}, '$');
        console.log(simple); // 'gonna just remove breaks from this'
        console.log(goofy); // 'gonna$make$ a$$ridiculous example'
        

        Parameters

        • str: string
        • toReplace: IReplaceWith
        • newStr: string
        • Optional single: boolean

        Returns string

  • singleSpace: (str: string) => string
      • (str: string): string
      • Takes string and replaces any instance of 2 or more consecutive spaces with a single space and returns the result

        Basic usage example:

        import {whitespace} from 'stringman' // or const whitespace = require('stringman').whitespace;
        const single = whitespace.singleSpace('this string  has    a dumb amount  of   extra spaces         !');
        console.log(single); // 'this string has a dumb amount of extra spaces !'
        

        Parameters

        • str: string

        Returns string

Generated using TypeDoc