mocha 3.4.1 → 3.4.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # 3.4.2 / 2017-05-24
2
+
3
+ ## :bug: Fixes
4
+
5
+ - [#2802]: Remove call to deprecated os.tmpDir ([@makepanic])
6
+ - [#2820]: Eagerly set process.exitCode ([@chrisleck])
7
+
8
+ ## :nut_and_bolt: Other
9
+
10
+ - [#2778]: Move linting into an npm script ([@Munter])
11
+
12
+ [@chrisleck]: https://github.com/chrisleck
13
+ [@makepanic]: https://github.com/makepanic
14
+ [@Munter]: https://github.com/Munter
15
+
16
+ [#2802]: https://github.com/mochajs/mocha/issues/2802
17
+ [#2820]: https://github.com/mochajs/mocha/pull/2820
18
+
1
19
  # 3.4.1 / 2017-05-14
2
20
 
3
21
  Fixed a publishing mishap with git's autocrlf settings.
package/bin/_mocha CHANGED
@@ -476,12 +476,18 @@ function exitLater (code) {
476
476
  }
477
477
 
478
478
  function exit (code) {
479
+ var clampedCode = Math.min(code, 255);
480
+
481
+ // Eagerly set the process's exit code in case stream.write doesn't
482
+ // execute its callback before the process terminates.
483
+ process.exitCode = clampedCode;
484
+
479
485
  // flush output for Node.js Windows pipe bug
480
486
  // https://github.com/joyent/node/issues/6247 is just one bug example
481
487
  // https://github.com/visionmedia/mocha/issues/333 has a good discussion
482
488
  function done () {
483
489
  if (!(draining--)) {
484
- process.exit(Math.min(code, 255));
490
+ process.exit(clampedCode);
485
491
  }
486
492
  }
487
493
 
package/bin/mocha CHANGED
File without changes
package/mocha.js CHANGED
@@ -6775,7 +6775,7 @@ exports.isPromise = function isPromise (value) {
6775
6775
  exports.noop = function () {};
6776
6776
 
6777
6777
  }).call(this,require('_process'),require("buffer").Buffer)
6778
- },{"./to-iso-string":37,"_process":82,"buffer":44,"debug":2,"fs":42,"glob":42,"json3":69,"path":42,"util":100}],39:[function(require,module,exports){
6778
+ },{"./to-iso-string":37,"_process":82,"buffer":44,"debug":2,"fs":42,"glob":42,"json3":69,"path":42,"util":99}],39:[function(require,module,exports){
6779
6779
  'use strict'
6780
6780
 
6781
6781
  exports.byteLength = byteLength
@@ -6922,7 +6922,7 @@ BrowserStdout.prototype._write = function(chunks, encoding, cb) {
6922
6922
  }
6923
6923
 
6924
6924
  }).call(this,require('_process'))
6925
- },{"_process":82,"stream":95,"util":100}],42:[function(require,module,exports){
6925
+ },{"_process":82,"stream":94,"util":99}],42:[function(require,module,exports){
6926
6926
  arguments[4][40][0].apply(exports,arguments)
6927
6927
  },{"dup":40}],43:[function(require,module,exports){
6928
6928
  (function (global){
@@ -13319,10 +13319,6 @@ process.off = noop;
13319
13319
  process.removeListener = noop;
13320
13320
  process.removeAllListeners = noop;
13321
13321
  process.emit = noop;
13322
- process.prependListener = noop;
13323
- process.prependOnceListener = noop;
13324
-
13325
- process.listeners = function (name) { return [] }
13326
13322
 
13327
13323
  process.binding = function (name) {
13328
13324
  throw new Error('process.binding is not supported');
@@ -13335,7 +13331,7 @@ process.chdir = function (dir) {
13335
13331
  process.umask = function() { return 0; };
13336
13332
 
13337
13333
  },{}],83:[function(require,module,exports){
13338
- module.exports = require('./lib/_stream_duplex.js');
13334
+ module.exports = require("./lib/_stream_duplex.js")
13339
13335
 
13340
13336
  },{"./lib/_stream_duplex.js":84}],84:[function(require,module,exports){
13341
13337
  // a duplex stream is just a stream that is both readable and writable.
@@ -13454,10 +13450,6 @@ var processNextTick = require('process-nextick-args');
13454
13450
  var isArray = require('isarray');
13455
13451
  /*</replacement>*/
13456
13452
 
13457
- /*<replacement>*/
13458
- var Duplex;
13459
- /*</replacement>*/
13460
-
13461
13453
  Readable.ReadableState = ReadableState;
13462
13454
 
13463
13455
  /*<replacement>*/
@@ -13469,7 +13461,14 @@ var EElistenerCount = function (emitter, type) {
13469
13461
  /*</replacement>*/
13470
13462
 
13471
13463
  /*<replacement>*/
13472
- var Stream = require('./internal/streams/stream');
13464
+ var Stream;
13465
+ (function () {
13466
+ try {
13467
+ Stream = require('st' + 'ream');
13468
+ } catch (_) {} finally {
13469
+ if (!Stream) Stream = require('events').EventEmitter;
13470
+ }
13471
+ })();
13473
13472
  /*</replacement>*/
13474
13473
 
13475
13474
  var Buffer = require('buffer').Buffer;
@@ -13497,11 +13496,7 @@ var StringDecoder;
13497
13496
 
13498
13497
  util.inherits(Readable, Stream);
13499
13498
 
13500
- var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
13501
-
13502
13499
  function prependListener(emitter, event, fn) {
13503
- // Sadly this is not cacheable as some libraries bundle their own
13504
- // event emitter implementation with them.
13505
13500
  if (typeof emitter.prependListener === 'function') {
13506
13501
  return emitter.prependListener(event, fn);
13507
13502
  } else {
@@ -13513,6 +13508,7 @@ function prependListener(emitter, event, fn) {
13513
13508
  }
13514
13509
  }
13515
13510
 
13511
+ var Duplex;
13516
13512
  function ReadableState(options, stream) {
13517
13513
  Duplex = Duplex || require('./_stream_duplex');
13518
13514
 
@@ -13531,7 +13527,7 @@ function ReadableState(options, stream) {
13531
13527
  this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
13532
13528
 
13533
13529
  // cast to ints.
13534
- this.highWaterMark = ~~this.highWaterMark;
13530
+ this.highWaterMark = ~ ~this.highWaterMark;
13535
13531
 
13536
13532
  // A linked list is used to store data chunks instead of an array because the
13537
13533
  // linked list can remove elements from the beginning faster than
@@ -13582,6 +13578,7 @@ function ReadableState(options, stream) {
13582
13578
  }
13583
13579
  }
13584
13580
 
13581
+ var Duplex;
13585
13582
  function Readable(options) {
13586
13583
  Duplex = Duplex || require('./_stream_duplex');
13587
13584
 
@@ -13904,7 +13901,7 @@ function maybeReadMore_(stream, state) {
13904
13901
  // for virtual (non-string, non-buffer) streams, "length" is somewhat
13905
13902
  // arbitrary, and perhaps not very meaningful.
13906
13903
  Readable.prototype._read = function (n) {
13907
- this.emit('error', new Error('_read() is not implemented'));
13904
+ this.emit('error', new Error('not implemented'));
13908
13905
  };
13909
13906
 
13910
13907
  Readable.prototype.pipe = function (dest, pipeOpts) {
@@ -14082,16 +14079,16 @@ Readable.prototype.unpipe = function (dest) {
14082
14079
  state.pipesCount = 0;
14083
14080
  state.flowing = false;
14084
14081
 
14085
- for (var i = 0; i < len; i++) {
14086
- dests[i].emit('unpipe', this);
14082
+ for (var _i = 0; _i < len; _i++) {
14083
+ dests[_i].emit('unpipe', this);
14087
14084
  }return this;
14088
14085
  }
14089
14086
 
14090
14087
  // try to find the right one.
14091
- var index = indexOf(state.pipes, dest);
14092
- if (index === -1) return this;
14088
+ var i = indexOf(state.pipes, dest);
14089
+ if (i === -1) return this;
14093
14090
 
14094
- state.pipes.splice(index, 1);
14091
+ state.pipes.splice(i, 1);
14095
14092
  state.pipesCount -= 1;
14096
14093
  if (state.pipesCount === 1) state.pipes = state.pipes[0];
14097
14094
 
@@ -14223,9 +14220,10 @@ Readable.prototype.wrap = function (stream) {
14223
14220
  }
14224
14221
 
14225
14222
  // proxy certain important events.
14226
- for (var n = 0; n < kProxyEvents.length; n++) {
14227
- stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
14228
- }
14223
+ var events = ['error', 'close', 'destroy', 'pause', 'resume'];
14224
+ forEach(events, function (ev) {
14225
+ stream.on(ev, self.emit.bind(self, ev));
14226
+ });
14229
14227
 
14230
14228
  // when we try to consume some more bytes, simply unpause the
14231
14229
  // underlying stream.
@@ -14378,7 +14376,7 @@ function indexOf(xs, x) {
14378
14376
  return -1;
14379
14377
  }
14380
14378
  }).call(this,require('_process'))
14381
- },{"./_stream_duplex":84,"./internal/streams/BufferList":89,"./internal/streams/stream":90,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":63,"inherits":66,"isarray":68,"process-nextick-args":81,"string_decoder/":96,"util":40}],87:[function(require,module,exports){
14379
+ },{"./_stream_duplex":84,"./internal/streams/BufferList":89,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":63,"inherits":66,"isarray":68,"process-nextick-args":81,"string_decoder/":95,"util":40}],87:[function(require,module,exports){
14382
14380
  // a transform stream is a readable/writable stream where you do
14383
14381
  // something with the data. Sometimes it's called a "filter",
14384
14382
  // but that's not a great name for it, since that implies a thing where
@@ -14475,6 +14473,7 @@ function Transform(options) {
14475
14473
 
14476
14474
  this._transformState = new TransformState(this);
14477
14475
 
14476
+ // when the writable side finishes, then flush out anything remaining.
14478
14477
  var stream = this;
14479
14478
 
14480
14479
  // start out asking for a readable event once data is transformed.
@@ -14491,10 +14490,9 @@ function Transform(options) {
14491
14490
  if (typeof options.flush === 'function') this._flush = options.flush;
14492
14491
  }
14493
14492
 
14494
- // When the writable side finishes, then flush out anything remaining.
14495
14493
  this.once('prefinish', function () {
14496
- if (typeof this._flush === 'function') this._flush(function (er, data) {
14497
- done(stream, er, data);
14494
+ if (typeof this._flush === 'function') this._flush(function (er) {
14495
+ done(stream, er);
14498
14496
  });else done(stream);
14499
14497
  });
14500
14498
  }
@@ -14515,7 +14513,7 @@ Transform.prototype.push = function (chunk, encoding) {
14515
14513
  // an error, then that'll put the hurt on the whole operation. If you
14516
14514
  // never call cb(), then you'll never get another chunk.
14517
14515
  Transform.prototype._transform = function (chunk, encoding, cb) {
14518
- throw new Error('_transform() is not implemented');
14516
+ throw new Error('Not implemented');
14519
14517
  };
14520
14518
 
14521
14519
  Transform.prototype._write = function (chunk, encoding, cb) {
@@ -14545,11 +14543,9 @@ Transform.prototype._read = function (n) {
14545
14543
  }
14546
14544
  };
14547
14545
 
14548
- function done(stream, er, data) {
14546
+ function done(stream, er) {
14549
14547
  if (er) return stream.emit('error', er);
14550
14548
 
14551
- if (data !== null && data !== undefined) stream.push(data);
14552
-
14553
14549
  // if there's nothing in the write buffer, then that means
14554
14550
  // that nothing more will ever be provided
14555
14551
  var ws = stream._writableState;
@@ -14579,10 +14575,6 @@ var processNextTick = require('process-nextick-args');
14579
14575
  var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
14580
14576
  /*</replacement>*/
14581
14577
 
14582
- /*<replacement>*/
14583
- var Duplex;
14584
- /*</replacement>*/
14585
-
14586
14578
  Writable.WritableState = WritableState;
14587
14579
 
14588
14580
  /*<replacement>*/
@@ -14597,7 +14589,14 @@ var internalUtil = {
14597
14589
  /*</replacement>*/
14598
14590
 
14599
14591
  /*<replacement>*/
14600
- var Stream = require('./internal/streams/stream');
14592
+ var Stream;
14593
+ (function () {
14594
+ try {
14595
+ Stream = require('st' + 'ream');
14596
+ } catch (_) {} finally {
14597
+ if (!Stream) Stream = require('events').EventEmitter;
14598
+ }
14599
+ })();
14601
14600
  /*</replacement>*/
14602
14601
 
14603
14602
  var Buffer = require('buffer').Buffer;
@@ -14616,6 +14615,7 @@ function WriteReq(chunk, encoding, cb) {
14616
14615
  this.next = null;
14617
14616
  }
14618
14617
 
14618
+ var Duplex;
14619
14619
  function WritableState(options, stream) {
14620
14620
  Duplex = Duplex || require('./_stream_duplex');
14621
14621
 
@@ -14635,9 +14635,8 @@ function WritableState(options, stream) {
14635
14635
  this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
14636
14636
 
14637
14637
  // cast to ints.
14638
- this.highWaterMark = ~~this.highWaterMark;
14638
+ this.highWaterMark = ~ ~this.highWaterMark;
14639
14639
 
14640
- // drain event flag.
14641
14640
  this.needDrain = false;
14642
14641
  // at the start of calling end()
14643
14642
  this.ending = false;
@@ -14712,7 +14711,7 @@ function WritableState(options, stream) {
14712
14711
  this.corkedRequestsFree = new CorkedRequest(this);
14713
14712
  }
14714
14713
 
14715
- WritableState.prototype.getBuffer = function getBuffer() {
14714
+ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
14716
14715
  var current = this.bufferedRequest;
14717
14716
  var out = [];
14718
14717
  while (current) {
@@ -14732,37 +14731,13 @@ WritableState.prototype.getBuffer = function getBuffer() {
14732
14731
  } catch (_) {}
14733
14732
  })();
14734
14733
 
14735
- // Test _writableState for inheritance to account for Duplex streams,
14736
- // whose prototype chain only points to Readable.
14737
- var realHasInstance;
14738
- if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
14739
- realHasInstance = Function.prototype[Symbol.hasInstance];
14740
- Object.defineProperty(Writable, Symbol.hasInstance, {
14741
- value: function (object) {
14742
- if (realHasInstance.call(this, object)) return true;
14743
-
14744
- return object && object._writableState instanceof WritableState;
14745
- }
14746
- });
14747
- } else {
14748
- realHasInstance = function (object) {
14749
- return object instanceof this;
14750
- };
14751
- }
14752
-
14734
+ var Duplex;
14753
14735
  function Writable(options) {
14754
14736
  Duplex = Duplex || require('./_stream_duplex');
14755
14737
 
14756
- // Writable ctor is applied to Duplexes, too.
14757
- // `realHasInstance` is necessary because using plain `instanceof`
14758
- // would return false, as no `_writableState` property is attached.
14759
-
14760
- // Trying to use the custom `instanceof` for Writable here will also break the
14761
- // Node.js LazyTransform implementation, which has a non-trivial getter for
14762
- // `_writableState` that would lead to infinite recursion.
14763
- if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
14764
- return new Writable(options);
14765
- }
14738
+ // Writable ctor is applied to Duplexes, though they're not
14739
+ // instanceof Writable, they're instanceof Readable.
14740
+ if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
14766
14741
 
14767
14742
  this._writableState = new WritableState(options, this);
14768
14743
 
@@ -14790,16 +14765,20 @@ function writeAfterEnd(stream, cb) {
14790
14765
  processNextTick(cb, er);
14791
14766
  }
14792
14767
 
14793
- // Checks that a user-supplied chunk is valid, especially for the particular
14794
- // mode the stream is in. Currently this means that `null` is never accepted
14795
- // and undefined/non-string values are only allowed in object mode.
14768
+ // If we get something that is not a buffer, string, null, or undefined,
14769
+ // and we're not in objectMode, then that's an error.
14770
+ // Otherwise stream chunks are all considered to be of length=1, and the
14771
+ // watermarks determine how many objects to keep in the buffer, rather than
14772
+ // how many bytes or characters.
14796
14773
  function validChunk(stream, state, chunk, cb) {
14797
14774
  var valid = true;
14798
14775
  var er = false;
14799
-
14776
+ // Always throw error if a null is written
14777
+ // if we are not in object mode then throw
14778
+ // if it is not a buffer, string, or undefined.
14800
14779
  if (chunk === null) {
14801
14780
  er = new TypeError('May not write null values to stream');
14802
- } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
14781
+ } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
14803
14782
  er = new TypeError('Invalid non-string/buffer chunk');
14804
14783
  }
14805
14784
  if (er) {
@@ -14813,20 +14792,19 @@ function validChunk(stream, state, chunk, cb) {
14813
14792
  Writable.prototype.write = function (chunk, encoding, cb) {
14814
14793
  var state = this._writableState;
14815
14794
  var ret = false;
14816
- var isBuf = Buffer.isBuffer(chunk);
14817
14795
 
14818
14796
  if (typeof encoding === 'function') {
14819
14797
  cb = encoding;
14820
14798
  encoding = null;
14821
14799
  }
14822
14800
 
14823
- if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
14801
+ if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
14824
14802
 
14825
14803
  if (typeof cb !== 'function') cb = nop;
14826
14804
 
14827
- if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
14805
+ if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
14828
14806
  state.pendingcb++;
14829
- ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
14807
+ ret = writeOrBuffer(this, state, chunk, encoding, cb);
14830
14808
  }
14831
14809
 
14832
14810
  return ret;
@@ -14866,11 +14844,10 @@ function decodeChunk(state, chunk, encoding) {
14866
14844
  // if we're already writing something, then just put this
14867
14845
  // in the queue, and wait our turn. Otherwise, call _write
14868
14846
  // If we return false, then we need a drain event, so set that flag.
14869
- function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
14870
- if (!isBuf) {
14871
- chunk = decodeChunk(state, chunk, encoding);
14872
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
14873
- }
14847
+ function writeOrBuffer(stream, state, chunk, encoding, cb) {
14848
+ chunk = decodeChunk(state, chunk, encoding);
14849
+
14850
+ if (Buffer.isBuffer(chunk)) encoding = 'buffer';
14874
14851
  var len = state.objectMode ? 1 : chunk.length;
14875
14852
 
14876
14853
  state.length += len;
@@ -14939,8 +14916,8 @@ function onwrite(stream, er) {
14939
14916
  asyncWrite(afterWrite, stream, state, finished, cb);
14940
14917
  /*</replacement>*/
14941
14918
  } else {
14942
- afterWrite(stream, state, finished, cb);
14943
- }
14919
+ afterWrite(stream, state, finished, cb);
14920
+ }
14944
14921
  }
14945
14922
  }
14946
14923
 
@@ -15020,7 +14997,7 @@ function clearBuffer(stream, state) {
15020
14997
  }
15021
14998
 
15022
14999
  Writable.prototype._write = function (chunk, encoding, cb) {
15023
- cb(new Error('_write() is not implemented'));
15000
+ cb(new Error('not implemented'));
15024
15001
  };
15025
15002
 
15026
15003
  Writable.prototype._writev = null;
@@ -15091,6 +15068,7 @@ function CorkedRequest(state) {
15091
15068
 
15092
15069
  this.next = null;
15093
15070
  this.entry = null;
15071
+
15094
15072
  this.finish = function (err) {
15095
15073
  var entry = _this.entry;
15096
15074
  _this.entry = null;
@@ -15108,7 +15086,7 @@ function CorkedRequest(state) {
15108
15086
  };
15109
15087
  }
15110
15088
  }).call(this,require('_process'))
15111
- },{"./_stream_duplex":84,"./internal/streams/stream":90,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"inherits":66,"process-nextick-args":81,"util-deprecate":97}],89:[function(require,module,exports){
15089
+ },{"./_stream_duplex":84,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":63,"inherits":66,"process-nextick-args":81,"util-deprecate":96}],89:[function(require,module,exports){
15112
15090
  'use strict';
15113
15091
 
15114
15092
  var Buffer = require('buffer').Buffer;
@@ -15174,27 +15152,35 @@ BufferList.prototype.concat = function (n) {
15174
15152
  return ret;
15175
15153
  };
15176
15154
  },{"buffer":44,"buffer-shims":43}],90:[function(require,module,exports){
15177
- module.exports = require('events').EventEmitter;
15178
-
15179
- },{"events":63}],91:[function(require,module,exports){
15180
- module.exports = require('./readable').PassThrough
15155
+ module.exports = require("./lib/_stream_passthrough.js")
15181
15156
 
15182
- },{"./readable":92}],92:[function(require,module,exports){
15157
+ },{"./lib/_stream_passthrough.js":85}],91:[function(require,module,exports){
15158
+ (function (process){
15159
+ var Stream = (function (){
15160
+ try {
15161
+ return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
15162
+ } catch(_){}
15163
+ }());
15183
15164
  exports = module.exports = require('./lib/_stream_readable.js');
15184
- exports.Stream = exports;
15165
+ exports.Stream = Stream || exports;
15185
15166
  exports.Readable = exports;
15186
15167
  exports.Writable = require('./lib/_stream_writable.js');
15187
15168
  exports.Duplex = require('./lib/_stream_duplex.js');
15188
15169
  exports.Transform = require('./lib/_stream_transform.js');
15189
15170
  exports.PassThrough = require('./lib/_stream_passthrough.js');
15190
15171
 
15191
- },{"./lib/_stream_duplex.js":84,"./lib/_stream_passthrough.js":85,"./lib/_stream_readable.js":86,"./lib/_stream_transform.js":87,"./lib/_stream_writable.js":88}],93:[function(require,module,exports){
15192
- module.exports = require('./readable').Transform
15172
+ if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
15173
+ module.exports = Stream;
15174
+ }
15175
+
15176
+ }).call(this,require('_process'))
15177
+ },{"./lib/_stream_duplex.js":84,"./lib/_stream_passthrough.js":85,"./lib/_stream_readable.js":86,"./lib/_stream_transform.js":87,"./lib/_stream_writable.js":88,"_process":82}],92:[function(require,module,exports){
15178
+ module.exports = require("./lib/_stream_transform.js")
15193
15179
 
15194
- },{"./readable":92}],94:[function(require,module,exports){
15195
- module.exports = require('./lib/_stream_writable.js');
15180
+ },{"./lib/_stream_transform.js":87}],93:[function(require,module,exports){
15181
+ module.exports = require("./lib/_stream_writable.js")
15196
15182
 
15197
- },{"./lib/_stream_writable.js":88}],95:[function(require,module,exports){
15183
+ },{"./lib/_stream_writable.js":88}],94:[function(require,module,exports){
15198
15184
  // Copyright Joyent, Inc. and other Node contributors.
15199
15185
  //
15200
15186
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -15323,281 +15309,230 @@ Stream.prototype.pipe = function(dest, options) {
15323
15309
  return dest;
15324
15310
  };
15325
15311
 
15326
- },{"events":63,"inherits":66,"readable-stream/duplex.js":83,"readable-stream/passthrough.js":91,"readable-stream/readable.js":92,"readable-stream/transform.js":93,"readable-stream/writable.js":94}],96:[function(require,module,exports){
15327
- 'use strict';
15312
+ },{"events":63,"inherits":66,"readable-stream/duplex.js":83,"readable-stream/passthrough.js":90,"readable-stream/readable.js":91,"readable-stream/transform.js":92,"readable-stream/writable.js":93}],95:[function(require,module,exports){
15313
+ // Copyright Joyent, Inc. and other Node contributors.
15314
+ //
15315
+ // Permission is hereby granted, free of charge, to any person obtaining a
15316
+ // copy of this software and associated documentation files (the
15317
+ // "Software"), to deal in the Software without restriction, including
15318
+ // without limitation the rights to use, copy, modify, merge, publish,
15319
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
15320
+ // persons to whom the Software is furnished to do so, subject to the
15321
+ // following conditions:
15322
+ //
15323
+ // The above copyright notice and this permission notice shall be included
15324
+ // in all copies or substantial portions of the Software.
15325
+ //
15326
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15327
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15328
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15329
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15330
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15331
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15332
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
15328
15333
 
15329
15334
  var Buffer = require('buffer').Buffer;
15330
- var bufferShim = require('buffer-shims');
15331
15335
 
15332
- var isEncoding = Buffer.isEncoding || function (encoding) {
15333
- encoding = '' + encoding;
15334
- switch (encoding && encoding.toLowerCase()) {
15335
- case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
15336
- return true;
15337
- default:
15338
- return false;
15339
- }
15340
- };
15336
+ var isBufferEncoding = Buffer.isEncoding
15337
+ || function(encoding) {
15338
+ switch (encoding && encoding.toLowerCase()) {
15339
+ case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
15340
+ default: return false;
15341
+ }
15342
+ }
15341
15343
 
15342
- function _normalizeEncoding(enc) {
15343
- if (!enc) return 'utf8';
15344
- var retried;
15345
- while (true) {
15346
- switch (enc) {
15347
- case 'utf8':
15348
- case 'utf-8':
15349
- return 'utf8';
15350
- case 'ucs2':
15351
- case 'ucs-2':
15352
- case 'utf16le':
15353
- case 'utf-16le':
15354
- return 'utf16le';
15355
- case 'latin1':
15356
- case 'binary':
15357
- return 'latin1';
15358
- case 'base64':
15359
- case 'ascii':
15360
- case 'hex':
15361
- return enc;
15362
- default:
15363
- if (retried) return; // undefined
15364
- enc = ('' + enc).toLowerCase();
15365
- retried = true;
15366
- }
15367
- }
15368
- };
15369
15344
 
15370
- // Do not cache `Buffer.isEncoding` when checking encoding names as some
15371
- // modules monkey-patch it to support additional encodings
15372
- function normalizeEncoding(enc) {
15373
- var nenc = _normalizeEncoding(enc);
15374
- if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
15375
- return nenc || enc;
15345
+ function assertEncoding(encoding) {
15346
+ if (encoding && !isBufferEncoding(encoding)) {
15347
+ throw new Error('Unknown encoding: ' + encoding);
15348
+ }
15376
15349
  }
15377
15350
 
15378
15351
  // StringDecoder provides an interface for efficiently splitting a series of
15379
15352
  // buffers into a series of JS strings without breaking apart multi-byte
15380
- // characters.
15381
- exports.StringDecoder = StringDecoder;
15382
- function StringDecoder(encoding) {
15383
- this.encoding = normalizeEncoding(encoding);
15384
- var nb;
15353
+ // characters. CESU-8 is handled as part of the UTF-8 encoding.
15354
+ //
15355
+ // @TODO Handling all encodings inside a single object makes it very difficult
15356
+ // to reason about this code, so it should be split up in the future.
15357
+ // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
15358
+ // points as used by CESU-8.
15359
+ var StringDecoder = exports.StringDecoder = function(encoding) {
15360
+ this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
15361
+ assertEncoding(encoding);
15385
15362
  switch (this.encoding) {
15386
- case 'utf16le':
15387
- this.text = utf16Text;
15388
- this.end = utf16End;
15389
- nb = 4;
15390
- break;
15391
15363
  case 'utf8':
15392
- this.fillLast = utf8FillLast;
15393
- nb = 4;
15364
+ // CESU-8 represents each of Surrogate Pair by 3-bytes
15365
+ this.surrogateSize = 3;
15366
+ break;
15367
+ case 'ucs2':
15368
+ case 'utf16le':
15369
+ // UTF-16 represents each of Surrogate Pair by 2-bytes
15370
+ this.surrogateSize = 2;
15371
+ this.detectIncompleteChar = utf16DetectIncompleteChar;
15394
15372
  break;
15395
15373
  case 'base64':
15396
- this.text = base64Text;
15397
- this.end = base64End;
15398
- nb = 3;
15374
+ // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
15375
+ this.surrogateSize = 3;
15376
+ this.detectIncompleteChar = base64DetectIncompleteChar;
15399
15377
  break;
15400
15378
  default:
15401
- this.write = simpleWrite;
15402
- this.end = simpleEnd;
15379
+ this.write = passThroughWrite;
15403
15380
  return;
15404
15381
  }
15405
- this.lastNeed = 0;
15406
- this.lastTotal = 0;
15407
- this.lastChar = bufferShim.allocUnsafe(nb);
15408
- }
15409
15382
 
15410
- StringDecoder.prototype.write = function (buf) {
15411
- if (buf.length === 0) return '';
15412
- var r;
15413
- var i;
15414
- if (this.lastNeed) {
15415
- r = this.fillLast(buf);
15416
- if (r === undefined) return '';
15417
- i = this.lastNeed;
15418
- this.lastNeed = 0;
15419
- } else {
15420
- i = 0;
15421
- }
15422
- if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
15423
- return r || '';
15383
+ // Enough space to store all bytes of a single character. UTF-8 needs 4
15384
+ // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
15385
+ this.charBuffer = new Buffer(6);
15386
+ // Number of bytes received for the current incomplete multi-byte character.
15387
+ this.charReceived = 0;
15388
+ // Number of bytes expected for the current incomplete multi-byte character.
15389
+ this.charLength = 0;
15424
15390
  };
15425
15391
 
15426
- StringDecoder.prototype.end = utf8End;
15427
15392
 
15428
- // Returns only complete characters in a Buffer
15429
- StringDecoder.prototype.text = utf8Text;
15393
+ // write decodes the given buffer and returns it as JS string that is
15394
+ // guaranteed to not contain any partial multi-byte characters. Any partial
15395
+ // character found at the end of the buffer is buffered up, and will be
15396
+ // returned when calling write again with the remaining bytes.
15397
+ //
15398
+ // Note: Converting a Buffer containing an orphan surrogate to a String
15399
+ // currently works, but converting a String to a Buffer (via `new Buffer`, or
15400
+ // Buffer#write) will replace incomplete surrogates with the unicode
15401
+ // replacement character. See https://codereview.chromium.org/121173009/ .
15402
+ StringDecoder.prototype.write = function(buffer) {
15403
+ var charStr = '';
15404
+ // if our last write ended with an incomplete multibyte character
15405
+ while (this.charLength) {
15406
+ // determine how many remaining bytes this buffer has to offer for this char
15407
+ var available = (buffer.length >= this.charLength - this.charReceived) ?
15408
+ this.charLength - this.charReceived :
15409
+ buffer.length;
15410
+
15411
+ // add the new bytes to the char buffer
15412
+ buffer.copy(this.charBuffer, this.charReceived, 0, available);
15413
+ this.charReceived += available;
15414
+
15415
+ if (this.charReceived < this.charLength) {
15416
+ // still not enough chars in this buffer? wait for more ...
15417
+ return '';
15418
+ }
15419
+
15420
+ // remove bytes belonging to the current character from the buffer
15421
+ buffer = buffer.slice(available, buffer.length);
15422
+
15423
+ // get the character that was split
15424
+ charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
15425
+
15426
+ // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
15427
+ var charCode = charStr.charCodeAt(charStr.length - 1);
15428
+ if (charCode >= 0xD800 && charCode <= 0xDBFF) {
15429
+ this.charLength += this.surrogateSize;
15430
+ charStr = '';
15431
+ continue;
15432
+ }
15433
+ this.charReceived = this.charLength = 0;
15430
15434
 
15431
- // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
15432
- StringDecoder.prototype.fillLast = function (buf) {
15433
- if (this.lastNeed <= buf.length) {
15434
- buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
15435
- return this.lastChar.toString(this.encoding, 0, this.lastTotal);
15435
+ // if there are no more bytes in this buffer, just emit our char
15436
+ if (buffer.length === 0) {
15437
+ return charStr;
15438
+ }
15439
+ break;
15436
15440
  }
15437
- buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
15438
- this.lastNeed -= buf.length;
15439
- };
15440
15441
 
15441
- // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
15442
- // continuation byte.
15443
- function utf8CheckByte(byte) {
15444
- if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
15445
- return -1;
15446
- }
15442
+ // determine and set charLength / charReceived
15443
+ this.detectIncompleteChar(buffer);
15447
15444
 
15448
- // Checks at most 3 bytes at the end of a Buffer in order to detect an
15449
- // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
15450
- // needed to complete the UTF-8 character (if applicable) are returned.
15451
- function utf8CheckIncomplete(self, buf, i) {
15452
- var j = buf.length - 1;
15453
- if (j < i) return 0;
15454
- var nb = utf8CheckByte(buf[j]);
15455
- if (nb >= 0) {
15456
- if (nb > 0) self.lastNeed = nb - 1;
15457
- return nb;
15445
+ var end = buffer.length;
15446
+ if (this.charLength) {
15447
+ // buffer the incomplete character bytes we got
15448
+ buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
15449
+ end -= this.charReceived;
15458
15450
  }
15459
- if (--j < i) return 0;
15460
- nb = utf8CheckByte(buf[j]);
15461
- if (nb >= 0) {
15462
- if (nb > 0) self.lastNeed = nb - 2;
15463
- return nb;
15451
+
15452
+ charStr += buffer.toString(this.encoding, 0, end);
15453
+
15454
+ var end = charStr.length - 1;
15455
+ var charCode = charStr.charCodeAt(end);
15456
+ // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
15457
+ if (charCode >= 0xD800 && charCode <= 0xDBFF) {
15458
+ var size = this.surrogateSize;
15459
+ this.charLength += size;
15460
+ this.charReceived += size;
15461
+ this.charBuffer.copy(this.charBuffer, size, 0, size);
15462
+ buffer.copy(this.charBuffer, 0, 0, size);
15463
+ return charStr.substring(0, end);
15464
15464
  }
15465
- if (--j < i) return 0;
15466
- nb = utf8CheckByte(buf[j]);
15467
- if (nb >= 0) {
15468
- if (nb > 0) {
15469
- if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
15465
+
15466
+ // or just emit the charStr
15467
+ return charStr;
15468
+ };
15469
+
15470
+ // detectIncompleteChar determines if there is an incomplete UTF-8 character at
15471
+ // the end of the given buffer. If so, it sets this.charLength to the byte
15472
+ // length that character, and sets this.charReceived to the number of bytes
15473
+ // that are available for this character.
15474
+ StringDecoder.prototype.detectIncompleteChar = function(buffer) {
15475
+ // determine how many bytes we have to check at the end of this buffer
15476
+ var i = (buffer.length >= 3) ? 3 : buffer.length;
15477
+
15478
+ // Figure out if one of the last i bytes of our buffer announces an
15479
+ // incomplete char.
15480
+ for (; i > 0; i--) {
15481
+ var c = buffer[buffer.length - i];
15482
+
15483
+ // See http://en.wikipedia.org/wiki/UTF-8#Description
15484
+
15485
+ // 110XXXXX
15486
+ if (i == 1 && c >> 5 == 0x06) {
15487
+ this.charLength = 2;
15488
+ break;
15470
15489
  }
15471
- return nb;
15472
- }
15473
- return 0;
15474
- }
15475
15490
 
15476
- // Validates as many continuation bytes for a multi-byte UTF-8 character as
15477
- // needed or are available. If we see a non-continuation byte where we expect
15478
- // one, we "replace" the validated continuation bytes we've seen so far with
15479
- // UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
15480
- // behavior. The continuation byte check is included three times in the case
15481
- // where all of the continuation bytes for a character exist in the same buffer.
15482
- // It is also done this way as a slight performance increase instead of using a
15483
- // loop.
15484
- function utf8CheckExtraBytes(self, buf, p) {
15485
- if ((buf[0] & 0xC0) !== 0x80) {
15486
- self.lastNeed = 0;
15487
- return '\ufffd'.repeat(p);
15488
- }
15489
- if (self.lastNeed > 1 && buf.length > 1) {
15490
- if ((buf[1] & 0xC0) !== 0x80) {
15491
- self.lastNeed = 1;
15492
- return '\ufffd'.repeat(p + 1);
15493
- }
15494
- if (self.lastNeed > 2 && buf.length > 2) {
15495
- if ((buf[2] & 0xC0) !== 0x80) {
15496
- self.lastNeed = 2;
15497
- return '\ufffd'.repeat(p + 2);
15498
- }
15491
+ // 1110XXXX
15492
+ if (i <= 2 && c >> 4 == 0x0E) {
15493
+ this.charLength = 3;
15494
+ break;
15499
15495
  }
15500
- }
15501
- }
15502
15496
 
15503
- // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
15504
- function utf8FillLast(buf) {
15505
- var p = this.lastTotal - this.lastNeed;
15506
- var r = utf8CheckExtraBytes(this, buf, p);
15507
- if (r !== undefined) return r;
15508
- if (this.lastNeed <= buf.length) {
15509
- buf.copy(this.lastChar, p, 0, this.lastNeed);
15510
- return this.lastChar.toString(this.encoding, 0, this.lastTotal);
15511
- }
15512
- buf.copy(this.lastChar, p, 0, buf.length);
15513
- this.lastNeed -= buf.length;
15514
- }
15515
-
15516
- // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
15517
- // partial character, the character's bytes are buffered until the required
15518
- // number of bytes are available.
15519
- function utf8Text(buf, i) {
15520
- var total = utf8CheckIncomplete(this, buf, i);
15521
- if (!this.lastNeed) return buf.toString('utf8', i);
15522
- this.lastTotal = total;
15523
- var end = buf.length - (total - this.lastNeed);
15524
- buf.copy(this.lastChar, 0, end);
15525
- return buf.toString('utf8', i, end);
15526
- }
15527
-
15528
- // For UTF-8, a replacement character for each buffered byte of a (partial)
15529
- // character needs to be added to the output.
15530
- function utf8End(buf) {
15531
- var r = buf && buf.length ? this.write(buf) : '';
15532
- if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
15533
- return r;
15534
- }
15535
-
15536
- // UTF-16LE typically needs two bytes per character, but even if we have an even
15537
- // number of bytes available, we need to check if we end on a leading/high
15538
- // surrogate. In that case, we need to wait for the next two bytes in order to
15539
- // decode the last character properly.
15540
- function utf16Text(buf, i) {
15541
- if ((buf.length - i) % 2 === 0) {
15542
- var r = buf.toString('utf16le', i);
15543
- if (r) {
15544
- var c = r.charCodeAt(r.length - 1);
15545
- if (c >= 0xD800 && c <= 0xDBFF) {
15546
- this.lastNeed = 2;
15547
- this.lastTotal = 4;
15548
- this.lastChar[0] = buf[buf.length - 2];
15549
- this.lastChar[1] = buf[buf.length - 1];
15550
- return r.slice(0, -1);
15551
- }
15497
+ // 11110XXX
15498
+ if (i <= 3 && c >> 3 == 0x1E) {
15499
+ this.charLength = 4;
15500
+ break;
15552
15501
  }
15553
- return r;
15554
15502
  }
15555
- this.lastNeed = 1;
15556
- this.lastTotal = 2;
15557
- this.lastChar[0] = buf[buf.length - 1];
15558
- return buf.toString('utf16le', i, buf.length - 1);
15559
- }
15503
+ this.charReceived = i;
15504
+ };
15560
15505
 
15561
- // For UTF-16LE we do not explicitly append special replacement characters if we
15562
- // end on a partial character, we simply let v8 handle that.
15563
- function utf16End(buf) {
15564
- var r = buf && buf.length ? this.write(buf) : '';
15565
- if (this.lastNeed) {
15566
- var end = this.lastTotal - this.lastNeed;
15567
- return r + this.lastChar.toString('utf16le', 0, end);
15568
- }
15569
- return r;
15570
- }
15506
+ StringDecoder.prototype.end = function(buffer) {
15507
+ var res = '';
15508
+ if (buffer && buffer.length)
15509
+ res = this.write(buffer);
15571
15510
 
15572
- function base64Text(buf, i) {
15573
- var n = (buf.length - i) % 3;
15574
- if (n === 0) return buf.toString('base64', i);
15575
- this.lastNeed = 3 - n;
15576
- this.lastTotal = 3;
15577
- if (n === 1) {
15578
- this.lastChar[0] = buf[buf.length - 1];
15579
- } else {
15580
- this.lastChar[0] = buf[buf.length - 2];
15581
- this.lastChar[1] = buf[buf.length - 1];
15511
+ if (this.charReceived) {
15512
+ var cr = this.charReceived;
15513
+ var buf = this.charBuffer;
15514
+ var enc = this.encoding;
15515
+ res += buf.slice(0, cr).toString(enc);
15582
15516
  }
15583
- return buf.toString('base64', i, buf.length - n);
15584
- }
15585
15517
 
15586
- function base64End(buf) {
15587
- var r = buf && buf.length ? this.write(buf) : '';
15588
- if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
15589
- return r;
15518
+ return res;
15519
+ };
15520
+
15521
+ function passThroughWrite(buffer) {
15522
+ return buffer.toString(this.encoding);
15590
15523
  }
15591
15524
 
15592
- // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
15593
- function simpleWrite(buf) {
15594
- return buf.toString(this.encoding);
15525
+ function utf16DetectIncompleteChar(buffer) {
15526
+ this.charReceived = buffer.length % 2;
15527
+ this.charLength = this.charReceived ? 2 : 0;
15595
15528
  }
15596
15529
 
15597
- function simpleEnd(buf) {
15598
- return buf && buf.length ? this.write(buf) : '';
15530
+ function base64DetectIncompleteChar(buffer) {
15531
+ this.charReceived = buffer.length % 3;
15532
+ this.charLength = this.charReceived ? 3 : 0;
15599
15533
  }
15600
- },{"buffer":44,"buffer-shims":43}],97:[function(require,module,exports){
15534
+
15535
+ },{"buffer":44}],96:[function(require,module,exports){
15601
15536
  (function (global){
15602
15537
 
15603
15538
  /**
@@ -15668,16 +15603,16 @@ function config (name) {
15668
15603
  }
15669
15604
 
15670
15605
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
15671
- },{}],98:[function(require,module,exports){
15606
+ },{}],97:[function(require,module,exports){
15672
15607
  arguments[4][66][0].apply(exports,arguments)
15673
- },{"dup":66}],99:[function(require,module,exports){
15608
+ },{"dup":66}],98:[function(require,module,exports){
15674
15609
  module.exports = function isBuffer(arg) {
15675
15610
  return arg && typeof arg === 'object'
15676
15611
  && typeof arg.copy === 'function'
15677
15612
  && typeof arg.fill === 'function'
15678
15613
  && typeof arg.readUInt8 === 'function';
15679
15614
  }
15680
- },{}],100:[function(require,module,exports){
15615
+ },{}],99:[function(require,module,exports){
15681
15616
  (function (process,global){
15682
15617
  // Copyright Joyent, Inc. and other Node contributors.
15683
15618
  //
@@ -16267,4 +16202,4 @@ function hasOwnProperty(obj, prop) {
16267
16202
  }
16268
16203
 
16269
16204
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
16270
- },{"./support/isBuffer":99,"_process":82,"inherits":98}]},{},[1]);
16205
+ },{"./support/isBuffer":98,"_process":82,"inherits":97}]},{},[1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "simple, flexible, fun test framework",
5
5
  "keywords": [
6
6
  "mocha",
@@ -299,6 +299,7 @@
299
299
  "npm": ">= 1.4.x"
300
300
  },
301
301
  "scripts": {
302
+ "lint": "eslint . bin/*",
302
303
  "test": "make test && make clean",
303
304
  "precoverage": "rm -rf coverage",
304
305
  "coverage": "COVERAGE=true npm run test",