UNPKG

position-strings

Version:

Lexicographically-ordered position strings for collaborative lists and text

24 lines (23 loc) 798 B
/** * Returns `{ index, isPresent }`, where: * - `index` is the current index of `position` in `positions`, * or where it would be if added. * - `isPresent` is true if `position` is present in `positions`. * * If this method is inconvenient (e.g., the positions are in a database * instead of an array), you can instead compute * `index` by finding the number of positions less than `position`. * For example, in SQL, use: * ```sql * SELECT COUNT(*) FROM table WHERE position < $position * ``` * * See also: `Cursors.toIndex`. * * @param positions The target list's positions, in lexicographic order. * There should be no duplicate positions. */ export declare function findPosition(position: string, positions: ArrayLike<string>): { index: number; isPresent: boolean; };