Function: allocateByWeights()
allocateByWeights<
T>(total,weights):T[]
Defined in: src/lib/money/index.ts:90
Allocate a total across buckets in proportion to integer weights, returning integer
minor units that sum exactly to total (the last non-zero-weight bucket absorbs the
rounding remainder). This is how a bi-monthly rate is split across the (possibly partial)
weeks of a pay period without losing or inventing a centavo.
Type Parameters
T
T extends Minor
Parameters
total
T
weights
readonly number[]
Returns
T[]
Throws
if all weights are zero (cannot allocate a non-zero total with no weight).