@stdlib/string
Version:
String manipulation functions.
57 lines (42 loc) • 1.49 kB
Plain Text
{{alias}}( src[, mapFcn[, thisArg]] )
Returns an iterator which iterates from right to left over each grapheme
cluster in a string.
When invoked, an input function is provided three arguments:
- value: grapheme cluster.
- index: iterated value index.
- src: source string.
If an environment supports Symbol.iterator, the returned iterator is
iterable.
If an environment supports Symbol.iterator, the function explicitly does not
invoke a string's `@@iterator` method, regardless of whether this method is
defined. To convert a string to an implementation defined iterator, invoke
this method directly.
Parameters
----------
src: string
String from which to create the iterator.
mapFcn: Function (optional)
Function to invoke for each iterated value.
thisArg: any (optional)
Execution context.
Returns
-------
iterator: Object
Iterator.
iterator.next(): Function
Returns an iterator protocol-compliant object containing the next
iterated value (if one exists) and a boolean flag indicating whether the
iterator is finished.
iterator.return( [value] ): Function
Finishes an iterator and returns a provided value.
Examples
--------
> var it = {{alias}}( '🌷🍕' );
> var v = it.next().value
'🍕'
> v = it.next().value
'🌷'
> var bool = it.next().done
true
See Also
--------