Skip to content

Latest commit

 

History

History

compare

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@thi.ng/compare

npm (scoped)

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