Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

distrib

Functions to distribute numbers or objects between groups

Usage

import {distrib, distribObjects} from '@kormanowsky/distrib';

// Distribute ten 10's into at most 4 groups
// groups = [[10, 10, 10], [10, 10, 10], [10, 10], [10, 10]]
const groups = distrib([10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 4);

// Distribute five objects into at most 3 groups
// objGroups = [[{x: 10}, {x: 10}], [{x:10}, {x: 10}], [{x: 10}]]
const objGroups = distribObjects(
    [{x: 10}, {x: 10}, {x: 10}, {x:10}],
    (obj) => obj.x,
    3
);

About

Functions to distribute numbers or objects between groups

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages