Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/float.js

Issue 877193002: Upgrade vulcanize to 0.7.6. (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/float.js
diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/float.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/float.js
index 644ff4b96f5368cbc410792157c1a77c9a9f603b..9e3eff4decfd939d862794b5050bea83481795c9 100644
--- a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/float.js
+++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/float.js
@@ -1,8 +1,7 @@
'use strict';
-
-var Type = require('../type');
-
+var common = require('../common');
+var Type = require('../type');
var YAML_FLOAT_PATTERN = new RegExp(
'^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
@@ -11,16 +10,23 @@ var YAML_FLOAT_PATTERN = new RegExp(
'|[-+]?\\.(?:inf|Inf|INF)' +
'|\\.(?:nan|NaN|NAN))$');
+function resolveYamlFloat(data) {
+ if (null === data) {
+ return false;
+ }
-function resolveYamlFloat(state) {
- var value, sign, base, digits,
- object = state.result;
+ var value, sign, base, digits;
- if (!YAML_FLOAT_PATTERN.test(object)) {
+ if (!YAML_FLOAT_PATTERN.test(data)) {
return false;
}
+ return true;
+}
- value = object.replace(/_/g, '').toLowerCase();
+function constructYamlFloat(data) {
+ var value, sign, base, digits;
+
+ value = data.replace(/_/g, '').toLowerCase();
sign = '-' === value[0] ? -1 : 1;
digits = [];
@@ -29,12 +35,10 @@ function resolveYamlFloat(state) {
}
if ('.inf' === value) {
- state.result = (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
- return true;
+ return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
} else if ('.nan' === value) {
- state.result = NaN;
- return true;
+ return NaN;
} else if (0 <= value.indexOf(':')) {
value.split(':').forEach(function (v) {
@@ -49,16 +53,13 @@ function resolveYamlFloat(state) {
base *= 60;
});
- state.result = sign * value;
- return true;
+ return sign * value;
} else {
- state.result = sign * parseFloat(value, 10);
- return true;
+ return sign * parseFloat(value, 10);
}
}
-
function representYamlFloat(object, style) {
if (isNaN(object)) {
switch (style) {
@@ -87,22 +88,23 @@ function representYamlFloat(object, style) {
case 'camelcase':
return '-.Inf';
}
+ } else if (common.isNegativeZero(object)) {
+ return '-0.0';
} else {
return object.toString(10);
}
}
-
function isFloat(object) {
return ('[object Number]' === Object.prototype.toString.call(object)) &&
- (0 !== object % 1);
+ (0 !== object % 1 || common.isNegativeZero(object));
}
-
module.exports = new Type('tag:yaml.org,2002:float', {
- loadKind: 'scalar',
- loadResolver: resolveYamlFloat,
- dumpPredicate: isFloat,
- dumpRepresenter: representYamlFloat,
- dumpDefaultStyle: 'lowercase'
+ kind: 'scalar',
+ resolve: resolveYamlFloat,
+ construct: constructYamlFloat,
+ predicate: isFloat,
+ represent: representYamlFloat,
+ defaultStyle: 'lowercase'
});

Powered by Google App Engine
This is Rietveld 408576698