Skip to content

Commit

Permalink
fix(api): update compare() & equiv()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 2, 2018
1 parent 0f57ff9 commit 110a9de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/api/src/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export function compare(a: any, b: any): number {
if (typeof a.compare === "function") {
return a.compare(b);
}
if (typeof b.compare === "function") {
return -b.compare(a);
}
return a < b ? -1 : a > b ? 1 : 0;
}
5 changes: 2 additions & 3 deletions packages/api/src/equiv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
import { isString } from "@thi.ng/checks/is-string";

export function equiv(a, b): boolean {
if (a === b) {
Expand All @@ -20,8 +19,8 @@ export function equiv(a, b): boolean {
} else {
return a == b;
}
if (isString(a) || isString(b)) {
return a === b;
if (typeof a === "string" || typeof b === "string") {
return false;
}
if (isPlainObject(a) && isPlainObject(b)) {
return equivObject(a, b);
Expand Down

0 comments on commit 110a9de

Please sign in to comment.