Skip to content

Commit

Permalink
fix: update function of number
Browse files Browse the repository at this point in the history
  • Loading branch information
adyfk committed Jul 10, 2023
1 parent 123a883 commit b7ffe92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"access": "public"
},
"dependencies": {
"@adifkz/exp-p": "^1.0.15",
"@adifkz/exp-p": "^1.0.16",
"@babel/runtime": "^7.21.0",
"eslint-plugin-jest": "^27.2.1",
"expressionparser": "^1.1.5",
Expand Down
10 changes: 10 additions & 0 deletions src/v2/parser/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ export const ExamplePrefixNumber = {
result: 3,
description: "",
},
PRECISION: {
expression: "PRECISION(12.34343434, 4)",
result: 12.34,
description: "",
},
FIXED: {
expression: "FIXED(12.34343434, 4)",
result: 12.3434,
description: "",
},
ADD: {
expression: "ADD(1, 2)",
result: 3,
Expand Down
2 changes: 2 additions & 0 deletions src/v2/parser/formula-operator-prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export const createPrefixOperator = () => {
SUB: (a, b) => num(a()) - num(b()),
MUL: (a, b) => num(a()) * num(b()),
DIV: (a, b) => num(a()) / num(b()),
PRECISION: (a, b) => +(num(a()).toPrecision(num(b()))),
FIXED: (a, b) => +(num(a()).toFixed(num(b()))),
};

const PREFIX_BOOLEAN: FunctionOps = {
Expand Down

0 comments on commit b7ffe92

Please sign in to comment.