Find all indexes
What is this?
Find all indexes allows you to find all occurrences of a unique or multiple characters in a string or in an array (Buffer included).
How-to use
ES6:
import findAllIndexes from 'find-all-indexes'
const myString = 'kayak';
const myArray = ['k', 'a', 'y', 'a', 'k'];
const myBuffer = new Buffer([107, 97, 121, 97, 107]);
console.log(
findAllIndexes(myString, 'a'),
findAllIndexes(myString, ['a', 'k']),
findAllIndexes(myString, ['a', 'k'], {
sort: true
}),
findAllIndexes(myArray, 'y'),
findAllIndexes(myBuffer, ['6B', '61'], {
hex: true,
sort: true
})
);
ES5:
var findAllIndexes = require('find-all-indexes').default;
var myString = 'kayak';
var myArray = ['k', 'a', 'y', 'a', 'k'];
var myBuffer = new Buffer([107, 97, 121, 97, 107]);
...
Want to contribute?
Feel free to open a pull request on GitHub!
Licence
MIT