
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@utilityjs/comparator
Advanced tools
A utility class for comparing values with customizable comparison functions.
npm install @utilityjs/comparator
or
pnpm add @utilityjs/comparator
import { Comparator } from "@utilityjs/comparator";
const comparator = new Comparator<number>();
comparator.isEqual(1, 1); // true
comparator.isLessThan(1, 2); // true
comparator.isGreaterThan(2, 1); // true
import { Comparator, CompareFunction } from "@utilityjs/comparator";
interface Person {
name: string;
age: number;
}
const compareByAge: CompareFunction<Person> = (a, b) => {
if (a.age === b.age) return 0;
return a.age < b.age ? -1 : 1;
};
const comparator = new Comparator(compareByAge);
const alice = { name: "Alice", age: 30 };
const bob = { name: "Bob", age: 25 };
comparator.isLessThan(bob, alice); // true
comparator.isGreaterThanOrEqual(alice, bob); // true
CompareFunction<T>type CompareFunction<T> = (a: T, b: T) => -1 | 0 | 1;
Comparator<T>Comparator.defaultComparatorFunction<T>(a: T, b: T): -1 | 0 | 1 - Default
comparison using JavaScript operatorsnew Comparator<T>(compareFunction?: CompareFunction<T>) - Creates a
comparator with optional custom functionisEqual(a: T, b: T): boolean - Check if values are equalisLessThan(a: T, b: T): boolean - Check if a < bisLessThanOrEqual(a: T, b: T): boolean - Check if a <= bisGreaterThan(a: T, b: T): boolean - Check if a > bisGreaterThanOrEqual(a: T, b: T): boolean - Check if a >= bRead the contributing guide to learn about our development process, how to propose bug fixes and improvements, and how to build and test your changes.
This project is licensed under the terms of the MIT license.
FAQs
A utility class that compares its comparable arguments.
The npm package @utilityjs/comparator receives a total of 5 weekly downloads. As such, @utilityjs/comparator popularity was classified as not popular.
We found that @utilityjs/comparator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.