Skip to content

Commit 26e470d

Browse files
fix: remove step form inc & dec functions
1 parent d853a8b commit 26e470d

File tree

7 files changed

+29
-47
lines changed

7 files changed

+29
-47
lines changed

docs/pages/number/dec.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# dec
22

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.
44

55
### Import
66

@@ -11,12 +11,12 @@ import { dec } from '@fullstacksjs/toolbox';
1111
### Signature
1212

1313
```typescript copy
14-
function dec(n: number, step?: number): number {}
14+
function dec(n: number): number {}
1515
```
1616

1717
### Examples
1818

1919
```typescript copy
20-
dec(3) // 2
21-
dec(3, 2) // 1
20+
dec(3) // 2
21+
dec(5) // 4
2222
```

docs/pages/number/inc.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# inc
22

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.
44

55
### Import
66

@@ -11,12 +11,12 @@ import { inc } from '@fullstacksjs/toolbox';
1111
### Signature
1212

1313
```typescript copy
14-
function inc(n: number, step?: number): number {}
14+
function inc(n: number): number {}
1515
```
1616

1717
### Examples
1818

1919
```typescript copy
20-
inc(3) // 4
21-
inc(3, 2) // 5
20+
inc(3) // 4
21+
inc(5) // 6
2222
```

src/number/dec.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
});

src/number/dec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
2-
* Decrements a number by 1 or a specified step.
2+
* Decrements a number by 1.
33
*
44
* @param {number} n - The number to decrement.
5-
* @param {number} [step=1] - The step size to decrement by. Defaults to 1.
65
* @returns {number} The decremented number.
76
*
87
* @example
9-
* dec(3) // 2
10-
* dec(3, 2) // 1
8+
* dec(3) // 2
9+
* dec(5) // 4
1110
*/
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;
1414
}

src/number/des.spec.ts

-17
This file was deleted.

src/number/inc.spec.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import { inc } from './inc';
22

33
describe('inc', () => {
4-
it('should increment by 1 when no step is provided', () => {
4+
it('should increment by 1', () => {
55
expect(inc(0)).toBe(1);
66
expect(inc(5)).toBe(6);
77
});
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-
});
178
});

src/number/inc.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
2-
* Increments a number by 1 or a specified step.
2+
* Increments a number by 1.
33
*
44
* @param {number} n - The number to increment.
5-
* @param {number} [step=1] - The step size to increment by. Defaults to 1.
65
* @returns {number} The incremented number.
76
*
87
* @example
9-
* inc(3) // 4
10-
* inc(3, 2) // 5
8+
* inc(3) // 4
9+
* inc(5) // 6
1110
*/
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;
1414
}

0 commit comments

Comments
 (0)