Added unit drop (gtt)

This commit is contained in:
jos 2014-06-09 09:34:53 +02:00
parent 490494d8ef
commit 64368ec4ad
4 changed files with 16 additions and 3 deletions

View File

@ -8,14 +8,19 @@ https://github.com/josdejong/mathjs
- Implemented function `unaryplus` and unary plus operator.
- Added constant `phi`, the golden ratio (`phi = 1.618...`).
- Added constant `version`, returning the version number of math.js as string.
- Added unit `drop` (`gtt`).
- Fixed not being able to load math.js using AMD/require.js.
- Removed matrix support from conditional function `ifElse`.
- Removed automatic assignment of expression results to variable `ans`.
This functionality can be restored by preprocessing every evaluation,
This functionality can be restored by pre- or postprocessing every evaluation,
something like:
```js
function evalWithAns (expr, scope) {
return math.eval('ans=(' + expr + ')', scope);
var ans = math.eval(expr, scope);
if (scope) {
scope.ans = ans;
}
return ans;
}
```

View File

@ -90,7 +90,7 @@ Base | Unit
Length | meter (m), inch (in), foot (ft), yard (yd), mile (mi), link (li), rod (rd), chain (ch), angstrom, mil
Surface | m2, sqin, sqft, sqyd, sqmi, sqrd, sqch, sqmil
Volume | m3, litre (l, L), cc, cuin, cuft, cuyd, teaspoon, tablespoon
Liquid | volume minim (min), fluiddram (fldr), fluidounce (fldz), gill (gi), cup (cp), pint (pt), quart (qt), gallon (gal), beerbarrel (bbl), oilbarrel (obl), hogshead
Liquid | volume minim (min), fluiddram (fldr), fluidounce (fldz), gill (gi), cup (cp), pint (pt), quart (qt), gallon (gal), beerbarrel (bbl), oilbarrel (obl), hogshead, drop (gtt)
Angles | rad, deg, grad, cycle
Time | second (s), seconds, minute, minutes, hour (h), hours, day, days
Mass | gram(g), tonne, ton, grain (gr), dram(dr), ounce (oz), poundmass (lbm), hundredweight (cwt), stick

View File

@ -672,6 +672,8 @@ var UNITS = {
teaspoon: {name: 'teaspoon', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000005, offset: 0}, // 5 mL
tablespoon: {name: 'tablespoon', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000015, offset: 0}, // 15 mL
//{name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL // not possible, we have already another cup
drop: {name: 'drop', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 5e-8, offset: 0}, // 0.05 mL = 5e-8 m3
gtt: {name: 'gtt', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 5e-8, offset: 0}, // 0.05 mL = 5e-8 m3
// Liquid volume
minim: {name: 'minim', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL
@ -805,6 +807,7 @@ var PLURALS = {
beerbarrels: 'beerbarrel',
oilbarrels: 'oilbarrel',
hogsheads: 'hogshead',
gtts: 'gtt',
grams: 'gram',
tons: 'ton',

View File

@ -58,4 +58,9 @@ describe('IndexError', function () {
assert.equal(err.toString(), 'IndexError: Index out of range (6 > 3)');
});
it('should throw an error when constructed without new operator', function() {
assert.throws(function () {
IndexError(5);
});
});
});