npm.io
1.4.5 • Published 3 years ago

index-of-any

Licence
MIT
Version
1.4.5
Deps
1
Size
12 kB
Vulns
0
Weekly
0

index-of-any

  • Like string indexOf with multiple search strings

Build Status Codacy Badge code style: prettier Coverage Status David GitHub npm

Installation

npm install index-of-any

Usage

Search strings
import indexOfAny from "index-of-any";

const searchStrings = ["first", "second", "third"];

const [index, searchString] = indexOfAny("a string containing second search string");

==> [20, "second"]
Search arrays
import indexOfAny from "index-of-any";

const strings = ["first", "second", "third"];

const [index, searchString] = indexOfAny(strings, "second");

==> [2, "second"]

Test

npm test

Keywords