strman

by dleitee

master36febeb  created August 4th 2016

other versions

70
Functions

fx
append
  • value
  • appends

Kind
function
Scope
global
Source

Append Strings on Value with spreaded arguments

Arguments:

  1. value

    Initial value

  2. appends

    Spreaded array with strings to append

Returns:

  1. The concatenated string

Playgrounds:

fx
appendArray
  • value
  • append

Kind
function
Scope
global
Source

Append Array of Strings on Value

Arguments:

  1. value

    String initial

  2. append

    Array with strings to append

Returns:

  1. The concatenated string

Playgrounds:

fx
at
  • value
  • index

Kind
function
Scope
global
Source

Get the character at index

Arguments:

  1. value

    The input string

  2. index

    The index for which to extract the character

Returns:

  1. The character at position index

Playgrounds:

fx
base64Decode
  • value

Kind
function
Scope
global
Source

Decodes data encoded with MIME base64

Arguments:

  1. value

    The data to decode.

Returns:

    • The decoded data.

Playgrounds:

fx
base64Encode
  • value

Kind
function
Scope
global
Source

Encodes data with MIME base64. Base64-encoded data takes about 33% more space than the original data.

Arguments:

  1. value

    The data to encode.

Returns:

    • The encoded data.

Playgrounds:

fx
between
  • value
  • start
  • end

Kind
function
Scope
global
Source

Returns array with strings between [start] and [end]

Arguments:

  1. value

    Input string

  2. start

    The start string to look for

  3. end

    The end string to look for

Returns:

  1. An array with all the matches between a pair of start and end

Playgrounds:

fx
binDecode
  • value

Kind
function
Scope
global
Source

Convert binary unicode (16 digits) string to string chars

Arguments:

  1. value

    Value to decode

Returns:

    • String decoded.

Playgrounds:

fx
binEncode
  • value

Kind
function
Scope
global
Source

Convert string chars to binary unicode (16 digits)

Arguments:

  1. value

    Value to encode

Returns:

    • String in binary format.

Playgrounds:

fx
chars
  • value

Kind
function
Scope
global
Source

Returns an array consisting of the characters in the string.

Arguments:

  1. value

    The input string

Returns:

  1. The array with the single characters of value

Playgrounds:

fx
collapseWhitespace
  • value

Kind
function
Scope
global
Source

Replaces consecutive whitespace characters with a single space

Arguments:

  1. value

    The input string

Returns:

  1. The whitespace collapsed string

Playgrounds:

fx
compare
  • stringA
  • stringB

Kind
function
Scope
global
Source

Compares two strings to each other. If they are equivalent, a zero is returned. Otherwise, most of these routines will return a positive or negative result corresponding to whether stringA is lexicographically greater than, or less than, respectively, than stringB.

Arguments:

  1. stringA

    String for the comparative

  2. stringB

    String to be compared

Returns:

    • +1 if [stringA] > [stringB], -1 if [stringA] < [stringB] and 0 if [stringA] = [stringB]

Playgrounds:

fx
contains
  • value
  • needle
  • caseSensitive

Kind
function
Scope
global
Source

Verifies that the needle is contained in value

Arguments:

  1. value

    The input string

  2. needle

    The string which is checked to be contained within value

  3. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching

Returns:

  1. True if needle is contained

Playgrounds:

fx
containsAll
  • value
  • needles
  • caseSensitive

Kind
function
Scope
global
Source

Verifies that all needles are contained in value

Arguments:

  1. value

    The input string

  2. needles

    An array of strings which are checked to be contained within value

  3. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching

Returns:

  1. True if all needles are contained

Playgrounds:

fx
containsAny
  • value
  • needles
  • caseSensitive

Kind
function
Scope
global
Source

Verifies that one or more of needles are contained in value

Arguments:

  1. value

    The input string

  2. needles

    An array of string which are checked to be contained within value

  3. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching

Returns:

  1. True if at least one of needles is contained

Playgrounds:

fx
countSubstr
  • value
  • substr
  • caseSensitive
  • allowOverlapping

Kind
function
Scope
global
Source

Count the number of times substr appears in value

