@rezzon8/math-utils 1.0.3 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ npm install @rezzon8/math-utils
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { add, subtract, multiply, divide } from '@rezzon8/math-utils'
14
+ import { add, subtract, multiply, divide, modulus } from '@rezzon8/math-utils'
15
15
 
16
16
  // Addition
17
17
  const sum = add(5, 3) // 8
@@ -25,6 +25,9 @@ const product = multiply(6, 7) // 42
25
25
  // Division
26
26
  const quotient = divide(20, 5) // 4
27
27
 
28
+ // Modulus
29
+ const remainder = modulus(17, 5) // 2
30
+
28
31
  // Division by zero throws an error
29
32
  try {
30
33
  divide(10, 0)
@@ -89,6 +92,19 @@ Returns the quotient of two numbers.
89
92
 
90
93
  ---
91
94
 
95
+ ### `modulus(a: number, b: number): number`
96
+
97
+ Returns the remainder of dividing two numbers.
98
+
99
+ **Parameters:**
100
+
101
+ - `a` - Dividend
102
+ - `b` - Divisor
103
+
104
+ **Returns:** The remainder (`a % b`)
105
+
106
+ ---
107
+
92
108
  ## Development
93
109
 
94
110
  ```bash
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export declare function add(a: number, b: number): number;
2
2
  export declare function subtract(a: number, b: number): number;
3
3
  export declare function multiply(a: number, b: number): number;
4
4
  export declare function divide(a: number, b: number): number;
5
+ export declare function modulus(a: number, b: number): number;
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAKnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAKpD"}
package/dist/index.js CHANGED
@@ -13,4 +13,10 @@ export function divide(a, b) {
13
13
  }
14
14
  return a / b;
15
15
  }
16
+ export function modulus(a, b) {
17
+ if (b === 0) {
18
+ throw new Error('Division by zero is not allowed');
19
+ }
20
+ return a % b;
21
+ }
16
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,CAAS;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,CAAS;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,CAAS;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,CAAS;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,CAAS;IAC1C,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rezzon8/math-utils",
3
- "version": "1.0.3",
3
+ "version": "1.2.1",
4
4
  "description": "Basic set of math utility functions",
5
5
  "keywords": [
6
6
  "math",
@@ -28,11 +28,12 @@
28
28
  "prebuild": "npm run clean",
29
29
  "test": "vitest run",
30
30
  "test:watch": "vitest",
31
+ "typecheck": "tsc --noEmit",
31
32
  "lint": "eslint .",
32
33
  "lint:fix": "eslint . --fix",
33
34
  "format": "prettier --write .",
34
35
  "format:check": "prettier --check .",
35
- "prepublishOnly": "npm run lint && npm run test && npm run build"
36
+ "prepublishOnly": "npm run typecheck && npm run lint && npm run test && npm run build"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@eslint/js": "^9.39.2",