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
@@ -2,8 +2,7 @@
2
2
  * Module dependencies.
3
3
  */
4
4
 
5
- var Base = require('./base')
6
- , color = Base.color;
5
+ var Base = require('./base');
7
6
 
8
7
  /**
9
8
  * Expose `List`.
@@ -14,32 +13,31 @@ exports = module.exports = List;
14
13
  /**
15
14
  * Initialize a new `List` test reporter.
16
15
  *
17
- * @param {Runner} runner
18
16
  * @api public
17
+ * @param {Runner} runner
19
18
  */
20
-
21
19
  function List(runner) {
22
20
  Base.call(this, runner);
23
21
 
24
- var self = this
25
- , stats = this.stats
26
- , total = runner.total;
22
+ var self = this;
23
+ var total = runner.total;
27
24
 
28
- runner.on('start', function(){
25
+ runner.on('start', function() {
29
26
  console.log(JSON.stringify(['start', { total: total }]));
30
27
  });
31
28
 
32
- runner.on('pass', function(test){
29
+ runner.on('pass', function(test) {
33
30
  console.log(JSON.stringify(['pass', clean(test)]));
34
31
  });
35
32
 
36
- runner.on('fail', function(test, err){
33
+ runner.on('fail', function(test, err) {
37
34
  test = clean(test);
38
35
  test.err = err.message;
36
+ test.stack = err.stack || null;
39
37
  console.log(JSON.stringify(['fail', test]));
40
38
  });
41
39
 
42
- runner.on('end', function(){
40
+ runner.on('end', function() {
43
41
  process.stdout.write(JSON.stringify(['end', self.stats]));
44
42
  });
45
43
  }
@@ -48,15 +46,14 @@ function List(runner) {
48
46
  * Return a plain-object representation of `test`
49
47
  * free of cyclic properties etc.
50
48
  *
49
+ * @api private
51
50
  * @param {Object} test
52
51
  * @return {Object}
53
- * @api private
54
52
  */
55
-
56
53
  function clean(test) {
57
54
  return {
58
- title: test.title
59
- , fullTitle: test.fullTitle()
60
- , duration: test.duration
61
- }
55
+ title: test.title,
56
+ fullTitle: test.fullTitle(),
57
+ duration: test.duration
58
+ };
62
59
  }
@@ -2,9 +2,7 @@
2
2
  * Module dependencies.
3
3
  */
4
4
 
5
- var Base = require('./base')
6
- , cursor = Base.cursor
7
- , color = Base.color;
5
+ var Base = require('./base');
8
6
 
9
7
  /**
10
8
  * Expose `JSON`.
@@ -15,36 +13,35 @@ exports = module.exports = JSONReporter;
15
13
  /**
16
14
  * Initialize a new `JSON` reporter.
17
15
  *
18
- * @param {Runner} runner
19
16
  * @api public
17
+ * @param {Runner} runner
20
18
  */
21
-
22
19
  function JSONReporter(runner) {
23
- var self = this;
24
20
  Base.call(this, runner);
25
21
 
26
- var tests = []
27
- , pending = []
28
- , failures = []
29
- , passes = [];
22
+ var self = this;
23
+ var tests = [];
24
+ var pending = [];
25
+ var failures = [];
26
+ var passes = [];
30
27
 
31
- runner.on('test end', function(test){
28
+ runner.on('test end', function(test) {
32
29
  tests.push(test);
33
30
  });
34
31
 
35
- runner.on('pass', function(test){
32
+ runner.on('pass', function(test) {
36
33
  passes.push(test);
37
34
  });
38
35
 
39
- runner.on('fail', function(test){
36
+ runner.on('fail', function(test) {
40
37
  failures.push(test);
41
38
  });
42
39
 
43
- runner.on('pending', function(test){
40
+ runner.on('pending', function(test) {
44
41
  pending.push(test);
45
42
  });
46
43
 
47
- runner.on('end', function(){
44
+ runner.on('end', function() {
48
45
  var obj = {
49
46
  stats: self.stats,
50
47
  tests: tests.map(clean),
@@ -63,26 +60,26 @@ function JSONReporter(runner) {
63
60
  * Return a plain-object representation of `test`
64
61
  * free of cyclic properties etc.
65
62
  *
63
+ * @api private
66
64
  * @param {Object} test
67
65
  * @return {Object}
68
- * @api private
69
66
  */
70
-
71
67
  function clean(test) {
72
68
  return {
73
69
  title: test.title,
74
70
  fullTitle: test.fullTitle(),
75
71
  duration: test.duration,
76
72
  err: errorJSON(test.err || {})
77
- }
73
+ };
78
74
  }
79
75
 
80
76
  /**
81
77
  * Transform `error` into a JSON object.
78
+ *
79
+ * @api private
82
80
  * @param {Error} err
83
81
  * @return {Object}
84
82
  */
85
-
86
83
  function errorJSON(err) {
87
84
  var res = {};
88
85
  Object.getOwnPropertyNames(err).forEach(function(key) {
@@ -2,9 +2,10 @@
2
2
  * Module dependencies.
3
3
  */
4
4
 
5
- var Base = require('./base')
6
- , cursor = Base.cursor
7
- , color = Base.color;
5
+ var Base = require('./base');
6
+ var inherits = require('../utils').inherits;
7
+ var cursor = Base.cursor;
8
+ var color = Base.color;
8
9
 
9
10
  /**
10
11
  * Expose `Landing`.
@@ -33,56 +34,52 @@ Base.colors.runway = 90;
33
34
  /**
34
35
  * Initialize a new `Landing` reporter.
35
36
  *
36
- * @param {Runner} runner
37
37
  * @api public
38
+ * @param {Runner} runner
38
39
  */
39
-
40
40
  function Landing(runner) {
41
41
  Base.call(this, runner);
42
42
 
43
- var self = this
44
- , stats = this.stats
45
- , width = Base.window.width * .75 | 0
46
- , total = runner.total
47
- , stream = process.stdout
48
- , plane = color('plane', '✈')
49
- , crashed = -1
50
- , n = 0;
43
+ var self = this;
44
+ var width = Base.window.width * .75 | 0;
45
+ var total = runner.total;
46
+ var stream = process.stdout;
47
+ var plane = color('plane', '✈');
48
+ var crashed = -1;
49
+ var n = 0;
51
50
 
52
51
  function runway() {
53
52
  var buf = Array(width).join('-');
54
53
  return ' ' + color('runway', buf);
55
54
  }
56
55
 
57
- runner.on('start', function(){
56
+ runner.on('start', function() {
58
57
  stream.write('\n\n\n ');
59
58
  cursor.hide();
60
59
  });
61
60
 
62
- runner.on('test end', function(test){
61
+ runner.on('test end', function(test) {
63
62
  // check if the plane crashed
64
- var col = -1 == crashed
65
- ? width * ++n / total | 0
66
- : crashed;
63
+ var col = crashed === -1 ? width * ++n / total | 0 : crashed;
67
64
 
68
65
  // show the crash
69
- if ('failed' == test.state) {
66
+ if (test.state === 'failed') {
70
67
  plane = color('plane crash', '✈');
71
68
  crashed = col;
72
69
  }
73
70
 
74
71
  // render landing strip
75
- stream.write('\u001b['+(width+1)+'D\u001b[2A');
72
+ stream.write('\u001b[' + (width + 1) + 'D\u001b[2A');
76
73
  stream.write(runway());
77
74
  stream.write('\n ');
78
75
  stream.write(color('runway', Array(col).join('⋅')));
79
- stream.write(plane)
76
+ stream.write(plane);
80
77
  stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
81
78
  stream.write(runway());
82
79
  stream.write('\u001b[0m');
83
80
  });
84
81
 
85
- runner.on('end', function(){
82
+ runner.on('end', function() {
86
83
  cursor.show();
87
84
  console.log();
88
85
  self.epilogue();
@@ -92,5 +89,4 @@ function Landing(runner) {
92
89
  /**
93
90
  * Inherit from `Base.prototype`.
94
91
  */
95
-
96
- Landing.prototype.__proto__ = Base.prototype;
92
+ inherits(Landing, Base);
@@ -2,9 +2,10 @@
2
2
  * Module dependencies.
3
3
  */
4
4
 
5
- var Base = require('./base')
6
- , cursor = Base.cursor
7
- , color = Base.color;
5
+ var Base = require('./base');
6
+ var inherits = require('../utils').inherits;
7
+ var color = Base.color;
8
+ var cursor = Base.cursor;
8
9
 
9
10
  /**
10
11
  * Expose `List`.
@@ -15,40 +16,38 @@ exports = module.exports = List;
15
16
  /**
16
17
  * Initialize a new `List` test reporter.
17
18
  *
18
- * @param {Runner} runner
19
19
  * @api public
20
+ * @param {Runner} runner
20
21
  */
21
-
22
22
  function List(runner) {
23
23
  Base.call(this, runner);
24
24
 
25
- var self = this
26
- , stats = this.stats
27
- , n = 0;
25
+ var self = this;
26
+ var n = 0;
28
27
 
29
- runner.on('start', function(){
28
+ runner.on('start', function() {
30
29
  console.log();
31
30
  });
32
31
 
33
- runner.on('test', function(test){
32
+ runner.on('test', function(test) {
34
33
  process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
35
34
  });
36
35
 
37
- runner.on('pending', function(test){
36
+ runner.on('pending', function(test) {
38
37
  var fmt = color('checkmark', ' -')
39
38
  + color('pending', ' %s');
40
39
  console.log(fmt, test.fullTitle());
41
40
  });
42
41
 
43
- runner.on('pass', function(test){
44
- var fmt = color('checkmark', ' '+Base.symbols.dot)
42
+ runner.on('pass', function(test) {
43
+ var fmt = color('checkmark', ' ' + Base.symbols.dot)
45
44
  + color('pass', ' %s: ')
46
45
  + color(test.speed, '%dms');
47
46
  cursor.CR();
48
47
  console.log(fmt, test.fullTitle(), test.duration);
49
48
  });
50
49
 
51
- runner.on('fail', function(test, err){
50
+ runner.on('fail', function(test) {
52
51
  cursor.CR();
53
52
  console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
54
53
  });
@@ -59,5 +58,4 @@ function List(runner) {
59
58
  /**
60
59
  * Inherit from `Base.prototype`.
61
60
  */
62
-
63
- List.prototype.__proto__ = Base.prototype;
61
+ inherits(List, Base);
@@ -2,8 +2,8 @@
2
2
  * Module dependencies.
3
3
  */
4
4
 
5
- var Base = require('./base')
6
- , utils = require('../utils');
5
+ var Base = require('./base');
6
+ var utils = require('../utils');
7
7
 
8
8
  /**
9
9
  * Constants
@@ -20,33 +20,28 @@ exports = module.exports = Markdown;
20
20
  /**
21
21
  * Initialize a new `Markdown` reporter.
22
22
  *
23
- * @param {Runner} runner
24
23
  * @api public
24
+ * @param {Runner} runner
25
25
  */
26
-
27
26
  function Markdown(runner) {
28
27
  Base.call(this, runner);
29
28
 
30
- var self = this
31
- , stats = this.stats
32
- , level = 0
33
- , buf = '';
29
+ var level = 0;
30
+ var buf = '';
34
31
 
35
32
  function title(str) {
36
33
  return Array(level).join('#') + ' ' + str;
37
34
  }
38
35
 
39
- function indent() {
40
- return Array(level).join(' ');
41
- }
42
-
43
36
  function mapTOC(suite, obj) {
44
- var ret = obj,
45
- key = SUITE_PREFIX + suite.title;
37
+ var ret = obj;
38
+ var key = SUITE_PREFIX + suite.title;
39
+
46
40
  obj = obj[key] = obj[key] || { suite: suite };
47
- suite.suites.forEach(function(suite){
41
+ suite.suites.forEach(function(suite) {
48
42
  mapTOC(suite, obj);
49
43
  });
44
+
50
45
  return ret;
51
46
  }
52
47
 
@@ -55,7 +50,9 @@ function Markdown(runner) {
55
50
  var buf = '';
56
51
  var link;
57
52
  for (var key in obj) {
58
- if ('suite' == key) continue;
53
+ if (key === 'suite') {
54
+ continue;
55
+ }
59
56
  if (key !== SUITE_PREFIX) {
60
57
  link = ' - [' + key.substring(1) + ']';
61
58
  link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
@@ -73,18 +70,18 @@ function Markdown(runner) {
73
70
 
74
71
  generateTOC(runner.suite);
75
72
 
76
- runner.on('suite', function(suite){
73
+ runner.on('suite', function(suite) {
77
74
  ++level;
78
75
  var slug = utils.slug(suite.fullTitle());
79
76
  buf += '<a name="' + slug + '"></a>' + '\n';
80
77
  buf += title(suite.title) + '\n';
81
78
  });
82
79
 
83
- runner.on('suite end', function(suite){
80
+ runner.on('suite end', function() {
84
81
  --level;
85
82
  });
86
83
 
87
- runner.on('pass', function(test){
84
+ runner.on('pass', function(test) {
88
85
  var code = utils.clean(test.fn.toString());
89
86
  buf += test.title + '.\n';
90
87
  buf += '\n```js\n';
@@ -92,7 +89,7 @@ function Markdown(runner) {
92
89
  buf += '```\n\n';
93
90
  });
94
91
 
95
- runner.on('end', function(){
92
+ runner.on('end', function() {
96
93
  process.stdout.write('# TOC\n');
97
94
  process.stdout.write(generateTOC(runner.suite));
98
95
  process.stdout.write(buf);
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  var Base = require('./base');
6
+ var inherits = require('../utils').inherits;
6
7
 
7
8
  /**
8
9
  * Expose `Min`.
@@ -13,14 +14,13 @@ exports = module.exports = Min;
13
14
  /**
14
15
  * Initialize a new `Min` minimal test reporter (best used with --watch).
15
16
  *
16
- * @param {Runner} runner
17
17
  * @api public
18
+ * @param {Runner} runner
18
19
  */
19
-
20
20
  function Min(runner) {
21
21
  Base.call(this, runner);
22
22
 
23
- runner.on('start', function(){
23
+ runner.on('start', function() {
24
24
  // clear screen
25
25
  process.stdout.write('\u001b[2J');
26
26
  // set cursor position
@@ -33,5 +33,4 @@ function Min(runner) {
33
33
  /**
34
34
  * Inherit from `Base.prototype`.
35
35
  */
36
-
37
- Min.prototype.__proto__ = Base.prototype;
36
+ inherits(Min, Base);
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  var Base = require('./base');
6
+ var inherits = require('../utils').inherits;
6
7
 
7
8
  /**
8
9
  * Expose `Dot`.
@@ -19,50 +20,57 @@ exports = module.exports = NyanCat;
19
20
 
20
21
  function NyanCat(runner) {
21
22
  Base.call(this, runner);
22
- var self = this
23
- , stats = this.stats
24
- , width = Base.window.width * .75 | 0
25
- , rainbowColors = this.rainbowColors = self.generateColors()
26
- , colorIndex = this.colorIndex = 0
27
- , numerOfLines = this.numberOfLines = 4
28
- , trajectories = this.trajectories = [[], [], [], []]
29
- , nyanCatWidth = this.nyanCatWidth = 11
30
- , trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)
31
- , scoreboardWidth = this.scoreboardWidth = 5
32
- , tick = this.tick = 0
33
- , n = 0;
34
-
35
- runner.on('start', function(){
23
+
24
+ var self = this;
25
+ var width = Base.window.width * .75 | 0;
26
+ var nyanCatWidth = this.nyanCatWidth = 11;
27
+
28
+ this.colorIndex = 0;
29
+ this.numberOfLines = 4;
30
+ this.rainbowColors = self.generateColors();
31
+ this.scoreboardWidth = 5;
32
+ this.tick = 0;
33
+ this.trajectories = [[], [], [], []];
34
+ this.trajectoryWidthMax = (width - nyanCatWidth);
35
+
36
+ runner.on('start', function() {
36
37
  Base.cursor.hide();
37
38
  self.draw();
38
39
  });
39
40
 
40
- runner.on('pending', function(test){
41
+ runner.on('pending', function() {
41
42
  self.draw();
42
43
  });
43
44
 
44
- runner.on('pass', function(test){
45
+ runner.on('pass', function() {
45
46
  self.draw();
46
47
  });
47
48
 
48
- runner.on('fail', function(test, err){
49
+ runner.on('fail', function() {
49
50
  self.draw();
50
51
  });
51
52
 
52
- runner.on('end', function(){
53
+ runner.on('end', function() {
53
54
  Base.cursor.show();
54
- for (var i = 0; i < self.numberOfLines; i++) write('\n');
55
+ for (var i = 0; i < self.numberOfLines; i++) {
56
+ write('\n');
57
+ }
55
58
  self.epilogue();
56
59
  });
57
60
  }
58
61
 
62
+ /**
63
+ * Inherit from `Base.prototype`.
64
+ */
65
+ inherits(NyanCat, Base);
66
+
59
67
  /**
60
68
  * Draw the nyan cat
61
69
  *
62
70
  * @api private
63
71
  */
64
72
 
65
- NyanCat.prototype.draw = function(){
73
+ NyanCat.prototype.draw = function() {
66
74
  this.appendRainbow();
67
75
  this.drawScoreboard();
68
76
  this.drawRainbow();
@@ -77,7 +85,7 @@ NyanCat.prototype.draw = function(){
77
85
  * @api private
78
86
  */
79
87
 
80
- NyanCat.prototype.drawScoreboard = function(){
88
+ NyanCat.prototype.drawScoreboard = function() {
81
89
  var stats = this.stats;
82
90
 
83
91
  function draw(type, n) {
@@ -100,13 +108,15 @@ NyanCat.prototype.drawScoreboard = function(){
100
108
  * @api private
101
109
  */
102
110
 
103
- NyanCat.prototype.appendRainbow = function(){
111
+ NyanCat.prototype.appendRainbow = function() {
104
112
  var segment = this.tick ? '_' : '-';
105
113
  var rainbowified = this.rainbowify(segment);
106
114
 
107
115
  for (var index = 0; index < this.numberOfLines; index++) {
108
116
  var trajectory = this.trajectories[index];
109
- if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift();
117
+ if (trajectory.length >= this.trajectoryWidthMax) {
118
+ trajectory.shift();
119
+ }
110
120
  trajectory.push(rainbowified);
111
121
  }
112
122
  };
@@ -117,10 +127,10 @@ NyanCat.prototype.appendRainbow = function(){
117
127
  * @api private
118
128
  */
119
129
 
120
- NyanCat.prototype.drawRainbow = function(){
130
+ NyanCat.prototype.drawRainbow = function() {
121
131
  var self = this;
122
132
 
123
- this.trajectories.forEach(function(line, index) {
133
+ this.trajectories.forEach(function(line) {
124
134
  write('\u001b[' + self.scoreboardWidth + 'C');
125
135
  write(line.join(''));
126
136
  write('\n');
@@ -134,7 +144,6 @@ NyanCat.prototype.drawRainbow = function(){
134
144
  *
135
145
  * @api private
136
146
  */
137
-
138
147
  NyanCat.prototype.drawNyanCat = function() {
139
148
  var self = this;
140
149
  var startWidth = this.scoreboardWidth + this.trajectories[0].length;
@@ -153,7 +162,6 @@ NyanCat.prototype.drawNyanCat = function() {
153
162
  write(dist);
154
163
  padding = self.tick ? '_' : '__';
155
164
  var tail = self.tick ? '~' : '^';
156
- var face;
157
165
  write(tail + '|' + padding + this.face() + ' ');
158
166
  write('\n');
159
167
 
@@ -168,8 +176,8 @@ NyanCat.prototype.drawNyanCat = function() {
168
176
  /**
169
177
  * Draw nyan cat face.
170
178
  *
171
- * @return {String}
172
179
  * @api private
180
+ * @return {string}
173
181
  */
174
182
 
175
183
  NyanCat.prototype.face = function() {
@@ -178,18 +186,17 @@ NyanCat.prototype.face = function() {
178
186
  return '( x .x)';
179
187
  } else if (stats.pending) {
180
188
  return '( o .o)';
181
- } else if(stats.passes) {
189
+ } else if (stats.passes) {
182
190
  return '( ^ .^)';
183
- } else {
184
- return '( - .-)';
185
191
  }
192
+ return '( - .-)';
186
193
  };
187
194
 
188
195
  /**
189
196
  * Move cursor up `n`.
190
197
  *
191
- * @param {Number} n
192
198
  * @api private
199
+ * @param {number} n
193
200
  */
194
201
 
195
202
  NyanCat.prototype.cursorUp = function(n) {
@@ -199,8 +206,8 @@ NyanCat.prototype.cursorUp = function(n) {
199
206
  /**
200
207
  * Move cursor down `n`.
201
208
  *
202
- * @param {Number} n
203
209
  * @api private
210
+ * @param {number} n
204
211
  */
205
212
 
206
213
  NyanCat.prototype.cursorDown = function(n) {
@@ -210,11 +217,10 @@ NyanCat.prototype.cursorDown = function(n) {
210
217
  /**
211
218
  * Generate rainbow colors.
212
219
  *
213
- * @return {Array}
214
220
  * @api private
221
+ * @return {Array}
215
222
  */
216
-
217
- NyanCat.prototype.generateColors = function(){
223
+ NyanCat.prototype.generateColors = function() {
218
224
  var colors = [];
219
225
 
220
226
  for (var i = 0; i < (6 * 7); i++) {
@@ -232,14 +238,14 @@ NyanCat.prototype.generateColors = function(){
232
238
  /**
233
239
  * Apply rainbow to the given `str`.
234
240
  *
235
- * @param {String} str
236
- * @return {String}
237
241
  * @api private
242
+ * @param {string} str
243
+ * @return {string}
238
244
  */
239
-
240
- NyanCat.prototype.rainbowify = function(str){
241
- if (!Base.useColors)
245
+ NyanCat.prototype.rainbowify = function(str) {
246
+ if (!Base.useColors) {
242
247
  return str;
248
+ }
243
249
  var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
244
250
  this.colorIndex += 1;
245
251
  return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
@@ -247,14 +253,9 @@ NyanCat.prototype.rainbowify = function(str){
247
253
 
248
254
  /**
249
255
  * Stdout helper.
256
+ *
257
+ * @param {string} string A message to write to stdout.
250
258
  */
251
-
252
259
  function write(string) {
253
260
  process.stdout.write(string);
254
261
  }
255
-
256
- /**
257
- * Inherit from `Base.prototype`.
258
- */
259
-
260
- NyanCat.prototype.__proto__ = Base.prototype;