@stdlib/string-split-grapheme-clusters

Split a string by its grapheme cluster breaks.

Usage no npm install needed!

<script type="module">
  import stdlibStringSplitGraphemeClusters from 'https://cdn.skypack.dev/@stdlib/string-split-grapheme-clusters';
</script>

README

splitGraphemeClusters

NPM version Build Status Coverage Status

Split a string by its grapheme cluster breaks.

Installation

npm install @stdlib/string-split-grapheme-clusters

Usage

var splitGraphemeClusters = require( '@stdlib/string-split-grapheme-clusters' );

splitGraphemeClusters( str )

Splits a string by its grapheme cluster breaks.

var out = splitGraphemeClusters( 'café' );
// returns [ 'c', 'a', 'f', 'é' ]

out = splitGraphemeClusters( '🍕🍕🍕' );
// returns [ '🍕', '🍕', '🍕' ]

Examples

var splitGraphemeClusters = require( '@stdlib/string-split-grapheme-clusters' );

var out = splitGraphemeClusters( 'abc' );
// returns [ 'a', 'b', 'c' ]

out = splitGraphemeClusters( 'Iñtërnâtiônàlizætiøn' );
// returns [ 'I', 'ñ', 't', 'ë', 'r', 'n', 'â', 't', 'i', 'ô', 'n', 'à', 'l', 'i', 'z', 'æ', 't', 'i', 'ø', 'n' ]

out = splitGraphemeClusters( '\uD834\uDD1E' );
// returns [ '𝄞' ]

out = splitGraphemeClusters( '! !' );
// returns [ '!', ' ', '!' ]

out = splitGraphemeClusters( '' );
// returns []

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2022. The Stdlib Authors.