File tree 7 files changed +29
-47
lines changed
7 files changed +29
-47
lines changed Original file line number Diff line number Diff line change 1
1
# dec
2
2
3
- Decrements the given number by 1, or by a specified step . Useful for counters and mathematical operations.
3
+ Decrements the given number by 1. Useful for counters and mathematical operations.
4
4
5
5
### Import
6
6
@@ -11,12 +11,12 @@ import { dec } from '@fullstacksjs/toolbox';
11
11
### Signature
12
12
13
13
``` typescript copy
14
- function dec(n : number , step ? : number ): number {}
14
+ function dec(n : number ): number {}
15
15
```
16
16
17
17
### Examples
18
18
19
19
``` typescript copy
20
- dec (3 ) // 2
21
- dec (3 , 2 ) // 1
20
+ dec (3 ) // 2
21
+ dec (5 ) // 4
22
22
```
Original file line number Diff line number Diff line change 1
1
# inc
2
2
3
- Increments the given number by 1, or by a specified step . Useful for counters and mathematical operations.
3
+ Increments the given number by 1. Useful for counters and mathematical operations.
4
4
5
5
### Import
6
6
@@ -11,12 +11,12 @@ import { inc } from '@fullstacksjs/toolbox';
11
11
### Signature
12
12
13
13
``` typescript copy
14
- function inc(n : number , step ? : number ): number {}
14
+ function inc(n : number ): number {}
15
15
```
16
16
17
17
### Examples
18
18
19
19
``` typescript copy
20
- inc (3 ) // 4
21
- inc (3 , 2 ) // 5
20
+ inc (3 ) // 4
21
+ inc (5 ) // 6
22
22
```
Original file line number Diff line number Diff line change
1
+ import { dec } from './dec' ;
2
+
3
+ describe ( 'dec' , ( ) => {
4
+ it ( 'should decrement by 1' , ( ) => {
5
+ expect ( dec ( 2 ) ) . toBe ( 1 ) ;
6
+ expect ( dec ( 5 ) ) . toBe ( 4 ) ;
7
+ } ) ;
8
+ } ) ;
Original file line number Diff line number Diff line change 1
1
/**
2
- * Decrements a number by 1 or a specified step .
2
+ * Decrements a number by 1.
3
3
*
4
4
* @param {number } n - The number to decrement.
5
- * @param {number } [step=1] - The step size to decrement by. Defaults to 1.
6
5
* @returns {number } The decremented number.
7
6
*
8
7
* @example
9
- * dec(3) // 2
10
- * dec(3, 2) // 1
8
+ * dec(3) // 2
9
+ * dec(5) // 4
11
10
*/
12
- export function dec ( n : number , step : number = 1 ) : number {
13
- return n - step ;
11
+
12
+ export function dec ( n : number ) : number {
13
+ return n - 1 ;
14
14
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import { inc } from './inc' ;
2
2
3
3
describe ( 'inc' , ( ) => {
4
- it ( 'should increment by 1 when no step is provided ' , ( ) => {
4
+ it ( 'should increment by 1' , ( ) => {
5
5
expect ( inc ( 0 ) ) . toBe ( 1 ) ;
6
6
expect ( inc ( 5 ) ) . toBe ( 6 ) ;
7
7
} ) ;
8
-
9
- it ( 'should increment by the given step' , ( ) => {
10
- expect ( inc ( 0 , 2 ) ) . toBe ( 2 ) ;
11
- expect ( inc ( 5 , 3 ) ) . toBe ( 8 ) ;
12
- } ) ;
13
-
14
- it ( 'should handle negative steps correctly' , ( ) => {
15
- expect ( inc ( 5 , - 2 ) ) . toBe ( 3 ) ;
16
- } ) ;
17
8
} ) ;
Original file line number Diff line number Diff line change 1
1
/**
2
- * Increments a number by 1 or a specified step .
2
+ * Increments a number by 1.
3
3
*
4
4
* @param {number } n - The number to increment.
5
- * @param {number } [step=1] - The step size to increment by. Defaults to 1.
6
5
* @returns {number } The incremented number.
7
6
*
8
7
* @example
9
- * inc(3) // 4
10
- * inc(3, 2) // 5
8
+ * inc(3) // 4
9
+ * inc(5) // 6
11
10
*/
12
- export function inc ( n : number , step : number = 1 ) : number {
13
- return n + step ;
11
+
12
+ export function inc ( n : number ) : number {
13
+ return n + 1 ;
14
14
}
You can’t perform that action at this time.
0 commit comments