arithmetic2json
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

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

Package Sidebar

Install

npm i arithmetic2json

Weekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

34.8 kB

Total Files

10

Last publish

Collaborators

  • muffinmann