fractional-index
v1.0.0
Published
A Javascript implementation of fractional indexes for sorting items, as described originally in: https://observablehq.com/@dgreensp/implementing-fractional-indexing
Downloads
2,821
Readme
fractional-index
A Javascript implementation of fractional indexes for sorting items, as described originally in: https://observablehq.com/@dgreensp/implementing-fractional-indexing
Given two indexes the library will always return a fractional index at the midpoint between the two.
Install
npm install fractional-index
or
yarn add fractional-index
Usage
import fractionalIndex from "fractional-index";
const index = fractionalIndex("a", "b");
For start and end of a list pass null
as the argument, eg:
import fractionalIndex from "fractional-index";
const index = fractionalIndex("a", null);