JSPM

chunk-array

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2318
  • Score
    100M100P100Q113880F
  • License MIT

Turn an array into chunks of n-size

Package Exports

  • chunk-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 (chunk-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Chunks Array

NPM version build status Test coverage

A tiny module that turn your array into chunks of n-size.

Usage

npm install chunk-array --save

chunks(arr, n)

Turn array into chunks of size n, if n is a falsy value then return original array

var chunks = require('chunk-array').chunks
var arr = [1,2,3,4,5,6]
var results = chunks(arr, 3) //[[1,2,3], [4,5,6]]

pairs(arr)

A convenient method that turn array into pairs, which equals chunks(arr, 2)

var pairs = require('chunk-array').pairs
var arr = [1,2,3,4,5,6]
var results = pairs(arr) //[[1,2], [3,4], [5,6]]

LICENSE

MIT