chunk-pattern

1.0.3 • Public • Published

chunk-pattern NPM version Build status for master

Chunk an array in a specific pattern.

Usage

import chunkPattern from 'chunk-pattern'
 
const flavors = [
  'Chocolate',
  'Strawberry',
  'Green Tea',
  'Rocky Road',
  'Salted Caramel',
  'Vanilla',
  'Cheese',
  'Kit Kat',
  'Ube',
  'Pandan',
  'Blueberry'
]
 
console.log(
  chunkPattern(flavors, [2, 3])
)
 
/*
  ['Chocolate', 'Strawberry'],
  ['Green Tea', 'Rocky Road', 'Salted Caramel'],
  ['Vanilla', 'Cheese'],
  ['Kit Kat', 'Ube', 'Pandan'],
  ['Blueberry']
 */

Installation

npm i chunk-pattern --save

API

chunkPattern(array: Array<mixed>, pattern: Array<number>): Array<Array<mixed>>

Parameters

  • array is the array to be chunked in given pattern.
  • pattern is the sequence in which you'd like your array to be chunked.

Contributing

# Run tests 
npm run test
 
# Create dist build 
npm run build
 
# Format with Prettier 
npm run fmt
 
# Run flow 
npm run flow

Package Sidebar

Install

npm i chunk-pattern

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

5.58 kB

Total Files

11

Last publish

Collaborators

  • srph