sortedindex
v0.1.1
Published
A simple npm package that provides a binary search function for a sorted array
Readme
sortedindex
sortedindex is a tiny TypeScript package that uses binary search to find the leftmost insertion index in a sorted array.
sortedindex は、二分探索でソート済み配列に対する左端の挿入位置を返す小さな TypeScript パッケージです。
- GitHub repository: https://github.com/arcatdmz/sortedIndex
- npm package: https://www.npmjs.com/package/sortedindex
- API document: https://arcatdmz.github.io/sortedIndex
Usage / 使い方
npm install sortedindeximport { sortedIndex } from "sortedindex";
const i1 = sortedIndex([1, 2, 4, 5], 3); // 2
const i2 = sortedIndex([1, 2, 2, 2, 3], 2); // 1
const i3 = sortedIndex(["a", "b", "d", "e"], "c", (o) => o.charCodeAt(0)); // 2
const i4 = sortedIndex([{ score: 10 }, { score: 20 }, { score: 40 }], 25, (o) => o.score); // 2Development / 開発
npm test
npm run buildCredits / 開発者
Copyright (c) 2021-2026 Jun Kato
