diff --git a/package.json b/package.json index c8cdf8f..9fa1a77 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "name": "Athan Reines", "email": "kgryte@gmail.com" }, + "types": "./types/index.d.ts", "contributors": [ { "name": "Athan Reines", diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..79ae1da --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,27 @@ +/** +* Accessor function. +* +* @param value - input value +* @returns numerical value +*/ +type AccessorFunction = (value: T) => number; + +/** + * Computes the cosine similarity between two arrays. + * + * @param x - input array + * @param y - input array + * @param accessor - accessor function for accessing array values + * @returns cosine similarity or null + */ +declare function similarity( + x: number[], + y: number[], +): number | null; +declare function similarity( + x: T[], + y: T[], + accessor: AccessorFunction +): number | null; + +export default similarity