indexof-limited

JavaScript library to find the first occurence of a substring inside a long string limited to initial and end position

Usage no npm install needed!

<script type="module">
  import indexofLimited from 'https://cdn.skypack.dev/indexof-limited';
</script>

README

indexof-limited

MIT License Build Status

NPM status

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);