GitXplorerGitXplorer
s

node-restraints

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
39c84a8a851fda51b09e599556a830d475475850

readme

ssaambarati committed 12 years ago
Unverified
2262cbd8146dde545104a19300ffb74f55adff6c

fixed package.json

ssaambarati committed 12 years ago
Unverified
d08c7521ee650e6763bc4e37b3ea2c22adf91cca

readme, v0.0.2, browserify field added to package.json

ssaambarati committed 12 years ago
Unverified
ac90a5dcb9b126914e605290ca2c3e213280b8df

removed 2

ssaambarati committed 12 years ago
Unverified
9d45f02c5c9fc6e8d1355212750e33d3ac555d0b

added system of equations

ssaambarati committed 12 years ago
Unverified
0d4903d514df61e784d16247718c5c20add2d06c

refined API to only accept hashes as argument

ssaambarati committed 12 years ago

README

The README file for this repository.

#restraints

use

npm install restraints

example - Fahrenheit to Celcius -- Celcius to Farhenheit

var restraints = require('restraints')
   , converter = restraints('9 * c = 5 * (f - 32)')
//when either the value for 'c' or 'f' are updated, their value will be attached to converter

converter({c : 21})
converter.f === 69.8
converter('forget') //all values are forgotten
converter({f : 80})
converter.c === 26.66666

another example

restraints is useful for creating a set of mathematical equations:

var equation = restraints('x^y = z')
equation({x:10, y:2})
equation.z === 100 //10^2=100

equation('forget') //all values are forgetten

equation({x:2, z:8})
equation.y === 3 //2^3=8

string of equations

var f = restraints('x = y = z')
f({x:10})
assert(f.y === 10)
assert(f.z === 10)

var f = restraints('x = y^2 = z^3')
f({y : 10})
assert(f.x === Math.pow(f.y, 2))
assert(f.z === Math.pow(f.y, 2/3))
assert(f.z === Math.pow(f.x, 1/3))