Skip to content

Commit

Permalink
✨ added map function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-runge committed Aug 27, 2023
1 parent cf11d70 commit 5dcb3d6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export function Try<T>(fn: () => T, err: (e: Error) => T): T {
}
}

export function map(x: number, in_min: number, in_max: number, out_min: number, out_max: number) {
return ((x - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min;
}

export function add(a: number, b: number): number {
return a + b;
}

0 comments on commit 5dcb3d6

Please sign in to comment.