From 772800a30b5dbec03ea6f236e1e068d3e513d6dd Mon Sep 17 00:00:00 2001 From: Julien Sanchez Date: Wed, 23 Aug 2017 15:48:14 +0200 Subject: [PATCH] Release v1.7.0 --- History.md | 7 ++++++ README.md | 2 +- RELEASE | 2 +- bower.json | 2 +- build/quantities.js | 54 ++++++++++++++++++++++++--------------------- package.json | 2 +- src/quantities.js | 2 +- 7 files changed, 41 insertions(+), 30 deletions(-) diff --git a/History.md b/History.md index f2f4e44..e15bf8c 100644 --- a/History.md +++ b/History.md @@ -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 ------------------ diff --git a/README.md b/README.md index 764e52a..6e97093 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/RELEASE b/RELEASE index ec70f75..bd8bf88 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -1.6.6 +1.7.0 diff --git a/bower.json b/bower.json index 07f0960..e7992bc 100644 --- a/bower.json +++ b/bower.json @@ -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": [ diff --git a/build/quantities.js b/build/quantities.js index 531cb2f..b796c1d 100644 --- a/build/quantities.js +++ b/build/quantities.js @@ -257,12 +257,13 @@ var UNITS = { "" : [["fathom","fathoms"], 1.829, "length", [""]], "" : [["pica","picas"], 0.00423333333, "length", [""]], "" : [["pt","point","points"], 0.000352777778, "length", [""]], - "" : [["z","red-shift"], 1.302773e26, "length", [""]], + "" : [["z","red-shift", "redshift"], 1.302773e26, "length", [""]], "" : [["AU","astronomical-unit"], 149597900000, "length", [""]], "":[["ls","light-second"], 299792500, "length", [""]], "":[["lmin","light-minute"], 17987550000, "length", [""]], "" : [["ly","light-year"], 9460528000000000, "length", [""]], "" : [["pc","parsec","parsecs"], 30856780000000000, "length", [""]], + "" : [["DM"], 1828.8, "length", [""]], /* mass */ "" : [["kg","kilogram","kilograms"], 1.0, "mass", [""]], @@ -430,6 +431,8 @@ var UNITS = { /* power */ "" : [["W","watt","watts"], 1.0, "power", ["","",""], ["","",""]], + "" : [["VA"], 1.0, "power", ["","",""], ["","",""]], + "" : [["var","Var","VAr","VAR"], 1.0, "power", ["","",""], ["","",""]], "" : [["hp","horsepower"], 745.699872, "power", ["","",""], ["","",""]], /* radiation */ @@ -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"); - } + } }); } @@ -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]; } @@ -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]))"); @@ -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"); } @@ -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); }; /** @@ -1992,7 +1996,7 @@ function simplify (units) { }); } -Qty$1.version = "1.6.6"; +Qty$1.version = "1.7.0"; return Qty$1; diff --git a/package.json b/package.json index a1b33ce..b31d50a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/quantities.js b/src/quantities.js index e29597e..04d37f9 100644 --- a/src/quantities.js +++ b/src/quantities.js @@ -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;