to-grid
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

/to-grid/

    Package Sidebar

    Install

    npm i to-grid

    Weekly Downloads

    0

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    5.68 kB

    Total Files

    9

    Last publish

    Collaborators

    • n0rush