Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface UnderscoreStringStatic

Hierarchy

Index

Methods

camelize

  • camelize(str: string): string

capitalize

  • capitalize(str: string): string

center

  • center(str: string, length: number, padStr?: string): string

chars

  • chars(str: string): any[]

chop

  • chop(str: string, step: number): any[]

classify

  • classify(str: string): string

clean

  • clean(str: string): string

contains

  • contains(str: string, needle: string): boolean

count

  • count(str: string, substr: string): number

dasherize

  • dasherize(str: string): string

endsWith

  • endsWith(value: string, starts: string): boolean

escapeHTML

  • escapeHTML(str: string): string

escapeRegExp

  • escapeRegExp(str: string): string

exports

humanize

  • humanize(str: string): string

include

  • include(str: string, needle: string): boolean

insert

  • insert(str: string, i: number, substr: string): string

isBlank

  • isBlank(str: string): boolean

join

  • join(separator: string, ...args: string[]): string

levenshtein

  • levenshtein(str1: string, str2: string): number

lines

  • lines(str: string): any[]

ljust

  • ljust(str: string, length: number, padStr?: string): string

lpad

  • lpad(str: string, length: number, padStr?: string): string

lrpad

  • lrpad(str: string, length: number, padStr?: string): string

lstrip

  • lstrip(str: string, characters?: string): string

ltrim

  • ltrim(str: string, characters?: string): string

naturalCmp

  • naturalCmp(str1: string, str2: string): number

numberFormat

  • numberFormat(number: number, dec?: number, dsep?: string, tsep?: string): string

pad

  • pad(str: string, length: number, padStr?: string, type?: string): string
  • Pads a string with characters until the total string length is equal to the passed length parameter. By default, pads on the left with the space char (' '). padStr is truncated to a single character if necessary. ('1', 8) => ' 1' ('1', 8, '0') => '00000001' ('1', 8, '0', 'right') => '10000000' ('1', 8, '0', 'both') => '00001000' ('1', 8, 'bleepblorp', 'both') => 'bbbb1bbb'

    Parameters

    • str: string
    • length: number
    • Optional padStr: string
    • Optional type: string

    Returns string

prune

  • prune(str: string, length: number, pruneStr?: string): string

q

  • q(str: string, quoteChar?: string): string

quote

  • quote(str: string, quoteChar?: string): string

repeat

  • repeat(value: string, count: number, separator?: string): string

reverse

  • reverse(str: string): string

rjust

  • rjust(str: string, length: number, padStr?: string): string

rpad

  • rpad(str: string, length: number, padStr?: string): string

rstrip

  • rstrip(str: string, characters?: string): string

rtrim

  • rtrim(str: string, characters?: string): string

slugify

  • slugify(str: string): string

splice

  • splice(str: string, i: number, howmany: number, substr?: string): string

sprintf

  • sprintf(format: string, ...args: any[]): string

startsWith

  • startsWith(str: string, starts: string): boolean

strLeft

  • strLeft(str: string, sep: string): string

strLeftBack

  • strLeftBack(str: string, sep: string): string

strRight

  • strRight(str: string, sep: string): string

strRightBack

  • strRightBack(str: string, sep: string): string

strip

  • strip(str: string, characters?: string): string

stripTags

  • stripTags(str: string): string

succ

  • succ(str: string): string

surround

  • surround(str: string, wrapper: string): string

swapCase

  • swapCase(str: string): string

titleize

  • titleize(str: string): string

toBoolean

  • toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean
  • Turn strings that can be commonly considered as booleans to real booleans. Such as "true", "false", "1" and "0". This function is case insensitive. ('true') => true ('FALSE') => false ('random') => undefined ('truthy', ['truthy'], ['falsy']) => true ('true only at start', [/^true/]) => true

    Parameters

    • str: string
    • Optional trueValues: any[]
    • Optional falseValues: any[]

    Returns boolean

toNumber

  • toNumber(str: string, decimals?: number): number

toSentence

  • toSentence(array: any[], separator?: string, lastSeparator?: string, serial?: boolean): string
  • Join an array into a human readable sentence. (['jQuery', 'Mootools', 'Prototype']) => 'jQuery, Mootools and Prototype' (['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') => 'jQuery, Mootools unt Prototype'

    Parameters

    • array: any[]
    • Optional separator: string
    • Optional lastSeparator: string
    • Optional serial: boolean

    Returns string

toSentenceSerial

  • toSentenceSerial(array: any[], separator?: string, lastSeparator?: string): string

trim

  • trim(str: string, characters?: string): string

truncate

  • truncate(str: string, length: number, truncateStr?: string): string

underscored

  • underscored(str: string): string

unescapeHTML

  • unescapeHTML(str: string): string

unquote

  • unquote(str: string, quoteChar?: string): string

words

  • words(str: string): string[]
  • words(str: string, delimiter: string): string[]
  • words(str: string, delimiter: RegExp): string[]