indexof-limited
v1.1.13
Published
JavaScript library to find the first occurence of a substring inside a long string limited to initial and end position
Downloads
11
Maintainers
Readme
indexof-limited
JavaScript library to find the first occurence of a substring inside a long string limited to initial and end position.
It works in the same way as String.prototype.indexOf
when no end limit specified. Otherwise it searches only until the end limit (the entire substring must be within the limit).
install
npm install --save indexof-limited
usage
const indexOf = require('indexof-limited');
const longtext = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua';
const substring = 'consectetur';
expect(indexOf(longtext, substring, 10, 15)).to.equal(-1);