Package Exports
- @writetome51/get-index-for-reversed-array
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@writetome51/get-index-for-reversed-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
getIndexForReversedArray(
index,
arrayLength
): number
Receives array index and returns the new index that same item would have
if the array's order were reversed.
Examples
let arr = ['a', 'b', 'c', 'd', 'e'];
let index = arr.indexOf('d');
arr.reverse();
getIndexForReversedArray(index, arr.length);
// --> 1
arr = [7, 2, 6, 9, 3, 10];
let index = arr.indexOf(2);
arr.reverse();
getIndexForReversedArray(index, arr.length);
// --> 2Installation
npm i @writetome51/get-index-for-reversed-array
Loading
import {getIndexForReversedArray} from '@writetome51/get-index-for-reversed-array';