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

Comparators with support for types implementing the @thi.ng/api ICompare interface.

Status

STABLE - used in production

Installation

yarn add @thi.ng/compare

Package sizes (gzipped): ESM: 0.2KB / CJS: 0.2KB / UMD: 0.3KB

Dependencies

None

Usage examples

Several demos in this repo's /examples directory are using this package.

A selection:

triple-query

Live demo | Source

API

Generated API docs

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

© 2016 - 2020 Karsten Schmidt // Apache Software License 2.0

Generated using TypeDoc