1.2.0 • Published 5 months ago

arithmetic2json v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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
*/
1.2.0

5 months ago

1.0.0

6 months ago