Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
test
.npmignore
CHANGELOG.md
LICENSE
README.md
package.json
tsconfig.json

README.md

@thi.ng/compare

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

General purpose comparator with optional delegation for types implementing the @thi.ng/api/ICompare interface.

This feature was previously part of the @thi.ng/api package.

Installation

yarn add @thi.ng/compare

Dependencies

None

Usage examples

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

Authors

  • Karsten Schmidt

License

© 2018 Karsten Schmidt // Apache Software License 2.0