6.0.3 • Published 7 years ago

comparative-selection v6.0.3

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
7 years ago

NPM version

Comparative selection algorithm plugin for d-pac platform

Based on NoMoreMarking's cj module.

Description

The algorithm accepts a queue (Array) of items, then:

  1. pseudo-randomizes the items list
  2. sorts the list by the number of comparisons each item has been featured in
  3. retains the first item as 'selected'
  4. retains the next valid item as 'opponent':
    • either, the next item in the (shuffled) list when 'selected' has no previous comparisons.
    • or, the next item in the (shuffled) list 'selected' hasn't been compared to yet.
  5. returns both items

Install

$ yarn add comparative-selection

API

Item

Type: Object

Properties

Comparison

Type: Object

Properties

  • a string the ID of the "A" item
  • b string the ID of the "B" item

select

Simple comparative selection algorithm

Parameters

Examples

const comparative = require('comparative-selection');

const pair = comparative.select([{id:"1"}, {id:"2"}, {id:"3"}, {id:"4"}]);
console.log('pair:', pair); // e.g.: {a: "2", b: "4"}
const comparative = require('comparative-selection');

const pair = comparative.select([{id:"1"}, {id:"2"}, {id:"3"}, {id:"4"}], [{a:"2", b: "1"}]);
console.log('pair:', pair); // {a: "3", b: "4"}

Returns Comparison the pair of item ID's to compare

Development

Testing

$ yarn test

Linting

$ yarn lint

License

GPL v3 © d-pac

6.0.3

7 years ago

6.0.2

7 years ago

6.0.1

7 years ago

6.0.0

7 years ago

5.0.0

7 years ago

4.0.0

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

8 years ago

3.0.0

9 years ago

2.1.0

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago