slice-calculator
v0.1.0
Published
given limits of a list, calculate limits of sliced new list
Downloads
2
Readme
slice-calculator
slice-calculator
exports a function that given the limits start
and end
of a list, it calculates the new limits of the list.
This library is useful for optimize multiple slice chaining without calculating intermediate lists.
Install
$ npm install slice-calculator --save
Usage
const sliceCalculator = require('slice-calculator')
sliceCalculator({start: 0, end: 6}, 2, 8) // {start: 2, end: 6}
sliceCalculator({start: 0, end: 6}, -1, 4) // {start: 0, end: 4}
sliceCalculator({start: 0, end: 6}, 1, 5) // {start: 1, end: 5}
sliceCalculator({start: 1, end: 5}, 1, 3) // {start: 2, end: 4}
sliceCalculator({start: 2, end: 4}, 0, 1) // {start: 2, end: 3}
Support
- Node.js >=6
- ES2015 transpilers
License
MIT