Package Exports
- robin-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (robin-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Robin JS
Robin JS is a JavaScript utility to calculate round-robin pairs from a list of participants.
It can be used directly in the browser, as a ES6 module, or as a CommonJS module in Node.
Installation
npm i robin-js
Usage
pairsCalc(participants, [opts])
participants(Number, or Array of strings): the number of participants or an array that contains their names.opts(Object, optional)randomStart(Boolean): whether the pairing logic should start from the first participant or a random one (defaults to false).rounds(Number, positive integer): the number of rounds required (defaults to a full round-robin).
Returns an array containing all the rounds. Each round is an array containing all the pairs. Each pair is an array containing the members.
If the number of participants is odd, at each round one different player will be alone (i.e. free / not paired).
Examples
import pairsCalc from 'robin-js'; // ES6
const pairsCalc = require('robin-js'); // CJS
pairsCalc(4);
// [ [ [ 1, 3 ], [ 2, 4 ] ],
// [ [ 1, 2 ], [ 4, 3 ] ],
// [ [ 1, 4 ], [ 3, 2 ] ] ]
pairsCalc(['Tom', 'Lucy', 'Hannah']);
// [ [ [ 'Lucy' ], [ 'Tom', 'Hannah' ] ],
// [ [ 'Tom' ], [ 'Hannah', 'Lucy' ] ],
// [ [ 'Hannah' ], [ 'Lucy', 'Tom' ] ] ]MIT License