File tree Expand file tree Collapse file tree 4 files changed +27
-1
lines changed
Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 11# deverything
22
3+ ## 3.3.1
4+
5+ ### Patch Changes
6+
7+ - max fix
8+
39## 3.3.0
410
511### Minor Changes
Original file line number Diff line number Diff line change 11{
22 "name" : " deverything" ,
3- "version" : " 3.3.0 " ,
3+ "version" : " 3.3.1 " ,
44 "description" : " Everything you need for Dev" ,
55 "main" : " ./dist/index.js" ,
66 "module" : " ./dist/index.mjs" ,
Original file line number Diff line number Diff line change 1+ import { describe , expect , test } from "@jest/globals" ;
2+ import { max } from "./max" ;
3+
4+ describe ( "max" , ( ) => {
5+ test ( "simple" , async ( ) => {
6+ expect ( max ( [ 1 , 2 ] ) ) . toBe ( 2 ) ;
7+ expect ( max ( [ - 1 , - 12 ] ) ) . toBe ( - 1 ) ;
8+ expect ( max ( [ 0 ] ) ) . toBe ( 0 ) ;
9+ expect ( max ( [ ] ) ) . toBe ( 0 ) ;
10+ expect ( max ( [ - Infinity , 0 ] ) ) . toBe ( 0 ) ;
11+ } ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Returns the maximum value in an array of numbers.
3+ * @param values - The array of numbers to find the maximum value of.
4+ * @returns The maximum value in the array. If the array is empty, returns 0.
5+ */
16export const max = ( values : number [ ] ) : number => {
7+ if ( ! values . length ) {
8+ return 0 ;
9+ }
210 const maxValue = Math . max ( ...values ) ;
311 return maxValue ;
412} ;
You can’t perform that action at this time.
0 commit comments