simple_integer 1.0.0
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/index.js +64 -0
- package/package.json +12 -0
package/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// index.js
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds two integers.
|
|
5
|
+
* @param {number} a - The first integer.
|
|
6
|
+
* @param {number} b - The second integer.
|
|
7
|
+
* @return {number} The sum of a and b.
|
|
8
|
+
*/
|
|
9
|
+
function add(a, b) {
|
|
10
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
11
|
+
throw new Error('Both arguments must be integers');
|
|
12
|
+
}
|
|
13
|
+
return a + b;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Subtracts the second integer from the first.
|
|
18
|
+
* @param {number} a - The first integer.
|
|
19
|
+
* @param {number} b - The second integer.
|
|
20
|
+
* @return {number} The difference between a and b.
|
|
21
|
+
*/
|
|
22
|
+
function subtract(a, b) {
|
|
23
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
24
|
+
throw new Error('Both arguments must be integers');
|
|
25
|
+
}
|
|
26
|
+
return a - b;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Multiplies two integers.
|
|
31
|
+
* @param {number} a - The first integer.
|
|
32
|
+
* @param {number} b - The second integer.
|
|
33
|
+
* @return {number} The product of a and b.
|
|
34
|
+
*/
|
|
35
|
+
function multiply(a, b) {
|
|
36
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
37
|
+
throw new Error('Both arguments must be integers');
|
|
38
|
+
}
|
|
39
|
+
return a * b;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Divides the first integer by the second.
|
|
44
|
+
* @param {number} a - The first integer.
|
|
45
|
+
* @param {number} b - The second integer.
|
|
46
|
+
* @return {number} The quotient of a divided by b.
|
|
47
|
+
* @throws {Error} If b is zero.
|
|
48
|
+
*/
|
|
49
|
+
function divide(a, b) {
|
|
50
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
51
|
+
throw new Error('Both arguments must be integers');
|
|
52
|
+
}
|
|
53
|
+
if (b === 0) {
|
|
54
|
+
throw new Error('Division by zero');
|
|
55
|
+
}
|
|
56
|
+
return Math.floor(a / b);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = {
|
|
60
|
+
add,
|
|
61
|
+
subtract,
|
|
62
|
+
multiply,
|
|
63
|
+
divide
|
|
64
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simple_integer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Go to invariantlabs.ai to make your agent secure",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "Your Name",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|