Chromium Code Reviews

Unified Diff: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/timestamp.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.
Jump to:
View side-by-side diff with in-line comments
Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/timestamp.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
index 34aa693a4b73d1bb6dc403026c4785a669d4492e..dc8cf15a06f424e470872c420e6f409ded6e5a4a 100644
--- a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
+++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
@@ -1,9 +1,7 @@
'use strict';
-
var Type = require('../type');
-
var YAML_TIMESTAMP_REGEXP = new RegExp(
'^([0-9][0-9][0-9][0-9])' + // [1] year
'-([0-9][0-9]?)' + // [2] month
@@ -16,17 +14,33 @@ var YAML_TIMESTAMP_REGEXP = new RegExp(
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
'(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
+function resolveYamlTimestamp(data) {
+ if (null === data) {
+ return false;
+ }
-function resolveYamlTimestamp(state) {
var match, year, month, day, hour, minute, second, fraction = 0,
- delta = null, tz_hour, tz_minute, data;
+ delta = null, tz_hour, tz_minute, date;
- match = YAML_TIMESTAMP_REGEXP.exec(state.result);
+ match = YAML_TIMESTAMP_REGEXP.exec(data);
if (null === match) {
return false;
}
+ return true;
+}
+
+function constructYamlTimestamp(data) {
+ var match, year, month, day, hour, minute, second, fraction = 0,
+ delta = null, tz_hour, tz_minute, date;
+
+ match = YAML_TIMESTAMP_REGEXP.exec(data);
+
+ if (null === match) {
+ throw new Error('Date resolve error');
+ }
+
// match: [1] year [2] month [3] day
year = +(match[1]);
@@ -34,8 +48,7 @@ function resolveYamlTimestamp(state) {
day = +(match[3]);
if (!match[4]) { // no hour
- state.result = new Date(Date.UTC(year, month, day));
- return true;
+ return new Date(Date.UTC(year, month, day));
}
// match: [4] hour [5] minute [6] second [7] fraction
@@ -63,25 +76,23 @@ function resolveYamlTimestamp(state) {
}
}
- data = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
if (delta) {
- data.setTime(data.getTime() - delta);
+ date.setTime(date.getTime() - delta);
}
- state.result = data;
- return true;
+ return date;
}
-
function representYamlTimestamp(object /*, style*/) {
return object.toISOString();
}
-
module.exports = new Type('tag:yaml.org,2002:timestamp', {
- loadKind: 'scalar',
- loadResolver: resolveYamlTimestamp,
- dumpInstanceOf: Date,
- dumpRepresenter: representYamlTimestamp
+ kind: 'scalar',
+ resolve: resolveYamlTimestamp,
+ construct: constructYamlTimestamp,
+ instanceOf: Date,
+ represent: representYamlTimestamp
});

Powered by Google App Engine