mori
mori copied to clipboard
How do you get the index of a given string in a sequence of strings?
This seems to be missing ... thanks for any hints
There is an undocumented function keepIndexed that you can use in this fashion:
const kept = mori.keepIndexed((idx, string) => string === referenceString ? idx : null, strings)
const matchingIndex = mori.first(kept)
thanks @hallettj but why is it undocumented?
I don't know why keepIndexed is not documented. I happened to get a pretty good look at that and other unadvertised functions while assembling type definitions for Mori.