This project is part of the @thi.ng/umbrella monorepo.
Comparators with support for types implementing the @thi.ng/api ICompare
interface.
STABLE - used in production
yarn add @thi.ng/compare
Package sizes (gzipped): ESM: 0.2KB / CJS: 0.2KB / UMD: 0.3KB
None
Several demos in this repo's /examples directory are using this package.
A selection:
import { ICompare } from "@thi.ng/api";
import { compare } from "@thi.ng/compare";
class Foo implements ICompare<Foo> {
x: number;
constructor(x: number) {
this.x = x;
}
compare(o: Foo) {
return compare(this.x, o.x);
}
}
compare(new Foo(1), new Foo(2));
// -1
Karsten Schmidt
© 2016 - 2020 Karsten Schmidt // Apache Software License 2.0