☕️ Classic, reliable, trusted test framework for Node.js and the browser
remove unused code in ms module
38elements709a09efd74e
diff --git a/lib/ms.js b/lib/ms.jsindex 95908560..2fdcaf32 100644--- a/lib/ms.js+++ b/lib/ms.js@@ -13,22 +13,15 @@ var y = d * 365.25;/*** Parse or format the given `val`.*- * Options:- *- * - `long` verbose formatting [false]- ** @api public* @param {string|number} val- * @param {Object} options* @return {string|number}*/-module.exports = function (val, options) {- options = options || {};+module.exports = function (val) {if (typeof val === 'string') {return parse(val);}- // https://github.com/mochajs/mocha/pull/1035- return options['long'] ? longFormat(val) : shortFormat(val);+ return format(val);};/**@@ -74,13 +67,13 @@ function parse (str) {}/**- * Short format for `ms`.+ * Format for `ms`.** @api private* @param {number} ms* @return {string}*/-function shortFormat (ms) {+function format (ms) {if (ms >= d) {return Math.round(ms / d) + 'd';}@@ -95,36 +88,3 @@ function shortFormat (ms) {}return ms + 'ms';}--/**- * Long format for `ms`.- *- * @api private- * @param {number} ms- * @return {string}- */-function longFormat (ms) {- return plural(ms, d, 'day') ||- plural(ms, h, 'hour') ||- plural(ms, m, 'minute') ||- plural(ms, s, 'second') ||- ms + ' ms';-}--/**- * Pluralization helper.- *- * @api private- * @param {number} ms- * @param {number} n- * @param {string} name- */-function plural (ms, n, name) {- if (ms < n) {- return;- }- if (ms < n * 1.5) {- return Math.floor(ms / n) + ' ' + name;- }- return Math.ceil(ms / n) + ' ' + name + 's';-}diff --git a/test/unit/ms.spec.js b/test/unit/ms.spec.jsindex e7b1d358..08443912 100644--- a/test/unit/ms.spec.js+++ b/test/unit/ms.spec.js@@ -21,45 +21,24 @@ describe('.ms()', function () {it('should return short format', function () {expect(ms(2000)).to.equal('2s');});-- it('should return long format', function () {- expect(ms(2000, { long: true })).to.equal('2 seconds');- expect(ms(1000, { long: true })).to.equal('1 second');- expect(ms(1010, { long: true })).to.equal('1 second');- });});describe('minutes representation', function () {it('should return short format', function () {expect(ms(time.minutes(1))).to.equal('1m');});-- it('should return long format', function () {- expect(ms(time.minutes(1), { long: true })).to.equal('1 minute');- expect(ms(time.minutes(3), { long: true })).to.equal('3 minutes');- });});describe('hours representation', function () {it('should return short format', function () {expect(ms(time.hours(1))).to.equal('1h');});-- it('should return long format', function () {- expect(ms(time.hours(1), { long: true })).to.equal('1 hour');- expect(ms(time.hours(3), { long: true })).to.equal('3 hours');- });});describe('days representation', function () {it('should return short format', function () {expect(ms(time.days(1))).to.equal('1d');});-- it('should return long format', function () {- expect(ms(time.days(1), { long: true })).to.equal('1 day');- expect(ms(time.days(3), { long: true })).to.equal('3 days');- });});describe('Getting string value', function () {