negative-index
Convert negative index to positive starting from the end
Last updated 3 years ago by dy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install negative-index 
SYNC missed versions from official npm registry.

Convert negative index to positive starting from the end. Same way Array.slice arguments work.

npm install negative-index

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

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

5 Versions

  • 2.0.0                                ...           3 years ago
  • 1.0.3                                ...           7 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |