mocha 2.2.5 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/HISTORY.md +1034 -0
  2. package/bin/.eslintrc +3 -0
  3. package/bin/_mocha +12 -15
  4. package/bin/mocha +3 -10
  5. package/bin/options.js +6 -5
  6. package/lib/browser/debug.js +3 -3
  7. package/lib/browser/events.js +42 -26
  8. package/lib/browser/progress.js +37 -45
  9. package/lib/browser/tty.js +4 -5
  10. package/lib/context.js +26 -32
  11. package/lib/hook.js +5 -7
  12. package/lib/interfaces/bdd.js +21 -26
  13. package/lib/interfaces/common.js +33 -15
  14. package/lib/interfaces/exports.js +7 -7
  15. package/lib/interfaces/qunit.js +16 -17
  16. package/lib/interfaces/tdd.js +24 -28
  17. package/lib/mocha.js +140 -99
  18. package/lib/ms.js +43 -24
  19. package/lib/pending.js +2 -3
  20. package/lib/reporters/base.js +159 -138
  21. package/lib/reporters/doc.js +13 -13
  22. package/lib/reporters/dot.js +23 -19
  23. package/lib/reporters/html-cov.js +25 -19
  24. package/lib/reporters/html.js +130 -91
  25. package/lib/reporters/index.js +19 -17
  26. package/lib/reporters/json-cov.js +39 -41
  27. package/lib/reporters/json-stream.js +14 -17
  28. package/lib/reporters/json.js +16 -19
  29. package/lib/reporters/landing.js +20 -24
  30. package/lib/reporters/list.js +14 -16
  31. package/lib/reporters/markdown.js +17 -20
  32. package/lib/reporters/min.js +4 -5
  33. package/lib/reporters/nyan.js +49 -48
  34. package/lib/reporters/progress.js +20 -23
  35. package/lib/reporters/spec.js +23 -22
  36. package/lib/reporters/tap.js +15 -19
  37. package/lib/reporters/xunit.js +83 -63
  38. package/lib/runnable.js +134 -94
  39. package/lib/runner.js +291 -167
  40. package/lib/suite.js +105 -95
  41. package/lib/template.html +1 -1
  42. package/lib/test.js +3 -4
  43. package/lib/utils.js +227 -199
  44. package/mocha.css +35 -0
  45. package/mocha.js +8324 -2471
  46. package/package.json +250 -10
  47. package/lib/browser/escape-string-regexp.js +0 -11
  48. package/lib/browser/fs.js +0 -0
  49. package/lib/browser/glob.js +0 -0
  50. package/lib/browser/path.js +0 -0
package/lib/mocha.js CHANGED
@@ -8,9 +8,10 @@
8
8
  * Module dependencies.
9
9
  */
10
10
 
11
- var path = require('path')
12
- , escapeRe = require('escape-string-regexp')
13
- , utils = require('./utils');
11
+ var escapeRe = require('escape-string-regexp');
12
+ var path = require('path');
13
+ var reporters = require('./reporters');
14
+ var utils = require('./utils');
14
15
 
15
16
  /**
16
17
  * Expose `Mocha`.
@@ -22,10 +23,9 @@ exports = module.exports = Mocha;
22
23
  * To require local UIs and reporters when running in node.
23
24
  */
24
25
 
25
- if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
26
- var join = path.join
27
- , cwd = process.cwd();
28
- module.paths.push(cwd, join(cwd, 'node_modules'));
26
+ if (!process.browser) {
27
+ var cwd = process.cwd();
28
+ module.paths.push(cwd, path.join(cwd, 'node_modules'));
29
29
  }
30
30
 
31
31
  /**
@@ -34,7 +34,7 @@ if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
34
34
 
35
35
  exports.utils = utils;
36
36
  exports.interfaces = require('./interfaces');
37
- exports.reporters = require('./reporters');
37
+ exports.reporters = reporters;
38
38
  exports.Runnable = require('./runnable');
39
39
  exports.Context = require('./context');
40
40
  exports.Runner = require('./runner');
@@ -45,17 +45,16 @@ exports.Test = require('./test');
45
45
  /**
46
46
  * Return image `name` path.
47
47
  *
48
- * @param {String} name
49
- * @return {String}
50
48
  * @api private
49
+ * @param {string} name
50
+ * @return {string}
51
51
  */
