collection-utils
Advanced tools
Comparing version
@@ -7,3 +7,5 @@ export declare const hashCodeInit = 17; | ||
export declare function definedMapWithDefault<T, U>(x: T | undefined, theDefault: U, f: (x: T) => U): U; | ||
export declare function hasOwnProperty(obj: object, name: string): boolean; | ||
export declare function hasOwnProperty<T extends string>(obj: unknown, name: T): obj is { | ||
[P in T]: unknown; | ||
}; | ||
export declare function iterableFind<T>(it: Iterable<T>, p: (v: T) => boolean): T | undefined; | ||
@@ -70,3 +72,3 @@ export declare function iterableEvery<T>(it: Iterable<T>, p: (v: T) => boolean): boolean; | ||
} | ||
export declare function areEqual(a: any, b: any): boolean; | ||
export declare function hashCodeOf(x: any): number; | ||
export declare function areEqual(a: unknown, b: unknown): boolean; | ||
export declare function hashCodeOf(x: unknown): number; |
@@ -45,2 +45,4 @@ "use strict"; | ||
function hasOwnProperty(obj, name) { | ||
if (obj === undefined || obj === null) | ||
return false; | ||
return Object.prototype.hasOwnProperty.call(obj, name); | ||
@@ -507,3 +509,6 @@ } | ||
} | ||
if (typeof a.equals === "function" && typeof b.equals === "function") { | ||
if (hasOwnProperty(a, "equals") && | ||
typeof a.equals === "function" && | ||
hasOwnProperty(b, "equals") && | ||
typeof b.equals === "function") { | ||
return a.equals(b); | ||
@@ -555,4 +560,5 @@ } | ||
return (h + 2) | 0; | ||
if (typeof x.hashCode === "function") | ||
if (hasOwnProperty(x, "hashCode") && typeof x.hashCode === "function") { | ||
return x.hashCode(); | ||
} | ||
if (x instanceof Set) { | ||
@@ -559,0 +565,0 @@ for (const y of x) { |
{ | ||
"name": "collection-utils", | ||
"version": "0.0.15", | ||
"version": "1.0.0", | ||
"description": "Utility functions for Javascript collections", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/quicktype/collection-utils", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
48102
0.9%655
1.24%2
-33.33%