UNPKG

@stdlib/string

Version:

String manipulation functions.

44 lines (33 loc) 1.2 kB
{{alias}}( str[, options] ) Reverses a string. Parameters ---------- str: string Input string. options: Object (optional) Options. options.mode: string (optional) Type of characters to reverse. 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 Reversed string. Examples -------- > var out = {{alias}}( 'foo' ) 'oof' > out = {{alias}}( 'abcdef' ) 'fedcba' See Also --------