sortedindex
    Preparing search index...

    sortedindex

    npm version license

    sortedindex is a tiny TypeScript package that uses binary search to find the leftmost insertion index in a sorted array.

    sortedindex は、二分探索でソート済み配列に対する左端の挿入位置を返す小さな TypeScript パッケージです。

    npm install sortedindex
    
    import { 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); // 2
    npm test
    npm run build

    Copyright (c) 2021-2026 Jun Kato