52
-
53
52
  function image(name) {
54
- return __dirname + '/../images/' + name + '.png';
53
+ return path.join(__dirname, '../images', name + '.png');
55
54
  }
56
55
 
57
56
  /**
58
- * Setup mocha with `options`.
57
+ * Set up mocha with `options`.
59
58
  *
60
59
  * Options:
61
60
  *
@@ -72,23 +71,32 @@ function image(name) {
72
71
  * @param {Object} options
73
72
  * @api public
74
73
  */
75
-
76
74
  function Mocha(options) {
77
75
  options = options || {};
78
76
  this.files = [];
79
77
  this.options = options;
80
- if (options.grep) this.grep(new RegExp(options.grep));
81
- if (options.fgrep) this.grep(options.fgrep);
82
- this.suite = new exports.Suite('', new exports.Context);
78
+ if (options.grep) {
79
+ this.grep(new RegExp(options.grep));
80
+ }
81
+ if (options.fgrep) {
82
+ this.grep(options.fgrep);
83
+ }
84
+ this.suite = new exports.Suite('', new exports.Context());
83
85
  this.ui(options.ui);
84
86
  this.bail(options.bail);
85
87
  this.reporter(options.reporter, options.reporterOptions);
86
- if (null != options.timeout) this.timeout(options.timeout);
88
+ if (typeof options.timeout !== 'undefined' && options.timeout !== null) {
89
+ this.timeout(options.timeout);
90
+ }
87
91
  this.useColors(options.useColors);
88
- if (options.enableTimeouts !== null) this.enableTimeouts(options.enableTimeouts);
89
- if (options.slow) this.slow(options.slow);
92
+ if (options.enableTimeouts !== null) {
93
+ this.enableTimeouts(options.enableTimeouts);
94
+ }
95
+ if (options.slow) {
96
+ this.slow(options.slow);
97
+ }
90
98
 
91
- this.suite.on('pre-require', function (context) {
99
+ this.suite.on('pre-require', function(context) {
92
100
  exports.afterEach = context.afterEach || context.teardown;
93
101
  exports.after = context.after || context.suiteTeardown;
94
102
  exports.beforeEach = context.beforeEach || context.setup;
@@ -108,12 +116,13 @@ function Mocha(options) {
108
116
  /**
109
117
  * Enable or disable bailing on the first failure.
110
118
  *
111
- * @param {Boolean} [bail]
112
119
  * @api public
120
+ * @param {boolean} [bail]
113
121
  */
114
-
115
- Mocha.prototype.bail = function(bail){
116
- if (0 == arguments.length) bail = true;
122
+ Mocha.prototype.bail = function(bail) {
123
+ if (!arguments.length) {
124
+ bail = true;
125
+ }
117
126
  this.suite.bail(bail);
118
127
  return this;
119
128
  };
@@ -121,11 +130,10 @@ Mocha.prototype.bail = function(bail){
121
130
  /**
122
131
  * Add test `file`.
123
132
  *
124
- * @param {String} file
125
133
  * @api public
134
+ * @param {string} file
126
135
  */
127
-
128
- Mocha.prototype.addFile = function(file){
136
+ Mocha.prototype.addFile = function(file) {
129
137
  this.files.push(file);
130
138
  return this;
131
139
  };
@@ -136,24 +144,37 @@ Mocha.prototype.addFile = function(file){
136
144
  * @param {String|Function} reporter name or constructor
137
145
  * @param {Object} reporterOptions optional options
138
146
  * @api public
147
+ * @param {string|Function} reporter name or constructor
148
+ * @param {Object} reporterOptions optional options
139
149
  */
140
- Mocha.prototype.reporter = function(reporter, reporterOptions){
141
- if ('function' == typeof reporter) {
150
+ Mocha.prototype.reporter = function(reporter, reporterOptions) {
151
+ if (typeof reporter === 'function') {
142
152
  this._reporter = reporter;
143
153
  } else {
144
154
  reporter = reporter || 'spec';
145
155
  var _reporter;
146
- try { _reporter = require('./reporters/' + reporter); } catch (err) {}
147
- if (!_reporter) try { _reporter = require(reporter); } catch (err) {
148
- err.message.indexOf('Cannot find module') !== -1
149
- ? console.warn('"' + reporter + '" reporter not found')
150
- : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
156
+ // Try to load a built-in reporter.
157
+ if (reporters[reporter]) {
158
+ _reporter = reporters[reporter];
159
+ }
160
+ // Try to load reporters from process.cwd() and node_modules
161
+ if (!_reporter) {
162
+ try {
163
+ _reporter = require(reporter);
164
+ } catch (err) {
165
+ err.message.indexOf('Cannot find module') !== -1
166
+ ? console.warn('"' + reporter + '" reporter not found')
167
+ : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
168
+ }
169
+ }
170
+ if (!_reporter && reporter === 'teamcity') {
171
+ console.warn('The Teamcity reporter was moved to a package named '
172
+ + 'mocha-teamcity-reporter '
173
+ + '(https://npmjs.org/package/mocha-teamcity-reporter).');
174
+ }
175
+ if (!_reporter) {
176
+ throw new Error('invalid reporter "' + reporter + '"');
151
177
  }
152
- if (!_reporter && reporter === 'teamcity')
153
- console.warn('The Teamcity reporter was moved to a package named ' +
154
- 'mocha-teamcity-reporter ' +
155
- '(https://npmjs.org/package/mocha-teamcity-reporter).');
156
- if (!_reporter) throw new Error('invalid reporter "' + reporter + '"');
157
178
  this._reporter = _reporter;
158
179
  }
159
180
  this.options.reporterOptions = reporterOptions;
@@ -163,15 +184,19 @@ Mocha.prototype.reporter = function(reporter, reporterOptions){
163
184
  /**
164
185
  * Set test UI `name`, defaults to "bdd".
165
186
  *
166
- * @param {String} bdd
167
187
  * @api public
188
+ * @param {string} bdd
168
189
  */
169
-
170
- Mocha.prototype.ui = function(name){
190
+ Mocha.prototype.ui = function(name) {
171
191
  name = name || 'bdd';
172
192
  this._ui = exports.interfaces[name];
173
- if (!this._ui) try { this._ui = require(name); } catch (err) {}
174
- if (!this._ui) throw new Error('invalid interface "' + name + '"');
193
+ if (!this._ui) {
194
+ try {
195
+ this._ui = require(name);
196
+ } catch (err) {
197
+ throw new Error('invalid interface "' + name + '"');
198
+ }
199
+ }
175
200
  this._ui = this._ui(this.suite);
176
201
  return this;
177
202
  };
@@ -181,12 +206,11 @@ Mocha.prototype.ui = function(name){
181
206
  *
182
207
  * @api private
183
208
  */
184
-
185
- Mocha.prototype.loadFiles = function(fn){
209
+ Mocha.prototype.loadFiles = function(fn) {
186
210
  var self = this;
187
211
  var suite = this.suite;
188
212
  var pending = this.files.length;
189
- this.files.forEach(function(file){
213
+ this.files.forEach(function(file) {
190
214
  file = path.resolve(file);
191
215
  suite.emit('pre-require', global, file, self);
192
216
  suite.emit('require', require(file), file, self);
@@ -200,20 +224,19 @@ Mocha.prototype.loadFiles = function(fn){
200
224
  *
201
225
  * @api private
202
226
  */
203
-
204
227
  Mocha.prototype._growl = function(runner, reporter) {
205
228
  var notify = require('growl');
206
229
 
207
- runner.on('end', function(){
230
+ runner.on('end', function() {
208
231
  var stats = reporter.stats;
209
232
  if (stats.failures) {
210
233
  var msg = stats.failures + ' of ' + runner.total + ' tests failed';
211
234
  notify(msg, { name: 'mocha', title: 'Failed', image: image('error') });
212
235
  } else {
213
236
  notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {
214
- name: 'mocha'
215
- , title: 'Passed'
216
- , image: image('ok')
237
+ name: 'mocha',
238
+ title: 'Passed',
239
+ image: image('ok')
217
240
  });
218
241
  }
219
242
  });
@@ -225,12 +248,11 @@ Mocha.prototype._growl = function(runner, reporter) {
225
248
  * @param {RegExp|String} re
226
249
  * @return {Mocha}
227
250
  * @api public
251
+ * @param {RegExp|string} re
252
+ * @return {Mocha}
228
253
  */
229
-
230
- Mocha.prototype.grep = function(re){
231
- this.options.grep = 'string' == typeof re
232
- ? new RegExp(escapeRe(re))
233
- : re;
254
+ Mocha.prototype.grep = function(re) {
255
+ this.options.grep = typeof re === 'string' ? new RegExp(escapeRe(re)) : re;
234
256
  return this;
235
257
  };
236
258
 
@@ -240,8 +262,7 @@ Mocha.prototype.grep = function(re){
240
262
  * @return {Mocha}
241
263
  * @api public
242
264
  */
243
-
244
- Mocha.prototype.invert = function(){
265
+ Mocha.prototype.invert = function() {
245
266
  this.options.invert = true;
246
267
  return this;
247
268
  };
@@ -252,10 +273,11 @@ Mocha.prototype.invert = function(){
252
273
  * @param {Boolean} ignore
253
274
  * @return {Mocha}
254
275
  * @api public
276
+ * @param {boolean} ignore
277
+ * @return {Mocha}
255
278
  */
256
-
257
- Mocha.prototype.ignoreLeaks = function(ignore){
258
- this.options.ignoreLeaks = !!ignore;
279
+ Mocha.prototype.ignoreLeaks = function(ignore) {
280
+ this.options.ignoreLeaks = Boolean(ignore);
259
281
  return this;
260
282
  };
261
283
 
@@ -265,8 +287,7 @@ Mocha.prototype.ignoreLeaks = function(ignore){
265
287
  * @return {Mocha}
266
288
  * @api public
267
289
  */
268
-
269
- Mocha.prototype.checkLeaks = function(){
290
+ Mocha.prototype.checkLeaks = function() {
270
291
  this.options.ignoreLeaks = false;
271
292
  return this;
272
293
  };
@@ -277,7 +298,6 @@ Mocha.prototype.checkLeaks = function(){
277
298
  * @return {Mocha}
278
299
  * @api public
279
300
  */
280
-
281
301
  Mocha.prototype.fullTrace = function() {
282
302
  this.options.fullStackTrace = true;
283
303
  return this;
@@ -289,8 +309,7 @@ Mocha.prototype.fullTrace = function() {
289
309
  * @return {Mocha}
290
310
  * @api public
291
311
  */
292
-
293
- Mocha.prototype.growl = function(){
312
+ Mocha.prototype.growl = function() {
294
313
  this.options.growl = true;
295
314
  return this;
296
315
  };
@@ -301,9 +320,10 @@ Mocha.prototype.growl = function(){
301
320
  * @param {Array|String} globals
302
321
  * @return {Mocha}
303
322
  * @api public
323
+ * @param {Array|string} globals
324
+ * @return {Mocha}
304
325
  */
305
-
306
- Mocha.prototype.globals = function(globals){
326
+ Mocha.prototype.globals = function(globals) {
307
327
  this.options.globals = (this.options.globals || []).concat(globals);
308
328
  return this;
309
329
  };
@@ -314,9 +334,10 @@ Mocha.prototype.globals = function(globals){
314
334
  * @param {Boolean} colors
315
335
  * @return {Mocha}
316
336
  * @api public
337
+ * @param {boolean} colors
338
+ * @return {Mocha}
317
339
  */
318
-
319
- Mocha.prototype.useColors = function(colors){
340
+ Mocha.prototype.useColors = function(colors) {
320
341
  if (colors !== undefined) {
321
342
  this.options.useColors = colors;
322
343
  }
@@ -329,12 +350,11 @@ Mocha.prototype.useColors = function(colors){
329
350
  * @param {Boolean} inlineDiffs
330
351
  * @return {Mocha}
331
352
  * @api public
353
+ * @param {boolean} inlineDiffs
354
+ * @return {Mocha}
332
355
  */
333
-
334
356
  Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
335
- this.options.useInlineDiffs = arguments.length && inlineDiffs != undefined
336
- ? inlineDiffs
337
- : false;
357
+ this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
338
358
  return this;
339
359
  };
340
360
 
@@ -344,9 +364,10 @@ Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
344
364
  * @param {Number} timeout
345
365
  * @return {Mocha}
346
366
  * @api public
367
+ * @param {number} timeout
368
+ * @return {Mocha}
347
369
  */
348
-
349
- Mocha.prototype.timeout = function(timeout){
370
+ Mocha.prototype.timeout = function(timeout) {
350
371
  this.suite.timeout(timeout);
351
372
  return this;
352
373
  };
@@ -357,9 +378,10 @@ Mocha.prototype.timeout = function(timeout){
357
378
  * @param {Number} slow
358
379
  * @return {Mocha}
359
380
  * @api public
381
+ * @param {number} slow
382
+ * @return {Mocha}
360
383
  */
361
-
362
- Mocha.prototype.slow = function(slow){
384
+ Mocha.prototype.slow = function(slow) {
363
385
  this.suite.slow(slow);
364
386
  return this;
365
387
  };
@@ -370,13 +392,12 @@ Mocha.prototype.slow = function(slow){
370
392
  * @param {Boolean} enabled
371
393
  * @return {Mocha}
372
394
  * @api public
395
+ * @param {boolean} enabled
396
+ * @return {Mocha}
373
397
  */
374
-
375
398
  Mocha.prototype.enableTimeouts = function(enabled) {
376
- this.suite.enableTimeouts(arguments.length && enabled !== undefined
377
- ? enabled
378
- : true);
379
- return this
399
+ this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true);
400
+ return this;
380
401
  };
381
402
 
382
403
  /**
@@ -385,15 +406,14 @@ Mocha.prototype.enableTimeouts = function(enabled) {
385
406
  * @return {Mocha}
386
407
  * @api public
387
408
  */
388
-
389
- Mocha.prototype.asyncOnly = function(){
409
+ Mocha.prototype.asyncOnly = function() {
390
410
  this.options.asyncOnly = true;
391
411
  return this;
392
412
  };
393
413
 
394
414
  /**
395
415
  * Disable syntax highlighting (in browser).
396
- * @returns {Mocha}
416
+ *
397
417
  * @api public
398
418
  */
399
419
  Mocha.prototype.noHighlighting = function() {
@@ -401,10 +421,20 @@ Mocha.prototype.noHighlighting = function() {
401
421
  return this;
402
422
  };
403
423
 
424
+ /**
425
+ * Enable uncaught errors to propagate (in browser).
426
+ *
427
+ * @return {Mocha}
428
+ * @api public
429
+ */
430
+ Mocha.prototype.allowUncaught = function() {
431
+ this.options.allowUncaught = true;
432
+ return this;
433
+ };
434
+
404
435
  /**
405
436
  * Delay root suite execution.
406
437
  * @returns {Mocha}
407
- * @api public
408
438
  */
409
439
  Mocha.prototype.delay = function delay() {
410
440
  this.options.delay = true;
@@ -414,32 +444,43 @@ Mocha.prototype.delay = function delay() {
414
444
  /**
415
445
  * Run tests and invoke `fn()` when complete.
416
446
  *
447
+ * @api public
417
448
  * @param {Function} fn
418
449
  * @return {Runner}
419
- * @api public
420
450
  */
421
- Mocha.prototype.run = function(fn){
422
- if (this.files.length) this.loadFiles();
451
+ Mocha.prototype.run = function(fn) {
452
+ if (this.files.length) {
453
+ this.loadFiles();
454
+ }
423
455
  var suite = this.suite;
424
456
  var options = this.options;
425
457
  options.files = this.files;
426
458
  var runner = new exports.Runner(suite, options.delay);
427
459
  var reporter = new this._reporter(runner, options);
428
- runner.ignoreLeaks = false !== options.ignoreLeaks;
460
+ runner.ignoreLeaks = options.ignoreLeaks !== false;
429
461
  runner.fullStackTrace = options.fullStackTrace;
430
462
  runner.asyncOnly = options.asyncOnly;
431
- if (options.grep) runner.grep(options.grep, options.invert);
432
- if (options.globals) runner.globals(options.globals);
433
- if (options.growl) this._growl(runner, reporter);
463
+ runner.allowUncaught = options.allowUncaught;
464
+ if (options.grep) {
465
+ runner.grep(options.grep, options.invert);
466
+ }
467
+ if (options.globals) {
468
+ runner.globals(options.globals);
469
+ }
470
+ if (options.growl) {
471
+ this._growl(runner, reporter);
472
+ }
434
473
  if (options.useColors !== undefined) {
435
474
  exports.reporters.Base.useColors = options.useColors;
436
475
  }
437
476
  exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
438
477
 
439
478
  function done(failures) {
440
- if (reporter.done) {
441
- reporter.done(failures, fn);
442
- } else fn && fn(failures);
479
+ if (reporter.done) {
480
+ reporter.done(failures, fn);
481
+ } else {
482
+ fn && fn(failures);
483
+ }
443
484
  }
444
485
 
445
486
  return runner.run(done);
package/lib/ms.js CHANGED
@@ -15,29 +15,32 @@ var y = d * 365.25;
15
15
  *
16
16
  * - `long` verbose formatting [false]
17
17
  *
18
- * @param {String|Number} val
19
- * @param {Object} options
20
- * @return {String|Number}
21
18
  * @api public
19
+ * @param {string|number} val
20
+ * @param {Object} options
21
+ * @return {string|number}
22
22
  */
23
-
24
- module.exports = function(val, options){
23
+ module.exports = function(val, options) {
25
24
  options = options || {};
26
- if ('string' == typeof val) return parse(val);
25
+ if (typeof val === 'string') {
26
+ return parse(val);
27
+ }
28
+ // https://github.com/mochajs/mocha/pull/1035
27
29
  return options['long'] ? longFormat(val) : shortFormat(val);
28
30
  };
29
31
 
30
32
  /**
31
33
  * Parse the given `str` and return milliseconds.
32
34
  *
33
- * @param {String} str
34
- * @return {Number}
35
35
  * @api private
36
+ * @param {string} str
37
+ * @return {number}
36
38
  */
37
-
38
39
  function parse(str) {
39
- var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);
40
- if (!match) return;
40
+ var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str);
41
+ if (!match) {
42
+ return;
43
+ }
41
44
  var n = parseFloat(match[1]);
42
45
  var type = (match[2] || 'ms').toLowerCase();
43
46
  switch (type) {
@@ -63,33 +66,41 @@ function parse(str) {
63
66
  return n * s;
64
67
  case 'ms':
65
68
  return n;
69
+ default:
70
+ // No default case
66
71
  }
67
72
  }
68
73
 
69
74
  /**
70
75
  * Short format for `ms`.
71
76
  *
72
- * @param {Number} ms
73
- * @return {String}
74
77
  * @api private
78
+ * @param {number} ms
79
+ * @return {string}
75
80
  */
76
-
77
81
  function shortFormat(ms) {
78
- if (ms >= d) return Math.round(ms / d) + 'd';
79
- if (ms >= h) return Math.round(ms / h) + 'h';
80
- if (ms >= m) return Math.round(ms / m) + 'm';
81
- if (ms >= s) return Math.round(ms / s) + 's';
82
+ if (ms >= d) {
83
+ return Math.round(ms / d) + 'd';
84
+ }
85
+ if (ms >= h) {
86
+ return Math.round(ms / h) + 'h';
87
+ }
88
+ if (ms >= m) {
89
+ return Math.round(ms / m) + 'm';
90
+ }
91
+ if (ms >= s) {
92
+ return Math.round(ms / s) + 's';
93
+ }
82
94
  return ms + 'ms';
83
95
  }
84
96
 
85
97
  /**
86
98
  * Long format for `ms`.
87
99
  *
88
- * @param {Number} ms
89
- * @return {String}
90
100
  * @api private
101
+ * @param {number} ms
102
+ * @return {string}
91
103
  */
92
-
93
104
  function longFormat(ms) {
94
105
  return plural(ms, d, 'day')
95
106
  || plural(ms, h, 'hour')
@@ -100,10 +111,18 @@ function longFormat(ms) {
100
111
 
101
112
  /**
102
113
  * Pluralization helper.
114
+ *
115
+ * @api private
116
+ * @param {number} ms
117
+ * @param {number} n
118
+ * @param {string} name
103
119
  */
104
-
105
120
  function plural(ms, n, name) {
106
- if (ms < n) return;
107
- if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
121
+ if (ms < n) {
122
+ return;
123
+ }
124
+ if (ms < n * 1.5) {
125
+ return Math.floor(ms / n) + ' ' + name;
126
+ }
108
127
  return Math.ceil(ms / n) + ' ' + name + 's';
109
128
  }
package/lib/pending.js CHANGED
@@ -8,9 +8,8 @@ module.exports = Pending;
8
8
  /**
9
9
  * Initialize a new `Pending` error with the given message.
10
10
  *
11
- * @param {String} message
11
+ * @param {string} message
12
12
  */
13
-
14
13
  function Pending(message) {
15
- this.message = message;
14
+ this.message = message;
16
15
  }