Socket
Socket
Sign inDemoInstall

negative-index

Package Overview
Dependencies
0
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    negative-index

Convert negative index to positive starting from the end


Version published
Weekly downloads
261
increased by6.1%
Maintainers
2
Install size
1.86 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 09 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc