0.3.0 • Published 6 years ago

comparison-wrapper v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Comparison Wrapper

A wrapper for JavaScript arrays useful for making comparison functions more readable.

Usage

Given an array arr and a comparison function compareFunction we generate the wrapper by executing for example

import {getComparisonWrapper} from "comparison-wrapper"
var e = getComparisonWrapper(compareFunction);

You can assign the result of getComparisonWrapper to any variable you want.
However, consider this example we could use it as follows

if (e(arr[i], "<=", arr[j])) {
  //do something
}
if (e(arr[i], "<", arr[j])) {
  //do something
}
if (e(arr[i], ">", arr[j])) {
  //do something
}
if (e(arr[i], ">=", arr[j])) {
  //do something
}