Comparing version 0.0.1 to 0.0.2
12
human.js
@@ -10,4 +10,2 @@ /** | ||
var util = require('util'); | ||
module.exports = human; | ||
@@ -34,8 +32,10 @@ | ||
var time = Math.floor(times[i]); | ||
var name = names[i]; | ||
if (time > 1) | ||
return util.format('%d %ss %s', time, names[i], suffix); | ||
else if (time === 1) | ||
return util.format('%d %s %s', time, names[i], suffix); | ||
name += 's'; | ||
if (time >= 1) | ||
return time + ' ' + name + ' ' + suffix; | ||
} | ||
return util.format('0 seconds %s', suffix); | ||
return '0 seconds ' + suffix; | ||
} |
{ | ||
"name": "human-time", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "show seconds in a human-readable form", | ||
@@ -5,0 +5,0 @@ "main": "human.js", |
@@ -7,8 +7,14 @@ #!/usr/bin/env node | ||
var rel; | ||
[ | ||
[600, '10 minutes ago'], | ||
[60, '1 minute ago'], | ||
[new Date(), '0 seconds ago'] | ||
].forEach(function (o) { | ||
var t = o[0]; | ||
var s = o[1]; | ||
rel = human(600); | ||
assert.equal(rel, '10 minutes ago'); | ||
var rel = human(t); | ||
rel = human(new Date()); | ||
assert.equal(rel, '0 seconds ago'); | ||
console.log('human(%j) [%j] == %j', t, rel, s); | ||
assert.equal(rel, s); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5841
48
7