str-indexes-of
Like String#indexOf()
, but return all indexes instead of the first one
; ; //=> [0, 1, 2]; //=> [1, 18, 22]
Almost the same module as indexes-of, but:
- only supports
String
explicitly- throws
TypeError
when it takes anArray
- throws
- supports optional
fromIndex
parameter - disallows empty search value
Installation
npm install str-indexes-of
API
import strIndexesOf from 'str-indexes-of';
strIndexesOf(str, searchValue [, fromIndex])
str: string
searchValue: string
(value to search for)
fromIndex: number
(index in the string where to begin searching)
Return: Array
of string
; //=> [0, 4]; //=> [4]
Related project
arr-indexes-of - Array#indexOf()
version