@stdlib/string
Version:
String manipulation functions.
49 lines (37 loc) • 1.35 kB
Plain Text
{{alias}}( str[, n][, options] )
Removes the last character(s) of a `string`.
Parameters
----------
str: string
Input string.
n: integer (optional)
Number of characters to remove. Default: 1.
options: Object (optional)
Options.
options.mode: string (optional)
Type of characters to remove. The following modes are supported:
- grapheme: grapheme clusters. Appropriate for strings containing visual
characters which can span multiple Unicode code points (e.g., emoji).
- code_point: Unicode code points. Appropriate for strings containing
visual characters which are comprised of more than one Unicode code
unit (e.g., ideographic symbols and punctuation and mathematical
alphanumerics).
- code_unit': UTF-16 code units. Appropriate for strings containing
visual characters drawn from the basic multilingual plane (BMP) (e.g.,
common characters, such as those from the Latin, Greek, and Cyrillic
alphabets).
Default: 'grapheme'.
Returns
-------
out: string
Updated string.
Examples
--------
> var out = {{alias}}( 'beep' )
'bee'
> out = {{alias}}( 'Boop' )
'Boo'
> out = {{alias}}( 'foo bar', 4 )
'foo'
See Also
--------