safe-math-ops 0.0.3 → 0.0.5

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 (2) hide show
  1. package/dist/index.js +1 -40
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,40 +1 @@
1
- // src/libs/calcHighestDecimalPoint.ts
2
- function calcHighestDecimalPoint(...numbers) {
3
- const r = numbers.filter((v) => typeof v === "number").map((v) => (v.toString().split(".")?.[1] || "").length).sort((a, b) => b - a);
4
- return r?.[0] || 0;
5
- }
6
-
7
- // src/libs/add.ts
8
- function add(...numbers) {
9
- const highDecimalPoint = calcHighestDecimalPoint(...numbers);
10
- return parseFloat(numbers.filter((v) => typeof v === "number").reduce((a, b) => a + b).toFixed(highDecimalPoint));
11
- }
12
-
13
- // src/libs/divide.ts
14
- function divide(...numbers) {
15
- const highDecimalPoint = calcHighestDecimalPoint(...numbers);
16
- return parseFloat(numbers.filter((v) => typeof v === "number").reduce((a, b) => a / b).toFixed(highDecimalPoint));
17
- }
18
-
19
- // src/libs/multiply.ts
20
- function multiply(...numbers) {
21
- const highDecimalPoint = calcHighestDecimalPoint(...numbers);
22
- return parseFloat(numbers.filter((v) => typeof v === "number").reduce((a, b) => a * b).toFixed(highDecimalPoint));
23
- }
24
-
25
- // src/libs/substract.ts
26
- function substract(...numbers) {
27
- const highDecimalPoint = calcHighestDecimalPoint(...numbers);
28
- return parseFloat(numbers.filter((v) => typeof v === "number").reduce((a, b) => a - b).toFixed(highDecimalPoint));
29
- }
30
-
31
- // src/index.ts
32
- var src_default = { add, substract, multiply, divide, calcHighestDecimalPoint };
33
- export {
34
- substract,
35
- multiply,
36
- divide,
37
- src_default as default,
38
- calcHighestDecimalPoint,
39
- add
40
- };
1
+ var s={};setInterval(()=>{s={}},15000);var i=s;function c(l,o){let t=0;for(let e of l){if(o==="add")t+=e;if(o==="substract")t-=e;if(o==="divide")t/=e;if(o==="multiply")t*=e}t=t*l.length+"";let r=i[t];if(!r)i[t]=l.filter((e)=>typeof e==="number").map((e)=>(e.toString().split(".")?.[1]||"").length).sort((e,a)=>a-e)?.[0]||0,r=i[t];return{result:r,key:t}}function m(...l){let o=c(l,"add"),t="a"+o.key,r=i[t];if(!r)i[t]=parseFloat(l.filter((e)=>typeof e==="number").reduce((e,a)=>e+a).toFixed(o.result)),r=i[t];return r}function f(...l){let o=c(l,"divide"),t="d"+o.key,r=i[t];if(!r)i[t]=parseFloat(l.filter((e)=>typeof e==="number").reduce((e,a)=>e/a).toFixed(o.result)),r=i[t];return r}function n(...l){let o=c(l,"multiply"),t="m"+o.key,r=i[t];if(!r)i[t]=parseFloat(l.filter((e)=>typeof e==="number").reduce((e,a)=>e*a).toFixed(o.result)),r=i[t];return r}function u(...l){let o=c(l,"substract"),t="s"+o.key,r=i[t];if(!r)i[t]=parseFloat(l.filter((e)=>typeof e==="number").reduce((e,a)=>e-a).toFixed(o.result)),r=i[t];return r}var B={add:m,substract:u,multiply:n,divide:f,calcHighestDecimalPoint:c};export{u as substract,n as multiply,f as divide,B as default,c as calcHighestDecimalPoint,m as add};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "safe-math-ops",
3
3
  "module": "src/index.ts",
4
4
  "type": "module",
5
- "version": "0.0.3",
5
+ "version": "0.0.5",
6
6
  "devDependencies": {
7
7
  "@types/bun": "latest",
8
8
  "rimraf": "^6.1.3"
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "author": "ctev",
19
19
  "scripts": {
20
- "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declaration",
20
+ "build": "bun build --minify --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declaration",
21
21
  "build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json",
22
22
  "postbuild": "rimraf tsconfig.types.tsbuildinfo"
23
23
  },