2.0.0 • Published 10 years ago

json-math v2.0.0

Weekly downloads
200
License
MIT
Repository
github
Last release
10 years ago

node-json-math

Package for expressing mathematical operations in JSON. Useful for storing mathematical procedures in a database.

Examples of use

var JSONMath = require('json-math');
var math = new JSONMath();
var result = math.execute({
	"a": {
		"operation": "+",
		"variables": [
			2,
			2
		]
	},
	"b": {
		"operation": "-",
		"variables": [
			5,
			1
		]
	},
	"c": {
		"operation": "*",
		"variables": [
			2,
			2
		]
	},
	"d": {
		"operation": "/",
		"variables": [
			8,
			2
		]
	}
});

After this has executed, the value of a , b, c and d will be 4.

You can also pass in an array of operations to perform, and even reference variables inside the procedure

[
	{
		"a": 3,
		"b": 4
	},
	{
		"c": {
			"operation": "+",
			"variables": [
				"a",
				"b"
			]
		}
	},
	{
		"c": "c"
	}
]

After this the value of a will be 3, b will be 4 and c will be 7.

2.0.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.1.0

10 years ago