1.0.19 ā€¢ Published 2 months ago

@dtable/formula v1.0.19

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

dtable-formula

Install

npm install --save @dtable/formula

Run tests

npm run test

Examples

List some simple examples for quick start.

prase text expression

import { formula } from "@dtable/formula";

formula("1 + 2"); // 3

get lexer result

import { tokenize } from "@dtable/formula";

tokenize("1 + 2");

// [
//   { image: "1", tokenType: { name: "Number" } },
//   { image: "+", tokenType: { name: "Plus" } },
//   { image: "2", tokenType: { name: "Number" } },
// ];

use params

import { formula } from "@dtable/formula";

formula("{Number1} + {Number2}", { Number1: 1, Number2: 2 }); // 3

All Functions And Operators

NameTypeDescription
{}Param operatorreference to a param.
!=Logical operatorCheck if one value is not equal to another value.
=Logical operatorCompare if one value is equal to another value.
>=Logical operatorCompare if one value is greater than, or equal to, another value.
>Logical operatorCompare if one value is greater than another value
<=Logical operatorCompare if one value is less than, or equal to, another value.
<Logical operatorCompare if one value is less than another value.
IF()Logical functionIt allows you to make logical comparisons between a value and what you expect
+Numeric operatorAdd together two values.
-Numeric operatorSubtract two values.
*Numeric operatorMultiply two values.
/Numeric operatorDivide two values.
ABS()Numeric functionReturns the absolute value.
ROUND()Numeric functionRounds the value to the number of decimal places given by precision.
ROUNDUP()Numeric functionRounds the value to the number of decimal places given by precision, always rounding up.
ROUNDDOWN()Numeric functionRounds the value to the number of decimal places given by precision, always rounding down.
INT()Numeric functionReturns the greatest integer that is less than or equal to the specified value.
MAX()Numeric functionReturns the largest of the given numbers.
MIN()Numeric functionReturns the smallest of the given numbers.
&Strings operatorConcatenate strings.
CONCATENATE()Strings functionConcatenate strings.
REPT()Strings functionRepeats text a given number of times.
LEN()Strings functionGet the length of the string
DATETIME_FORMAT()Date functionReformat the data from the date-type field into a string of your specifications
SET_TIMEZONE()Date functionSet the time zone for the date

Author

šŸ‘¤ zhangchao1997

1.0.19

2 months ago

1.0.18

2 months ago

1.0.17

2 months ago

1.0.10-1

1 year ago

1.0.10-0

1 year ago

1.0.16

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago