This package has been deprecated

Author message:

This package has been deprecated and is no longer maintained. Please use @seregpie/max-diff.

almete.maxdiff

18.1.20 • Public • Published

almete.MaxDiff

almete.MaxDiff(values)

Implementation of MaxDiff technique to support discrete ordering model.

argument description
values An iterable of the values to order.

Returns an instance to control the process.

demo

Try it out!

dependencies

setup

npm

npm install almete.maxdiff

ES module

import MaxDiff from 'almete.maxdiff';

Node

const MaxDiff = require('almete.maxdiff');

browser

<script src="https://unpkg.com/almete.bronkerbosch"></script>
<script src="https://unpkg.com/almete.maxdiff"></script>

The function MaxDiff will be available under the namespace almete.

members

.complete

read-only

true, if the process is complete, false otherwise.


.result

read-only

An array of the values in the resulted order, if the process is complete, undefined otherwise.


.order(...values)

Orders the given values. The values are ordered in the given argument order.

Already established order relations between values are immutable.

argument description
values The values to order.
let instance =  almete.MaxDiff('edacb');
instance.order('a', 'b', 'c');
instance.order('c', 'd', 'e');
console.log(instance.result); // => ['a', 'b', 'c', 'd', 'e']

.getCandidatesToOrder(count = 4)

Returns the values that are most significant candidates to be ordered as next.

argument description
count The maximum count of candidates to get.

.getUnorderedPairs()

Returns pairs of the values as an array of arrays, where the order between the two values is unknown.

The values are ordered by their initial order.

let instance =  almete.MaxDiff('bca');
console.log(instance.getUnorderedPairs()); // => [['b', 'c'], ['b', 'a'], ['c', 'a']]
instance.order('a', 'b');
console.log(instance.getUnorderedPairs()); // => [['b', 'c'], ['c', 'a']]
instance.order('b', 'c');
console.log(instance.getUnorderedPairs()); // => []

.getOrderedPairs()

Returns pairs of the values as an array of arrays, where the order between the two values is known.

The values are ordered by their resulted order.

let instance =  almete.MaxDiff('bca');
console.log(instance.getOrderedPairs()); // => []
instance.order('a', 'b');
console.log(instance.getOrderedPairs()); // => [['a', 'b']]
instance.order('b', 'c');
console.log(instance.getOrderedPairs()); // => [['b', 'c'], ['a', 'b'], ['a', 'c']]

.getValues()

Returns the values as an array.


.orderLeftOf(value, otherValues)

Orders the value to the left of the other values.

Already established order relations between values are immutable.

argument description
value The value to order to the left of the other values.
otherValues An iterable of the values to order to the right of the given value.
let instance =  almete.MaxDiff('edacb');
instance.orderLeftOf('a', 'cd');
console.log(instance.getOrderedPairs()); // => [['a', 'c'], ['a', 'd']]

.orderRightOf(value, otherValues)

Orders the value to the right of the other values.

Already established order relations between values are immutable.

argument description
value The value to order to the right of the other values.
otherValues An iterable of the values to order to the left of the given value.
let instance =  almete.MaxDiff('edacb');
instance.orderRightOf('e', 'bc');
console.log(instance.getOrderedPairs()); // => [['c', 'e'], ['b', 'e']]

.orderLeft(value)

Orders the value to the left of all other values.

Already established order relations between values are immutable.

argument description
value The value to order to the left of all other values.
let instance =  almete.MaxDiff('bca');
instance.orderLeft('a');
console.log(instance.getOrderedPairs()); // => [['a', 'b'], ['a', 'c']]
instance.orderLeft('b');
console.log(instance.result); // => ['a', 'b', 'c']

.orderRight(value)

Orders the value to the right of all other values.

Already established order relations between values are immutable.

argument description
value The value to order to the right of all other values.
let instance =  almete.MaxDiff('bca');
instance.orderRight('c');
console.log(instance.getOrderedPairs()); // => [['b', 'c'], ['a', 'c']]
instance.orderRight('b');
console.log(instance.result); // => ['a', 'b', 'c']

.getValuesLeftOf(value)

Returns the values that are ordered to the left of the given value.

argument description
value The value to the right of the values to get.
let instance =  almete.MaxDiff('edacb');
instance.order('a', 'b', 'e');
instance.order('c', 'e');
console.log(instance.getValuesLeftOf('e')); // => ['b', 'a', 'c']

.getValuesRightOf(value)

Returns the values that are ordered to the right of the given value.

argument description
value The value to the left of the values to get.
let instance =  almete.MaxDiff('edacb');
instance.order('a', 'd', 'e');
instance.order('a', 'c');
console.log(instance.getValuesRightOf('a')); // => ['d', 'e', 'c']

.getUnorderedGroups()

Returns groups of the values as an array of arrays, where the order between each pair of values is unknown.

The groups are ordered by decreasing length. The values are ordered by their initial order.

let instance =  almete.MaxDiff('cbad');
console.log(instance.getUnorderedGroups()); // => [['c', 'b', 'a', 'd']]
instance.order('a', 'd');
instance.order('c', 'd');
console.log(instance.getUnorderedPairs()); // => [['c', 'b'], ['c', 'a'], ['b', 'a'], ['b', 'd']]
console.log(instance.getUnorderedGroups()); // => [['c', 'b', 'a'], ['b', 'd']]
instance.order('a', 'b', 'c');
console.log(instance.getUnorderedGroups()); // => []

.getOrderedGroups()

Returns groups of the values as an array of arrays, where the order between each pair of values is known.

The groups are ordered by decreasing length. The values are ordered by their resulted order.

let instance =  almete.MaxDiff('cbad');
console.log(instance.getOrderedGroups()); // => []
instance.order('a', 'b', 'c');
instance.order('a', 'd');
console.log(instance.getOrderedPairs()); // => [['b', 'c'], ['a', 'b'], ['a', 'c'], ['a', 'd']]
console.log(instance.getOrderedGroups()); // => [['a', 'b', 'c'], ['a', 'd']]
instance.order('c', 'd');
console.log(instance.getOrderedGroups()); // => [['a', 'b', 'c', 'd']]

.getValuesCount()

Returns the length of the array, that the function .getValues() would return.


.getUnorderedPairsCount()

Returns the length of the array, that the function .getUnorderedPairs() would return.


.getOrderedPairsCount()

Returns the length of the array, that the function .getOrderedPairs() would return.


.getValuesCountRightOf(value)

Returns the length of the array, that the function .getValuesRightOf() would return.


.getValuesCountLeftOf(value)

Returns the length of the array, that the function .getValuesLeftOf() would return.


.clone()

Returns a clone of this instance.

Package Sidebar

Install

npm i almete.maxdiff

Weekly Downloads

12

Version

18.1.20

License

MIT

Last publish

Collaborators

  • npm