previous-index-of
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Previous Index Of

Build Status Download count No dependencies Current version Support me

Find the index of a specific char-sequence in a string at a given offset.

Installation

NPM
$ npm i previous-index-of
Yarn
$ yarn add previous-index-of

Usage

const previousIndexOf = require('previous-index-of');
 
// previousIndexOf(sourceString: <string>, target: <string>, offset: <number|undefined>)
previousIndexOf('baz bam boo foo bam', 'bam', 12); // 4
previousIndexOf('baz bam boo foo bam', 'bam');     // 16
previousIndexOf('baz bam boo foo bam', 'da');      // -1
previousIndexOf('baz bam boo foo bam', 'bam', {}); // 16
previousIndexOf('baz bam boo foo bam', null);      // -1
previousIndexOf(null, 'abc');                      // -1

Running tests

$ npm install -d && npm test

Readme

Keywords

Package Sidebar

Install

npm i previous-index-of

Weekly Downloads

4

Version

1.2.1

License

MIT

Unpacked Size

4.95 kB

Total Files

5

Last publish

Collaborators

  • simonwep