From f56dd06f7ffc19637c6a8dc033e485f3896248f2 Mon Sep 17 00:00:00 2001 From: Sergey Kamardin Date: Tue, 22 Sep 2015 14:25:36 +0300 Subject: [PATCH 1/2] Rename `long` and `short` Cause it is reserved words in ES1-3. It is ok for ES2015, but it still breaks down Closure Compiler. --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 4f92771..29383c7 100644 --- a/index.js +++ b/index.js @@ -25,8 +25,8 @@ module.exports = function(val, options){ options = options || {}; if ('string' == typeof val) return parse(val); return options.long - ? long(val) - : short(val); + ? fmtLong(val) + : fmtShort(val); }; /** @@ -90,7 +90,7 @@ function parse(str) { * @api private */ -function short(ms) { +function fmtShort(ms) { if (ms >= d) return Math.round(ms / d) + 'd'; if (ms >= h) return Math.round(ms / h) + 'h'; if (ms >= m) return Math.round(ms / m) + 'm'; @@ -106,7 +106,7 @@ function short(ms) { * @api private */ -function long(ms) { +function fmtLong(ms) { return plural(ms, d, 'day') || plural(ms, h, 'hour') || plural(ms, m, 'minute') From 004d137cdd70c9f210361839b8ff5db77c89cb5c Mon Sep 17 00:00:00 2001 From: Sergey Kamardin Date: Wed, 30 Sep 2015 23:40:11 +0300 Subject: [PATCH 2/2] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 29383c7..9f1fd26 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ var y = d * 365.25; module.exports = function(val, options){ options = options || {}; if ('string' == typeof val) return parse(val); - return options.long + return options['long'] ? fmtLong(val) : fmtShort(val); };