1.0.3 • Published 5 years ago

to-grid v1.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

An utility to group items in order

Usage

npm i --save to-grid
let { Order, default: toGrid} = require('to-grid');
toGrid([1,2,3,4,5,6,7], 3, Order.N);

API

enum Order { N, Z }

toGrid(arr: T[], numOfColumns: number, order: Order = Order.Z): T

Z Ordering

left-to-right, top-to-bottom

E.g.

1,2,3,4,5,6,7 with 3 groups will result in:

[[1, 2, 3], [4, 5, 6], [7]]

i.e.

1 2 3
4 5 6
7

N Ordering

top-to-bottom -> left-to-right

E.g.

1,2,3,4,5,6,7 with 3 groups will result in:

[1, 4, 7], [2, 5], [3, 6]])

i.e.

1 4 7
2 5 
3 6
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago