Installation
Quick Take
Compared to Others
method / program | returns | index system based on |
---|---|---|
String.prototype.indexOf() | ||
String.prototype.indexOf() | index where the first finding starts | code point count |
str-indexes-of | ||
str-indexes-of | array of indexes where each finding starts | code point count |
📦 This package, str-indexes-of-plus | ||
📦 This package, str-indexes-of-plus | array of indexes where each finding starts | grapheme count |
See this article about Unicode, graphemes and code points.
API — strIndexesOfPlus()
The main function strIndexesOfPlus()
is imported like this:
It’s a function which takes three input arguments:
Input argument | Type | Obligatory | Description |
---|---|---|---|
str Type: string Obligatory: yes | |||
str | string | yes | Source string, where to search. |
searchValue Type: string Obligatory: yes | |||
searchValue | string | yes | What to search for. |
fromIndex Type: natural number or zero Obligatory: no | |||
fromIndex | natural number or zero | no | If set, the searching will start from this index. |
Function will return an array of zero or more numbers, each indicating the index of each finding’s first character. Unicode astral characters are counted, as one character-long.
API — version
You can import version
:
Trivia
Roy asked ~Shinnn is it all right to create grapheme-count-based-index alternative of his str-indexes-of
and he said it’s OK.