This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ray Foo
committed
Aug 27, 2022
1 parent
d7a5990
commit 9399c5f
Showing
3 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@busyxiang/utilities-js': patch | ||
--- | ||
|
||
Implement minMax util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export const average = (...nums: number[]) => { | ||
return nums.reduce((acc, value) => acc + value, 0) / nums.length; | ||
export const average = (...values: number[]) => { | ||
return values.reduce((acc, value) => acc + value, 0) / values.length; | ||
}; | ||
|
||
export const minMax = (value: number, min: number, max: number) => { | ||
return Math.min(Math.max(value, min), max); | ||
}; |