Arguments:

  1. value

    The input string

  2. substr

    The substring to look for

  3. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching

  4. allowOverlappingoptional, default: false

    Allow overlapping substrings to be counted

Returns:

  1. The number of matches

Playgrounds:

fx
decDecode
  • value

Kind
function
Scope
global
Source

Convert binary unicode (16 digits) string to string chars

Arguments:

  1. value

    Value to decode

Returns:

    • String decoded.

Playgrounds:

fx
decEncode
  • value

Kind
function
Scope
global
Source

Convert string chars to decimal unicode (5 digits)

Arguments:

  1. value

    Value to encode

Returns:

    • String in decimal format.

Playgrounds:

fx
endsWith
  • value
  • search
  • position
  • caseSensitive

Kind
function
Scope
global
Source

Test if value ends with search

Arguments:

  1. value

    The input string

  2. search

    The string to search for

  3. positionoptional

    The start position/index within value to start searching

  4. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching

Returns:

  1. True if input ends with search

Playgrounds:

fx
ensureLeft
  • value
  • substr
  • caseSensitive

Kind
function
Scope
global
Source

Ensures that the value begins with substr. If it doesn't, it's prepended.

Arguments:

  1. value

    The input string

  2. substr

    The substr to be ensured to be left

  3. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching for determining if value already starts with substr

Returns:

  1. The string which is guarenteed to start with substr

Playgrounds:

fx
ensureRight
  • value
  • substr
  • caseSensitive

Kind
function
Scope
global
Source

Ensures that the [value] ends with [substr]. If it doesn't, it's appended.

Arguments:

  1. value

    The input string

  2. substr

    The substr to be ensured to be right

  3. caseSensitiveoptional, default: true

    Use case (in-)sensitive matching for determining if value already ends with substr

Returns:

  1. The string which is guarenteed to start with substr

Playgrounds:

fx
equal
  • stringA
  • stringB

Kind
function
Scope
global
Source

Tests if two strings are equal.

Arguments:

  1. stringA

    String for the comparative

  2. stringB

    String to be compared

Returns:

    • [stringA] is equal [stringB]

Playgrounds:

fx
first
  • value
  • n

Kind
function
Scope
global
Source

Return the first 'n' chars of string.

Arguments:

  1. value

    The String!.

  2. n

    Number of chars to return.

Returns:

    • Return 'n' firsts chars.

Playgrounds:

fx
format
  • value
  • params

Kind
function
Scope
global
Source

Formats a string using parameters.

Arguments:

  1. value

    Value that will be formatted.

  2. params

    Array with the parameters described in the string.

Returns:

    • Formatted string.

Playgrounds:

fx
hexDecode
  • value

Kind
function
Scope
global
Source

Convert hexadecimal unicode (4 digits) string to string chars

Arguments:

  1. value

    Value to decode

Returns:

    • String decoded.

Playgrounds:

fx
hexEncode
  • value

Kind
function
Scope
global
Source

Convert string chars to hexadecimal unicode (4 digits)

Arguments:

  1. value

    Value to encode

Returns:

    • String in hexadecimal format.

Playgrounds:

