{{pkg.description}}
{{meta.status}}
{{repo.supportPackages}}
{{repo.relatedPackages}}
{{meta.blogPosts}}
{{pkg.install}}
{{pkg.size}}
{{pkg.deps}}
{{repo.examples}}
{{pkg.docs}}
arrayIterator()
argMin()
/argMax()
argSort()
binarySearch()
bisect()
blit1d()
/ blit2d()endsWith()
ensureArray()
ensureIterable()
fillRange()
find()
findSequence()
floydRivest()
fuzzyMatch()
insert()
into()
isSorted()
levenshtein()
multiSwap()
peek()
quickSort()
rotate()
/rotateTyped()
selectThresholdMin()
/selectThresholdMax()
shuffle()
(w/ custom PRNG support)shuffleRange()
(w/ custom PRNG support)sortByCachedKey()
startsWith()
swap()
swizzle()
topoSort()
The following predicates can be used to perform predecessor / successor
queries using binarySearch()
.
bsLT()
- Returns index of last item less than search value or -1 if no such values existbsLE()
- Similar tobsLT()
, but for less-than-equals queriesbsGT()
- Returns index of first item greater than search value or -1 if no such values existbsGE()
- Similar tobsGT()
, but for less-than-equals queriesbsEQ()
- Merely syntax sugar, casting any non-found result indices to -1
import { binarySearch, bsGT, bsLT } from "@thi.ng/arrays";
const src = [10, 20, 30, 40];
bsLT(binarySearch(src, 25))
// 1
// greater-than queries also require the array length
bsGT(binarySearch(src, 25), src.length)
// 2
bsGT(binarySearch(src, 40), src.length)
// -1