kvandake / lexorank-ts

A reference implementation of a list ordering system like JIRA's Lexorank algorithm
197 stars 27 forks source link

Support for multiple ranks in between 2 values #28

Open ritik5049 opened 5 months ago

ritik5049 commented 5 months ago

It would be really nice if, I have 2 ranks, and want to add multiple values in between them, thus need to have a support for that.

oliverlockwood commented 2 months ago

Agreed.

Spelling this out at bit more, you currently have to do the following:

const x: LexoRank = /* the "before" rank */;
const y: LexoRank = /* the "after" rank */;

// to insert `n` ranks between x and y
r1: LexoRank = x.between(y);
r2: LexoRank = r1.between(y);
r3: LexoRank = r2.between(y);
...
rn: LexoRank = rm.between(y);

and of course, the space between the inserted ranks is not evenly distributed.

I envisage a new approach could be something like:

// to insert `n` ranks between x and y, **ideally with even spacing**
ranks:  LexoRank[] = x.between(y, n);

@kvandake if someone were to submit an implementation with the signature I propose here, would you consider accepting it?

oliverlockwood commented 2 weeks ago

@ritik5049 since this repo appears to have been abandoned by the owner, we have made and will maintain a fork at https://github.com/dalet-oss/lexorank-ts.

This particular issue has been addressed by https://github.com/dalet-oss/lexorank-ts/pull/1, and the new functionality is available in @dalet-oss/lexorank version 1.1.0: https://www.npmjs.com/package/@dalet-oss/lexorank/v/1.1.0.