npm.io
1.0.0 • Published 5 years ago

split-integer

Licence
MIT
Version
1.0.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
2

split-integer Travis CI Build Status

Split up an integer into even parts that add to the original integer.

NPM Badge

Install

npm install split-integer

Usage

const splitInteger = require("split-integer")

splitInteger(10, 2)
//=> [5, 5]

splitInteger(10, 3)
//=> [4, 3, 3]

splitInteger(10, 3, { smallestFirst: true })
//=> [3, 3, 4]

API

splitInteger(number, parts, options?)
number

Type: number

The number to split.

parts

Type: number

The amount of parts to split the number into.

options

Type: object

smallestFirst

Type: boolean
Default: false

Whether to order the smallest numbers first in the resulting array.