Skip to content

Commit

Permalink
Release v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gentooboontoo committed Aug 23, 2017
1 parent 68a53b7 commit 772800a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 30 deletions.
7 changes: 7 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.7.0 / 2017-08-23
------------------

* Fix JS allocation failure for unrealistically large exponents
* Add volt-ampere, volt-ampere-reactive and data mile definitions
* Add redshift alias

1.6.6 / 2017-02-08
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and within browsers.

### Browser

Download [latest release v1.6.6](https://raw.github.com/gentooboontoo/js-quantities/v1.6.6/build/quantities.js)
Download [latest release v1.7.0](https://raw.github.com/gentooboontoo/js-quantities/v1.7.0/build/quantities.js)
or install it with Bower:

bower install js-quantities
Expand Down
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.6
1.7.0
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-quantities",
"version": "1.6.6",
"version": "1.7.0",
"description": "JavaScript library for quantity calculation and unit conversion",
"main": "./build/quantities.js",
"keywords": [
Expand Down
54 changes: 29 additions & 25 deletions build/quantities.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ var UNITS = {
"<fathom>" : [["fathom","fathoms"], 1.829, "length", ["<meter>"]],
"<pica>" : [["pica","picas"], 0.00423333333, "length", ["<meter>"]],
"<point>" : [["pt","point","points"], 0.000352777778, "length", ["<meter>"]],
"<redshift>" : [["z","red-shift"], 1.302773e26, "length", ["<meter>"]],
"<redshift>" : [["z","red-shift", "redshift"], 1.302773e26, "length", ["<meter>"]],
"<AU>" : [["AU","astronomical-unit"], 149597900000, "length", ["<meter>"]],
"<light-second>":[["ls","light-second"], 299792500, "length", ["<meter>"]],
"<light-minute>":[["lmin","light-minute"], 17987550000, "length", ["<meter>"]],
"<light-year>" : [["ly","light-year"], 9460528000000000, "length", ["<meter>"]],
"<parsec>" : [["pc","parsec","parsecs"], 30856780000000000, "length", ["<meter>"]],
"<datamile>" : [["DM"], 1828.8, "length", ["<meter>"]],

/* mass */
"<kilogram>" : [["kg","kilogram","kilograms"], 1.0, "mass", ["<kilogram>"]],
Expand Down Expand Up @@ -430,6 +431,8 @@ var UNITS = {

/* power */
"<watt>" : [["W","watt","watts"], 1.0, "power", ["<kilogram>","<meter>","<meter>"], ["<second>","<second>","<second>"]],
"<volt-ampere>" : [["VA"], 1.0, "power", ["<kilogram>","<meter>","<meter>"], ["<second>","<second>","<second>"]],
"<volt-ampere-reactive>" : [["var","Var","VAr","VAR"], 1.0, "power", ["<kilogram>","<meter>","<meter>"], ["<second>","<second>","<second>"]],
"<horsepower>" : [["hp","horsepower"], 745.699872, "power", ["<kilogram>","<meter>","<meter>"], ["<second>","<second>","<second>"]],

/* radiation */
Expand Down Expand Up @@ -493,14 +496,14 @@ function validateUnitDefinition(unitDef, definition) {
if (UNITS[unit] === undefined) {
throw new QtyError(unitDef + ": Invalid unit definition. " +
"Unit " + unit + " in 'numerator' is not recognized");
}
}
});

denominator.forEach(function(unit) {
if (UNITS[unit] === undefined) {
throw new QtyError(unitDef + ": Invalid unit definition. " +
"Unit " + unit + " in 'denominator' is not recognized");
}
}
});
}

Expand Down Expand Up @@ -582,7 +585,7 @@ function getUnits (kind) {
*/
function getAliases(unitName) {
if (!UNIT_MAP[unitName]) {
throw new QtyError("Unit not recognized");
throw new QtyError("Unit not recognized");
}
return UNITS[UNIT_MAP[unitName]][0];
}
Expand Down Expand Up @@ -660,7 +663,9 @@ var QTY_STRING = "(" + SIGNED_NUMBER + ")?" + "\\s*([^/]*)(?:\/(.+))?";
var QTY_STRING_REGEX = new RegExp("^" + QTY_STRING + "$");

var POWER_OP = "\\^|\\*{2}";
var SAFE_POWER = "[01234]"; // scalar, length, area, volume; 4 is for SI base unit form of lux
// Allow unit powers representing scalar, length, area, volume; 4 is for some
// special case representations in SI base units.
var SAFE_POWER = "[01234]";
var TOP_REGEX = new RegExp ("([^ \\*\\d]+?)(?:" + POWER_OP + ")?(-?" + SAFE_POWER + "(?![a-zA-Z]))");
var BOTTOM_REGEX = new RegExp("([^ \\*\\d]+?)(?:" + POWER_OP + ")?(" + SAFE_POWER + "(?![a-zA-Z]))");

Expand Down Expand Up @@ -1527,7 +1532,7 @@ assign(Qty$1.prototype, {
},

// Returns a Qty that is the inverse of this Qty,
inverse: function() {
inverse: function() {
if (this.isTemperature()) {
throw new QtyError("Cannot divide with temperatures");
}
Expand Down Expand Up @@ -1783,27 +1788,26 @@ NestedMap.prototype.get = function(keys) {

NestedMap.prototype.set = function(keys, value) {

if (arguments.length > 2) {
keys = Array.prototype.slice.call(arguments, 0, -1);
value = arguments[arguments.length - 1];
}
if (arguments.length > 2) {
keys = Array.prototype.slice.call(arguments, 0, -1);
value = arguments[arguments.length - 1];
}

return keys.reduce(function(map, key, index) {
return keys.reduce(function(map, key, index) {

var childMap = map[key];
if (childMap === undefined) {
childMap = map[key] = {};
}
var childMap = map[key];
if (childMap === undefined) {
childMap = map[key] = {};
}

if (index === keys.length - 1) {
childMap.data = value;
return value;
}
else {
return childMap;
}
},
this);
if (index === keys.length - 1) {
childMap.data = value;
return value;
}
else {
return childMap;
}
}, this);
};

/**
Expand Down Expand Up @@ -1992,7 +1996,7 @@ function simplify (units) {
});
}

Qty$1.version = "1.6.6";
Qty$1.version = "1.7.0";

return Qty$1;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"main": "./build/quantities.js",
"readmeFilename": "README.md",
"description": "JavaScript library for quantity calculation and unit conversion",
"version": "1.6.6",
"version": "1.7.0",
"homepage": "http://gentooboontoo.github.io/js-quantities/",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/quantities.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import "./quantities/predicates.js";
import "./quantities/conversion.js";
import "./quantities/format.js";

Qty.version = "1.6.6";
Qty.version = "1.7.0";

export default Qty;

0 comments on commit 772800a

Please sign in to comment.