Share your code. Components are building blocks, you are the architect.

utils/aperture
v1.1.0
1.1.0
Returns a new list, composed of n-tuples of consecutive elements

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/aperture in your project
npm i @bit/bit.ramda.utils.aperture
Copied

aperture (n:Number, list:Array) : Array

Returns a new list, composed of n-tuples of consecutive elements. If n is greater than the length of the list, an empty list is returned.

Acts as a transducer if a transformer is given in list position.

Example

R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
     R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
     R.aperture(7, [1, 2, 3, 4, 5]); //=> []

Arguments

n: Number

The size of the tuples to create

list: Array

The list to split into `n`-length tuples

Returns

Array

The resulting list of `n`-length tuples