String

GitHub   Edit on GitHub

Utilities for working with strings.

1
import String from 'string'

Values

String.concat

1
concat : (String, String) -> String

Concatenate two strings.

String.length

1
length : String -> Number

Computes the character length of the input string.

String.byteLength

1
byteLength : String -> Number

Returns the byte length of the input string.

String.slice

1
slice : (String, Number, Number) -> String

Get a substring of the input string starting at from up to (but not including) to.

Parameters:

  • input: The input string
  • from: The index where the substring should begin
  • to: The index where the substring should end (not including the character at to)

Returns the substring. If from or to is negative, it is treated as an offset from the end of the input string, i.e. the index plus the length of the string.

String.contains

1
contains : (String, String) -> Bool

Check if a string contains a substring.

Parameters:

  • input: The input string
  • substring: The substring to find

String.startsWith

1
startsWith : (String, String) -> Bool

Check if a string begins with another string.

Parameters:

  • input: The input string
  • substring: The substring to match at the beginning of the input string

String.endsWith

1
endsWith : (String, String) -> Bool

Check if a string ends with another string.

Parameters:

  • input: The input string
  • substring: The substring to match at the end of the input string
This is a notification!