Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename long and short #53

Merged
merged 2 commits into from Sep 3, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -25,8 +25,8 @@ module.exports = function(val, options){
options = options || {};
if ('string' == typeof val) return parse(val);
return options.long

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use options['long'], since the reserved word problem can still affect object properties. Also, my syntax checker complained about these not being on the same line, so maybe

return options['long'] ? fmtLong(val) : fmtShort(val);

would be better.

? long(val)
: short(val);
? fmtLong(val)
: fmtShort(val);
};

/**
Expand Down Expand Up @@ -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';
Expand All @@ -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')
Expand Down