Options
All
  • Public
  • Public/Protected
  • All
Menu

@thi.ng/compare

@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

Generated using TypeDoc