Convert negative index to positive starting from the end. Same way Array.slice arguments work.
import idx from 'negative-index';
// idx(index, length)
idx(-5, 8); //3
idx(5, 8); //5
Works well for normalizing real numbers offset, like time etc:
import normOffset from 'negative-index';
let time = -.15, duration = 2.45;
normOffset(time, duration); //2.3