Skip to content

Commit

Permalink
Adds TS types
Browse files Browse the repository at this point in the history
* adds TypeScript types

---------

Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com>
  • Loading branch information
angellovc and Planeshifter authored Sep 15, 2023
1 parent 8df7373 commit f3e834b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "Athan Reines",
"email": "kgryte@gmail.com"
},
"types": "./types/index.d.ts",
"contributors": [
{
"name": "Athan Reines",
Expand Down
27 changes: 27 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Accessor function.
*
* @param value - input value
* @returns numerical value
*/
type AccessorFunction<T> = (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<T>(
x: T[],
y: T[],
accessor: AccessorFunction<T>
): number | null;

export default similarity

0 comments on commit f3e834b

Please sign in to comment.