group-numbers

1.4.0 • Public • Published

group-numbers

Partitions an array of numbers into continuous groups.

Build Status

NPM

Usage

npm install group-numbers
   numberRange([   43, 44, 45, 46,   51,   53, 54  ]);
            => [ [ 43, 44, 45, 46 ], 51, [ 53, 54 ] ]

For having single elements in array, too:

   numberRange([   43, 44, 45, 46,     51,     53, 54  ], false);
            => [ [ 43, 44, 45, 46 ], [ 51 ], [ 53, 54 ] ]

Arguments

numbers

The array of numbers to be grouped.

returnSingleElements

Whether to return single elements in the array as single elements or in an array (of a single element). Defaults to true. (Passed to underlying arr-group method)

Note

The numbers in the passed array are sorted naturally first in order for grouping to work properly.

Package Sidebar

Install

npm i group-numbers

Weekly Downloads

1

Version

1.4.0

License

MIT

Last publish

Collaborators

  • strarsis