Package Exports
- indicesof
 
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (indicesof) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
js-indicesof
Just like indexOf(), but returns an array of all occurrences.
Will return an empty array if there is no match.
Install
npm i indicesofSyntax
function (needle, haystack, startOffset, endOffset ]);haystackcan be a string or a buffer.startOffsetis optional. Default is 0.endOffsetis optional. Default is the haystack length. Note that the entire length of the needle must be within the offsets to be a match. Also, the offset is not inclusive.
Strings vs Buffers
Note that the byte position is returned for Buffers, which might not be the same as the char position for strings:
indicesOf('l', 'Älg'); // Returns [ 1 ]
indicesOf('l', Buffer.from('Älg', 'utf8')); // Returns [ 2 ]Example
var indicesOf = require('indicesof');
var haystack = "If I Can't Dance It's Not My Revolution";
indicesOf('n', haystack); // [ 7, 13, 38 ]
indicesOf('an', haystack); // [ 6, 12 ]
indicesOf('Dan', haystack); // [ 11 ]
indicesOf('dan', haystack); // [ ]