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

1.0.0 • Public • Published

The midIndexOf method returns the first index at which a given element can be found in the array, or -1 if it is not present.

Specially, this method will search from the middle index, and go to left and right to find target element.

syntax

midIndexOf(array, searchElement, startIndex);

startIdex is optional, and default is half the length of the array.

example

import midIndexOf from 'mid-index-of';

midIndexOf(['a', 'b', 'c', 'd', 'e', 'f'], 'e', 1);
// result: 1
// Actually, it will search with snake path: b -> c -> a -> d -> e

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.00latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.70
1.0.00
0.0.20
0.0.10

Package Sidebar

Install

npm i mid-index-of

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.09 kB

Total Files

6

Last publish

Collaborators

  • frstar