Socket
Socket
Sign inDemoInstall

almete.maxdiff

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    almete.maxdiff

Implementation of MaxDiff technique to support discrete ordering model.


Version published
Weekly downloads
6
increased by50%
Maintainers
1
Install size
16.8 kB
Created
Weekly downloads
 

Readme

Source

almete.MaxDiff

almete.MaxDiff(values)

Implementation of MaxDiff technique to support discrete ordering model.

argumentdescription
valuesAn 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.

argumentdescription
valuesThe 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.

argumentdescription
countThe 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.

argumentdescription
valueThe value to order to the left of the other values.
otherValuesAn 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.

argumentdescription
valueThe value to order to the right of the other values.
otherValuesAn 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.

argumentdescription
valueThe 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.

argumentdescription
valueThe 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.

argumentdescription
valueThe 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.

argumentdescription
valueThe 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.

Keywords

FAQs

Last updated on 19 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc