Count array / list occurrences... 😐
const arr = Array.from(
{ length: 10 },
() => Math.round(Math.random() * 5)
);
countOf(3, arr);
Searchable
is a barebonesArrayLike
interface that has the methods it needs to forfill its task.
- This is to permit the use of a
string
as a nativetarget
-ArrayLike<T>
would not have permitted this.
reference
:T
- The search term or element.target
:Searchable<T>
- The entity to search.
- This implementation derives from
underscore
andlodash
but focusing on one element as the query focus. - Attempts were made to allow it to accept a function, and then build the string search predicate from there... but that fell short rapidly - and it was not worth investing more time into something that is ultimately slower than the best available native solution.
You can find more of my shenanigans projects with TinkerStorm... might be more interesting, ya never know. 🤷♂️