# negative-index

> Convert negative index to positive starting from the end

Latest version **2.0.0** (published 2023-01-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install negative-index
pnpm add negative-index
yarn add negative-index
bun add negative-index
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-01-09 |
| First published | 2016-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/negative-index) |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | ΔY |
| Maintainers | dfcreative, dy |
| Keywords | normalize-offset, negative, index, slice, array, rotate, mod |

## Links

- npm: https://www.npmjs.com/package/negative-index
- Repository: https://github.com/dfcreative/negative-index
- Homepage: https://github.com/dfcreative/negative-index#readme
- Issues: https://github.com/dfcreative/negative-index/issues
- npm.io page: https://npm.io/package/negative-index

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads
- [react-native-modal-translucent-axton](https://npm.io/package/react-native-modal-translucent-axton.md) — 4 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-01-09
- 1.0.3 — 2018-10-26
- 1.0.2 — 2017-01-27
- 1.0.1 — 2016-10-04
- 1.0.0 — 2016-09-15

## README

Convert negative index to positive starting from the end. Same way [Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) arguments work.

[![npm install negative-index](https://nodei.co/npm/negative-index.png?mini=true)](https://npmjs.org/package/negative-index/)

```js
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:

```js
import normOffset from 'negative-index';

let time = -.15, duration = 2.45;

normOffset(time, duration); //2.3
```

---
_Source: https://npm.io/package/negative-index · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