fx
htmlDecode

    Kind
    function
    Scope
    global
    Source

    Convert all HTML entities to applicable characters.

    Returns:

      • The decoded data.

    Playgrounds:

    fx
    htmlEncode

      Kind
      function
      Scope
      global
      Source

      Convert all applicable characters to HTML entities.

      Returns:

        • The encoded data.

      Playgrounds:

      fx
      indexOf
      • value
      • needle
      • offset
      • caseSensitive

      Kind
      function
      Scope
      global
      Source

      The indexOf() method returns the index within the calling String of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.

      Arguments:

      1. value

        The String!.

      2. needle

        Value to search.

      3. offset

        Offset to search.

      4. caseSensitive

        if you use caseSensitive to test.

      Returns:

        • Return position of the first occurrence of 'needle'.

      Playgrounds:

      fx
      inequal
      • stringA
      • stringB

      Kind
      function
      Scope
      global
      Source

      Tests if two strings are inequal.

      Arguments:

      1. stringA

        String for the comparative

      2. stringB

        String to be compared

      Returns:

        • [stringA] is inequal [stringB]

      Playgrounds:

      fx
      insert
      • value
      • _substr
      • index

      Kind
      function
      Scope
      global
      Source

      Inserts 'substr' into the 'value' at the 'index' provided.

      Arguments:

      1. value

        The String!.

      2. _substr

        Value to insert.

      3. index

        Index to insert substr.

      Returns:

        • String with substr added.

      Playgrounds:

      fx
      isLowerCase
      • value

      Kind
      function
      Scope
      global
      Source

      Verify if has lowerCase

      Arguments:

      1. value

        The String!.

      Returns:

        • String is lowercase?.

      Playgrounds:

      fx
      isString
      • value

      Kind
      function
      Scope
      global
      Source

      Checks whether a string.

      Arguments:

      1. value

        The String!.

      Returns:

        • if 'value' isString, return true, else false.

      Playgrounds:

      fx
      isUpperCase
      • value

      Kind
      function
      Scope
      global
      Source

      Verify if has UPPERCASE

      Arguments:

      1. value

        The String!.

      Returns:

        • String is UPPERCASE?.

      Playgrounds:

      fx
      last
      • value
      • n

      Kind
      function
      Scope
      global
      Source

      Return the last 'n' chars of string.

      Arguments:

      1. value

        The String!.

      2. n

        Number of chars to return.

      Returns:

        • Return 'n' lasts chars.

      Playgrounds:

      fx
      lastIndexOf
      • value
      • needle
      • offset
      • caseSensitive

      Kind
      function
      Scope
      global
      Source

      The lastIndexOf() method returns the index within the calling String object of the last occurrence of the specified value, searching backwards from fromIndex. Returns -1 if the value is not found.

      Arguments:

      1. value

        The String!.

      2. needle

        Value to search.

      3. offset

        Offset to search.

      4. caseSensitive

        if you use caseSensitive to test.

      Returns:

        • Return position of the last occurrence of 'needle'.

      Playgrounds:

      fx
      leftPad
      • value
      • _length
      • char

      Kind
      function
      Scope
      global
      Source

      Returns a new string of a given length such that the beginning of the string is padded.

      Arguments:

      1. value

        The String!.

      2. _length

        Max length of String.

      3. char

        Char to repeat.

      Returns:

        • String pad.

      Playgrounds:

      fx
      leftTrim
      • value

      Kind
      function
      Scope
      global
      Source

      Remove all spaces on left.

      Arguments:

      1. value

        The String!.

      Returns:

        • String without left boarders spaces.

      Playgrounds:

      fx
      length
      • value

      Kind
      function
      Scope
      global
      Source

      Returns the length of the string.

      Arguments:

      1. value

        The String!.

      Returns:

        • Length of the string..

      Playgrounds:

      fx
      prepend
      • value
      • prepends

      Kind
      function
      Scope
      global
      Source

      Returns a new string starting with 'prepends'.

      Arguments:

      1. value

        The String!.

      2. prepends

        Strings to prepend.

      Returns:

        • The String prepended!

      Playgrounds:

      fx
      prependArray
      • value
      • prepends

      Kind
      function
      Scope
      global
      Source

      Returns a new string starting with 'prepends'.

      Arguments:

      1. value

        The String!.

      2. prepends

        Strings to prepend.

      Returns:

        • The String prepended!

      Playgrounds:

      fx
      removeEmptyStrings
      • strings

      Kind
      function
      Scope
      global
      Source

      Remove empty strings from strings array.

      Arguments:

      1. strings

        Array of strings that will be cleaned.

      Returns:

        • Array of strings without empty strings.

      Playgrounds:

      fx
      removeLeft
      • value
      • prefix
      • caseSensitive

      Kind
      function
      Scope
      global
      Source

      Returns a new string with the 'prefix' removed, if present.

      Arguments:

      1. value

        The String!.

      2. prefix

        String to remove on left.

      3. caseSensitive

        If you need to caseSensitive.

      Returns:

        • The String without prefix!

      Playgrounds:

      fx
      removeNonWords
      • value
      • replaced

      Kind
      function
      Scope
      global
      Source

      Remove all non word characters.

      Arguments:

      1. value

        The String!.

      2. replaced

        Value to replace.

      Returns:

        • String without non word characters.

      Playgrounds:

      fx
      removeRight
      • value
      • suffix
      • caseSensitive

      Kind
      function
      Scope
      global
      Source

      Returns a new string with the 'suffix' removed, if present.

      Arguments:

      1. value

        The String!.

      2. suffix

        String to remove on right.

      3. caseSensitive

        If you need to caseSensitive.

      Returns:

        • The String without suffix!

      Playgrounds:

      fx
      removeSpaces
      • value
      • replaced

      Kind
      function
      Scope
      global
      Source

      Remove all spaces and replace for value.

      Arguments:

      1. value

        The String!.

      2. replaced

        Value to replace.

      Returns:

        • String without spaces.

      Playgrounds:

      fx
      repeat
      • value
      • multiplier

      Kind
      function
      Scope
      global
      Source

      Returns a repeated string given a multiplier.

      Arguments:

      1. value

        The String!.

      2. multiplier

        Number of repeats.

      Returns:

        • The String repeated!

      Playgrounds:

      fx
      replace
      • value
      • search
      • newvalue
      • caseSensitive
      • multiline

      Kind
      function
      Scope
      global
      Source

      Replace all ocurrences of 'search' value to 'newvalue'. var replace = require('strman').replace; let title = "superman"; let result = replace(title, 'upe', 't');

      Arguments:

      1. value

        The String!.

      2. search

        String to search.

      3. newvalue

        String to replace.

      4. caseSensitive

        if you use caseSensitive replace.

      5. multiline

        if you use multiline replace.

      Returns:

        • String replaced with 'newvalue'.

      fx
      reverse
      • value

      Kind
      function
      Scope
      global
      Source

      Returns a reversed string.

      Arguments:

      1. value

        The String!.

      Returns:

        • The String reversed!

      Playgrounds:

      fx
      rightPad
      • value
      • _length
      • char

      Kind
      function
      Scope
      global
      Source

      Returns a new string of a given length such that the ending of the string is padded.

      Arguments:

      1. value

        The String!.

      2. _length

        Max length of String.

      3. char

        Char to repeat.

      Returns:

        • String pad.

      Playgrounds:

      fx
      rightTrim
      • value

      Kind
      function
      Scope
      global
      Source

      Remove all spaces on right.

      Arguments:

      1. value

        The String!.

      Returns:

        • String without right boarders spaces.

      Playgrounds:

      fx
      safeTruncate
      • value
      • _length
      • _append

      Kind
      function
      Scope
      global
      Source

      Truncate the string securely, not cutting a word in half. It always returns the last full word.

      Arguments:

      1. value

        Value will be truncated securely.

      2. _length

        Max size of the returned string.

      3. _appendoptional, default: ''

        Value that will be added to the end of the return string. Example: '...'

      Returns:

        • String truncated safely.

      Playgrounds:

      fx
      shuffle
      • value

      Kind
      function
      Scope
      global
      Source

      It returns a string with its characters in random order.

      Arguments:

      1. value

        The String!.

      Returns:

        • The String shuffled!

      Playgrounds:

      fx
      slice
      • value
      • beginSlice
      • endSlice

      Kind
      function
      Scope
      global
      Source

      Alias to slice method.

      Arguments:

      1. value

        The String!.

      2. beginSlice

        Start of slice.

      3. endSlice

        End of slice.

      Returns:

        • The String sliced!

      Playgrounds:

      fx
      slugify
      • value

      Kind
      function
      Scope
      global

      Converts a value to a slug.

      Arguments:

      1. value

        The value to slugify

      Returns:

        • The slugified value

      Playgrounds:

      fx
      split
      • value
      • separator
      • limit

      Kind
      function
      Scope
      global
      Source

      Alias to split function.

      Arguments:

      1. value

        The String!.

      2. separator

        Split separator.

      3. limit

        Split limit.

      Returns:

        • The String splited!

      Playgrounds:

      fx
      startsWith
      • value
      • search
      • position
      • caseSensitive

      Kind
      function
      Scope
      global
      Source

      Test if 'value' starts with 'search'

      Arguments:

      1. value

        The String!.

      2. search

        Value to search.

      3. position

        offset to search.

      4. caseSensitive

        if you use caseSensitive to test.

      Returns:

        • If 'value' startsWith 'search' return true, else false.

      Playgrounds:

      fx
      substr
      • value
      • start
      • _length

      Kind
      function
      Scope
      global
      Source

      Alias to substr function.

      Arguments:

      1. value

        The String!.

      2. start

        Substring starts.

      3. _length

        Substring length.

      Returns:

        • The Substring!

      Playgrounds:

      fx
      surround
      • value
      • _substr
      • _substrRight

      Kind
      function
      Scope
      global
      Source

      Surrounds a 'value' with the given 'substr'.

      Arguments:

      1. value

        The String!.

      2. _substr

        The substr to append on left, if substrRight is null, this is appended in right.

      3. _substrRight

        The substr to append on right.

      Returns:

        • The String with surround substrs!

      Playgrounds:

      fx
      toCamelCase
      • value

      Kind
      function
      Scope
      global
      Source

      Transform to camelCase.

      Arguments:

      1. value

        The String!.

      Returns:

        • String in camelCase.

      Playgrounds:

      fx
      toDecamelize
      • value

      Kind
      function
      Scope
      global
      Source

      Decamelize String

      Arguments:

      1. value

        The String!.

      Returns:

        • String decamelized.

      Playgrounds:

      fx
      toKebabCase
      • value

      Kind
      function
      Scope
      global
      Source

      Transform to kebab-case.

      Arguments:

      1. value

        The String!.

      Returns:

        • String in kebab-case.

      Playgrounds:

      fx
      toLowerCase
      • value

      Kind
      function
      Scope
      global
      Source

      Transform to lowercase.

      Arguments:

      1. value

        The String!.

      Returns:

        • String in lowercase.

      Playgrounds:

      fx
      toSnakeCase
      • value

      Kind
      function
      Scope
      global
      Source

      Transform to snake_case.

      Arguments:

      1. value

        The String!.

      Returns:

        • String in snake_case.

      Playgrounds:

      fx
      toStudlyCaps
      • value

      Kind
      function
      Scope
      global
      Source

      Transform to StudlyCaps.

      Arguments:

      1. value

        The String!.

      Returns:

        • String in StudlyCaps.

      Playgrounds:

      fx
      toUpperCase
      • value

      Kind
      function
      Scope
      global
      Source

      Transform to uppercase.

      Arguments:

      1. value

        The String!.

      Returns:

        • String in uppercase.

      Playgrounds:

      fx
      transliterate
      • value

      Kind
      function
      Scope
      global
      Source

      Remove all non valid characters. Example: change á => a or αΊ½ => e.

      Arguments:

      1. value

        The String!.

      Returns:

        • String without non valid characters.

      Playgrounds:

      fx
      trim

        Kind
        function
        Scope
        global
        Source

        Remove all spaces on left and right.

        Returns:

          • String without boarders spaces.

        Playgrounds:

        fx
        truncate
        • value
        • _length
        • _append

        Kind
        function
        Scope
        global
        Source

        Truncate the unsecured form string, cutting the independent string of required position.

        Arguments:

        1. value

          Value will be truncated unsecurely.

        2. _length

          Size of the returned string.

        3. _appendoptional, default: ''

          Value that will be added to the end of the return string. Example: '...'

        Returns:

          • String truncated unsafely.

        Playgrounds:

        fx
        urlDecode
        • value

        Kind
        function
        Scope
        global
        Source

        Decodes URL-encoded string

        Arguments:

        1. value

          The string to be decoded

        Returns:

          • Returns the decoded string.

        Playgrounds:

        fx
        urlEncode
        • value

        Kind
        function
        Scope
        global
        Source

        Replaces all characters with the appropriate UTF-8 escape sequences.

        Arguments:

        1. value

          The string to be encoded

        Returns:

          • Returns a string in which all non-alphanumeric characters except -_.

        Playgrounds: