https://github.com/shadowtime2000/find-item
A utility package to find an item that matches a condition from an array.
https://github.com/shadowtime2000/find-item
Last synced: 4 months ago
JSON representation
A utility package to find an item that matches a condition from an array.
- Host: GitHub
- URL: https://github.com/shadowtime2000/find-item
- Owner: shadowtime2000
- Created: 2020-07-25T23:36:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-25T23:37:07.000Z (almost 6 years ago)
- Last Synced: 2025-10-06T16:35:37.747Z (8 months ago)
- Homepage: https://www.npmjs.com/package/find-item
- Size: 1000 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# find-item
A utility package to find an item that matches a condition from an array.
## Search Algorithms
`find-item` currently only supports 2 search algorithms:
### Linear
Linear can be called like this: `findItem.linear(array here, function to check if matches condition here, get all matches or the first, "all", "first")`.
If you choose the `all` option, it will return an array, which will contain the indexes of the values that match the condition. If no values are found, an empty array will be given.
If you choose the `first` option, it will return a single number which is the index of the first value found. If no values are found, -1 will be returned.
### Binary
Binary can be called like this: `findItem.binary(array here, number here)`.
This will return the index of location of the number. If it is not found, it will return -1.