Skip to content

xgbuils/multiple-needles-indexof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multiple-needles-indexof

indexOf function with multiple needles. Needles may be a string or a character set RegExp.

Install

npm install multiple-needles-indexof

Example

var mnIndexOf = require('multiple-needles-indexof')

// pass two needles that matches
mnIndexOf('xbcda', ['a', 'cd']) // {index: 2, match: 'cd'}
// pass one needle as string
mnIndexOf('xbcda', 'b') // {index: 1, match: 'b'}
// needles don't match
mnIndexOf('abcda', ['x', 'y']) // undefined
// with offset
mnIndexOf('caabcda', ['c', 'd', 'x'], 2) // {index: 5, match: 'd'}
// no needles returns undefined
mnIndexOf('xaabcda', []) // undefined
// with charset regexp needle
mnIndexOf('xaabcda', ['f', /[b-d]/]) // {index: 3, match: 'b'}

About

indexOf with multiple needles

Resources

Stars

Watchers

Forks

Packages

No packages published