comparison-wrapper

0.3.0 • Public • Published

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
}

Readme

Keywords

Package Sidebar

Install

npm i comparison-wrapper

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

2.7 kB

Total Files

4

Last publish

Collaborators

  • xerocross