arithmetic2json
v1.2.0
Published
\
Downloads
2
Readme
Arithmetic2JSON
Arithmetic2JSON converts arithmetic expressions into a JSON object.
Example
console.log(parse("(length - 2.2) * 3 - 10 * 3"))
/**
{
"-": [
{
"*": [
{
"-": [
{
"var": "length"
},
2.2
]
},
3
]
},
{
"*": [
10,
3
]
}
]
}
*/
// or reversely
console.log(parse(
{
"-": [
{
"*": [
{
"-": [
{
"var": "length"
},
2.2
]
},
3
]
},
{
"*": [
10,
3
]
}
]
}
))
/*
(length - 2.2) * 3 - 10 * 3
*/