Security update for permissions_by_term
[yaffs-website] / node_modules / is-function / browser-test.js
1 (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2 /**
3  * The buffer module from node.js, for the browser.
4  *
5  * Author:   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
6  * License:  MIT
7  *
8  * `npm install buffer`
9  */
10
11 var base64 = require('base64-js')
12 var ieee754 = require('ieee754')
13
14 exports.Buffer = Buffer
15 exports.SlowBuffer = Buffer
16 exports.INSPECT_MAX_BYTES = 50
17 Buffer.poolSize = 8192
18
19 /**
20  * If `Buffer._useTypedArrays`:
21  *   === true    Use Uint8Array implementation (fastest)
22  *   === false   Use Object implementation (compatible down to IE6)
23  */
24 Buffer._useTypedArrays = (function () {
25    // Detect if browser supports Typed Arrays. Supported browsers are IE 10+,
26    // Firefox 4+, Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+.
27   if (typeof Uint8Array === 'undefined' || typeof ArrayBuffer === 'undefined')
28     return false
29
30   // Does the browser support adding properties to `Uint8Array` instances? If
31   // not, then that's the same as no `Uint8Array` support. We need to be able to
32   // add all the node Buffer API methods.
33   // Relevant Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
34   try {
35     var arr = new Uint8Array(0)
36     arr.foo = function () { return 42 }
37     return 42 === arr.foo() &&
38         typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
39   } catch (e) {
40     return false
41   }
42 })()
43
44 /**
45  * Class: Buffer
46  * =============
47  *
48  * The Buffer constructor returns instances of `Uint8Array` that are augmented
49  * with function properties for all the node `Buffer` API functions. We use
50  * `Uint8Array` so that square bracket notation works as expected -- it returns
51  * a single octet.
52  *
53  * By augmenting the instances, we can avoid modifying the `Uint8Array`
54  * prototype.
55  */
56 function Buffer (subject, encoding, noZero) {
57   if (!(this instanceof Buffer))
58     return new Buffer(subject, encoding, noZero)
59
60   var type = typeof subject
61
62   // Workaround: node's base64 implementation allows for non-padded strings
63   // while base64-js does not.
64   if (encoding === 'base64' && type === 'string') {
65     subject = stringtrim(subject)
66     while (subject.length % 4 !== 0) {
67       subject = subject + '='
68     }
69   }
70
71   // Find the length
72   var length
73   if (type === 'number')
74     length = coerce(subject)
75   else if (type === 'string')
76     length = Buffer.byteLength(subject, encoding)
77   else if (type === 'object')
78     length = coerce(subject.length) // Assume object is an array
79   else
80     throw new Error('First argument needs to be a number, array or string.')
81
82   var buf
83   if (Buffer._useTypedArrays) {
84     // Preferred: Return an augmented `Uint8Array` instance for best performance
85     buf = augment(new Uint8Array(length))
86   } else {
87     // Fallback: Return THIS instance of Buffer (created by `new`)
88     buf = this
89     buf.length = length
90     buf._isBuffer = true
91   }
92
93   var i
94   if (Buffer._useTypedArrays && typeof Uint8Array === 'function' &&
95       subject instanceof Uint8Array) {
96     // Speed optimization -- use set if we're copying from a Uint8Array
97     buf._set(subject)
98   } else if (isArrayish(subject)) {
99     // Treat array-ish objects as a byte array
100     for (i = 0; i < length; i++) {
101       if (Buffer.isBuffer(subject))
102         buf[i] = subject.readUInt8(i)
103       else
104         buf[i] = subject[i]
105     }
106   } else if (type === 'string') {
107     buf.write(subject, 0, encoding)
108   } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
109     for (i = 0; i < length; i++) {
110       buf[i] = 0
111     }
112   }
113
114   return buf
115 }
116
117 // STATIC METHODS
118 // ==============
119
120 Buffer.isEncoding = function (encoding) {
121   switch (String(encoding).toLowerCase()) {
122     case 'hex':
123     case 'utf8':
124     case 'utf-8':
125     case 'ascii':
126     case 'binary':
127     case 'base64':
128     case 'raw':
129     case 'ucs2':
130     case 'ucs-2':
131     case 'utf16le':
132     case 'utf-16le':
133       return true
134     default:
135       return false
136   }
137 }
138
139 Buffer.isBuffer = function (b) {
140   return !!(b !== null && b !== undefined && b._isBuffer)
141 }
142
143 Buffer.byteLength = function (str, encoding) {
144   var ret
145   str = str + ''
146   switch (encoding || 'utf8') {
147     case 'hex':
148       ret = str.length / 2
149       break
150     case 'utf8':
151     case 'utf-8':
152       ret = utf8ToBytes(str).length
153       break
154     case 'ascii':
155     case 'binary':
156     case 'raw':
157       ret = str.length
158       break
159     case 'base64':
160       ret = base64ToBytes(str).length
161       break
162     case 'ucs2':
163     case 'ucs-2':
164     case 'utf16le':
165     case 'utf-16le':
166       ret = str.length * 2
167       break
168     default:
169       throw new Error('Unknown encoding')
170   }
171   return ret
172 }
173
174 Buffer.concat = function (list, totalLength) {
175   assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' +
176       'list should be an Array.')
177
178   if (list.length === 0) {
179     return new Buffer(0)
180   } else if (list.length === 1) {
181     return list[0]
182   }
183
184   var i
185   if (typeof totalLength !== 'number') {
186     totalLength = 0
187     for (i = 0; i < list.length; i++) {
188       totalLength += list[i].length
189     }
190   }
191
192   var buf = new Buffer(totalLength)
193   var pos = 0
194   for (i = 0; i < list.length; i++) {
195     var item = list[i]
196     item.copy(buf, pos)
197     pos += item.length
198   }
199   return buf
200 }
201
202 // BUFFER INSTANCE METHODS
203 // =======================
204
205 function _hexWrite (buf, string, offset, length) {
206   offset = Number(offset) || 0
207   var remaining = buf.length - offset
208   if (!length) {
209     length = remaining
210   } else {
211     length = Number(length)
212     if (length > remaining) {
213       length = remaining
214     }
215   }
216
217   // must be an even number of digits
218   var strLen = string.length
219   assert(strLen % 2 === 0, 'Invalid hex string')
220
221   if (length > strLen / 2) {
222     length = strLen / 2
223   }
224   for (var i = 0; i < length; i++) {
225     var byte = parseInt(string.substr(i * 2, 2), 16)
226     assert(!isNaN(byte), 'Invalid hex string')
227     buf[offset + i] = byte
228   }
229   Buffer._charsWritten = i * 2
230   return i
231 }
232
233 function _utf8Write (buf, string, offset, length) {
234   var charsWritten = Buffer._charsWritten =
235     blitBuffer(utf8ToBytes(string), buf, offset, length)
236   return charsWritten
237 }
238
239 function _asciiWrite (buf, string, offset, length) {
240   var charsWritten = Buffer._charsWritten =
241     blitBuffer(asciiToBytes(string), buf, offset, length)
242   return charsWritten
243 }
244
245 function _binaryWrite (buf, string, offset, length) {
246   return _asciiWrite(buf, string, offset, length)
247 }
248
249 function _base64Write (buf, string, offset, length) {
250   var charsWritten = Buffer._charsWritten =
251     blitBuffer(base64ToBytes(string), buf, offset, length)
252   return charsWritten
253 }
254
255 function _utf16leWrite (buf, string, offset, length) {
256   var charsWritten = Buffer._charsWritten =
257     blitBuffer(utf16leToBytes(string), buf, offset, length)
258   return charsWritten
259 }
260
261 Buffer.prototype.write = function (string, offset, length, encoding) {
262   // Support both (string, offset, length, encoding)
263   // and the legacy (string, encoding, offset, length)
264   if (isFinite(offset)) {
265     if (!isFinite(length)) {
266       encoding = length
267       length = undefined
268     }
269   } else {  // legacy
270     var swap = encoding
271     encoding = offset
272     offset = length
273     length = swap
274   }
275
276   offset = Number(offset) || 0
277   var remaining = this.length - offset
278   if (!length) {
279     length = remaining
280   } else {
281     length = Number(length)
282     if (length > remaining) {
283       length = remaining
284     }
285   }
286   encoding = String(encoding || 'utf8').toLowerCase()
287
288   var ret
289   switch (encoding) {
290     case 'hex':
291       ret = _hexWrite(this, string, offset, length)
292       break
293     case 'utf8':
294     case 'utf-8':
295       ret = _utf8Write(this, string, offset, length)
296       break
297     case 'ascii':
298       ret = _asciiWrite(this, string, offset, length)
299       break
300     case 'binary':
301       ret = _binaryWrite(this, string, offset, length)
302       break
303     case 'base64':
304       ret = _base64Write(this, string, offset, length)
305       break
306     case 'ucs2':
307     case 'ucs-2':
308     case 'utf16le':
309     case 'utf-16le':
310       ret = _utf16leWrite(this, string, offset, length)
311       break
312     default:
313       throw new Error('Unknown encoding')
314   }
315   return ret
316 }
317
318 Buffer.prototype.toString = function (encoding, start, end) {
319   var self = this
320
321   encoding = String(encoding || 'utf8').toLowerCase()
322   start = Number(start) || 0
323   end = (end !== undefined)
324     ? Number(end)
325     : end = self.length
326
327   // Fastpath empty strings
328   if (end === start)
329     return ''
330
331   var ret
332   switch (encoding) {
333     case 'hex':
334       ret = _hexSlice(self, start, end)
335       break
336     case 'utf8':
337     case 'utf-8':
338       ret = _utf8Slice(self, start, end)
339       break
340     case 'ascii':
341       ret = _asciiSlice(self, start, end)
342       break
343     case 'binary':
344       ret = _binarySlice(self, start, end)
345       break
346     case 'base64':
347       ret = _base64Slice(self, start, end)
348       break
349     case 'ucs2':
350     case 'ucs-2':
351     case 'utf16le':
352     case 'utf-16le':
353       ret = _utf16leSlice(self, start, end)
354       break
355     default:
356       throw new Error('Unknown encoding')
357   }
358   return ret
359 }
360
361 Buffer.prototype.toJSON = function () {
362   return {
363     type: 'Buffer',
364     data: Array.prototype.slice.call(this._arr || this, 0)
365   }
366 }
367
368 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
369 Buffer.prototype.copy = function (target, target_start, start, end) {
370   var source = this
371
372   if (!start) start = 0
373   if (!end && end !== 0) end = this.length
374   if (!target_start) target_start = 0
375
376   // Copy 0 bytes; we're done
377   if (end === start) return
378   if (target.length === 0 || source.length === 0) return
379
380   // Fatal error conditions
381   assert(end >= start, 'sourceEnd < sourceStart')
382   assert(target_start >= 0 && target_start < target.length,
383       'targetStart out of bounds')
384   assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
385   assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
386
387   // Are we oob?
388   if (end > this.length)
389     end = this.length
390   if (target.length - target_start < end - start)
391     end = target.length - target_start + start
392
393   // copy!
394   for (var i = 0; i < end - start; i++)
395     target[i + target_start] = this[i + start]
396 }
397
398 function _base64Slice (buf, start, end) {
399   if (start === 0 && end === buf.length) {
400     return base64.fromByteArray(buf)
401   } else {
402     return base64.fromByteArray(buf.slice(start, end))
403   }
404 }
405
406 function _utf8Slice (buf, start, end) {
407   var res = ''
408   var tmp = ''
409   end = Math.min(buf.length, end)
410
411   for (var i = start; i < end; i++) {
412     if (buf[i] <= 0x7F) {
413       res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
414       tmp = ''
415     } else {
416       tmp += '%' + buf[i].toString(16)
417     }
418   }
419
420   return res + decodeUtf8Char(tmp)
421 }
422
423 function _asciiSlice (buf, start, end) {
424   var ret = ''
425   end = Math.min(buf.length, end)
426
427   for (var i = start; i < end; i++)
428     ret += String.fromCharCode(buf[i])
429   return ret
430 }
431
432 function _binarySlice (buf, start, end) {
433   return _asciiSlice(buf, start, end)
434 }
435
436 function _hexSlice (buf, start, end) {
437   var len = buf.length
438
439   if (!start || start < 0) start = 0
440   if (!end || end < 0 || end > len) end = len
441
442   var out = ''
443   for (var i = start; i < end; i++) {
444     out += toHex(buf[i])
445   }
446   return out
447 }
448
449 function _utf16leSlice (buf, start, end) {
450   var bytes = buf.slice(start, end)
451   var res = ''
452   for (var i = 0; i < bytes.length; i += 2) {
453     res += String.fromCharCode(bytes[i] + bytes[i+1] * 256)
454   }
455   return res
456 }
457
458 Buffer.prototype.slice = function (start, end) {
459   var len = this.length
460   start = clamp(start, len, 0)
461   end = clamp(end, len, len)
462
463   if (Buffer._useTypedArrays) {
464     return augment(this.subarray(start, end))
465   } else {
466     var sliceLen = end - start
467     var newBuf = new Buffer(sliceLen, undefined, true)
468     for (var i = 0; i < sliceLen; i++) {
469       newBuf[i] = this[i + start]
470     }
471     return newBuf
472   }
473 }
474
475 // `get` will be removed in Node 0.13+
476 Buffer.prototype.get = function (offset) {
477   console.log('.get() is deprecated. Access using array indexes instead.')
478   return this.readUInt8(offset)
479 }
480
481 // `set` will be removed in Node 0.13+
482 Buffer.prototype.set = function (v, offset) {
483   console.log('.set() is deprecated. Access using array indexes instead.')
484   return this.writeUInt8(v, offset)
485 }
486
487 Buffer.prototype.readUInt8 = function (offset, noAssert) {
488   if (!noAssert) {
489     assert(offset !== undefined && offset !== null, 'missing offset')
490     assert(offset < this.length, 'Trying to read beyond buffer length')
491   }
492
493   if (offset >= this.length)
494     return
495
496   return this[offset]
497 }
498
499 function _readUInt16 (buf, offset, littleEndian, noAssert) {
500   if (!noAssert) {
501     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
502     assert(offset !== undefined && offset !== null, 'missing offset')
503     assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
504   }
505
506   var len = buf.length
507   if (offset >= len)
508     return
509
510   var val
511   if (littleEndian) {
512     val = buf[offset]
513     if (offset + 1 < len)
514       val |= buf[offset + 1] << 8
515   } else {
516     val = buf[offset] << 8
517     if (offset + 1 < len)
518       val |= buf[offset + 1]
519   }
520   return val
521 }
522
523 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
524   return _readUInt16(this, offset, true, noAssert)
525 }
526
527 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
528   return _readUInt16(this, offset, false, noAssert)
529 }
530
531 function _readUInt32 (buf, offset, littleEndian, noAssert) {
532   if (!noAssert) {
533     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
534     assert(offset !== undefined && offset !== null, 'missing offset')
535     assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
536   }
537
538   var len = buf.length
539   if (offset >= len)
540     return
541
542   var val
543   if (littleEndian) {
544     if (offset + 2 < len)
545       val = buf[offset + 2] << 16
546     if (offset + 1 < len)
547       val |= buf[offset + 1] << 8
548     val |= buf[offset]
549     if (offset + 3 < len)
550       val = val + (buf[offset + 3] << 24 >>> 0)
551   } else {
552     if (offset + 1 < len)
553       val = buf[offset + 1] << 16
554     if (offset + 2 < len)
555       val |= buf[offset + 2] << 8
556     if (offset + 3 < len)
557       val |= buf[offset + 3]
558     val = val + (buf[offset] << 24 >>> 0)
559   }
560   return val
561 }
562
563 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
564   return _readUInt32(this, offset, true, noAssert)
565 }
566
567 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
568   return _readUInt32(this, offset, false, noAssert)
569 }
570
571 Buffer.prototype.readInt8 = function (offset, noAssert) {
572   if (!noAssert) {
573     assert(offset !== undefined && offset !== null,
574         'missing offset')
575     assert(offset < this.length, 'Trying to read beyond buffer length')
576   }
577
578   if (offset >= this.length)
579     return
580
581   var neg = this[offset] & 0x80
582   if (neg)
583     return (0xff - this[offset] + 1) * -1
584   else
585     return this[offset]
586 }
587
588 function _readInt16 (buf, offset, littleEndian, noAssert) {
589   if (!noAssert) {
590     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
591     assert(offset !== undefined && offset !== null, 'missing offset')
592     assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
593   }
594
595   var len = buf.length
596   if (offset >= len)
597     return
598
599   var val = _readUInt16(buf, offset, littleEndian, true)
600   var neg = val & 0x8000
601   if (neg)
602     return (0xffff - val + 1) * -1
603   else
604     return val
605 }
606
607 Buffer.prototype.readInt16LE = function (offset, noAssert) {
608   return _readInt16(this, offset, true, noAssert)
609 }
610
611 Buffer.prototype.readInt16BE = function (offset, noAssert) {
612   return _readInt16(this, offset, false, noAssert)
613 }
614
615 function _readInt32 (buf, offset, littleEndian, noAssert) {
616   if (!noAssert) {
617     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
618     assert(offset !== undefined && offset !== null, 'missing offset')
619     assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
620   }
621
622   var len = buf.length
623   if (offset >= len)
624     return
625
626   var val = _readUInt32(buf, offset, littleEndian, true)
627   var neg = val & 0x80000000
628   if (neg)
629     return (0xffffffff - val + 1) * -1
630   else
631     return val
632 }
633
634 Buffer.prototype.readInt32LE = function (offset, noAssert) {
635   return _readInt32(this, offset, true, noAssert)
636 }
637
638 Buffer.prototype.readInt32BE = function (offset, noAssert) {
639   return _readInt32(this, offset, false, noAssert)
640 }
641
642 function _readFloat (buf, offset, littleEndian, noAssert) {
643   if (!noAssert) {
644     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
645     assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
646   }
647
648   return ieee754.read(buf, offset, littleEndian, 23, 4)
649 }
650
651 Buffer.prototype.readFloatLE = function (offset, noAssert) {
652   return _readFloat(this, offset, true, noAssert)
653 }
654
655 Buffer.prototype.readFloatBE = function (offset, noAssert) {
656   return _readFloat(this, offset, false, noAssert)
657 }
658
659 function _readDouble (buf, offset, littleEndian, noAssert) {
660   if (!noAssert) {
661     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
662     assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
663   }
664
665   return ieee754.read(buf, offset, littleEndian, 52, 8)
666 }
667
668 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
669   return _readDouble(this, offset, true, noAssert)
670 }
671
672 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
673   return _readDouble(this, offset, false, noAssert)
674 }
675
676 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
677   if (!noAssert) {
678     assert(value !== undefined && value !== null, 'missing value')
679     assert(offset !== undefined && offset !== null, 'missing offset')
680     assert(offset < this.length, 'trying to write beyond buffer length')
681     verifuint(value, 0xff)
682   }
683
684   if (offset >= this.length) return
685
686   this[offset] = value
687 }
688
689 function _writeUInt16 (buf, value, offset, littleEndian, noAssert) {
690   if (!noAssert) {
691     assert(value !== undefined && value !== null, 'missing value')
692     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
693     assert(offset !== undefined && offset !== null, 'missing offset')
694     assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
695     verifuint(value, 0xffff)
696   }
697
698   var len = buf.length
699   if (offset >= len)
700     return
701
702   for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
703     buf[offset + i] =
704         (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
705             (littleEndian ? i : 1 - i) * 8
706   }
707 }
708
709 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
710   _writeUInt16(this, value, offset, true, noAssert)
711 }
712
713 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
714   _writeUInt16(this, value, offset, false, noAssert)
715 }
716
717 function _writeUInt32 (buf, value, offset, littleEndian, noAssert) {
718   if (!noAssert) {
719     assert(value !== undefined && value !== null, 'missing value')
720     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
721     assert(offset !== undefined && offset !== null, 'missing offset')
722     assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
723     verifuint(value, 0xffffffff)
724   }
725
726   var len = buf.length
727   if (offset >= len)
728     return
729
730   for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
731     buf[offset + i] =
732         (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
733   }
734 }
735
736 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
737   _writeUInt32(this, value, offset, true, noAssert)
738 }
739
740 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
741   _writeUInt32(this, value, offset, false, noAssert)
742 }
743
744 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
745   if (!noAssert) {
746     assert(value !== undefined && value !== null, 'missing value')
747     assert(offset !== undefined && offset !== null, 'missing offset')
748     assert(offset < this.length, 'Trying to write beyond buffer length')
749     verifsint(value, 0x7f, -0x80)
750   }
751
752   if (offset >= this.length)
753     return
754
755   if (value >= 0)
756     this.writeUInt8(value, offset, noAssert)
757   else
758     this.writeUInt8(0xff + value + 1, offset, noAssert)
759 }
760
761 function _writeInt16 (buf, value, offset, littleEndian, noAssert) {
762   if (!noAssert) {
763     assert(value !== undefined && value !== null, 'missing value')
764     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
765     assert(offset !== undefined && offset !== null, 'missing offset')
766     assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
767     verifsint(value, 0x7fff, -0x8000)
768   }
769
770   var len = buf.length
771   if (offset >= len)
772     return
773
774   if (value >= 0)
775     _writeUInt16(buf, value, offset, littleEndian, noAssert)
776   else
777     _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
778 }
779
780 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
781   _writeInt16(this, value, offset, true, noAssert)
782 }
783
784 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
785   _writeInt16(this, value, offset, false, noAssert)
786 }
787
788 function _writeInt32 (buf, value, offset, littleEndian, noAssert) {
789   if (!noAssert) {
790     assert(value !== undefined && value !== null, 'missing value')
791     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
792     assert(offset !== undefined && offset !== null, 'missing offset')
793     assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
794     verifsint(value, 0x7fffffff, -0x80000000)
795   }
796
797   var len = buf.length
798   if (offset >= len)
799     return
800
801   if (value >= 0)
802     _writeUInt32(buf, value, offset, littleEndian, noAssert)
803   else
804     _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
805 }
806
807 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
808   _writeInt32(this, value, offset, true, noAssert)
809 }
810
811 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
812   _writeInt32(this, value, offset, false, noAssert)
813 }
814
815 function _writeFloat (buf, value, offset, littleEndian, noAssert) {
816   if (!noAssert) {
817     assert(value !== undefined && value !== null, 'missing value')
818     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
819     assert(offset !== undefined && offset !== null, 'missing offset')
820     assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
821     verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
822   }
823
824   var len = buf.length
825   if (offset >= len)
826     return
827
828   ieee754.write(buf, value, offset, littleEndian, 23, 4)
829 }
830
831 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
832   _writeFloat(this, value, offset, true, noAssert)
833 }
834
835 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
836   _writeFloat(this, value, offset, false, noAssert)
837 }
838
839 function _writeDouble (buf, value, offset, littleEndian, noAssert) {
840   if (!noAssert) {
841     assert(value !== undefined && value !== null, 'missing value')
842     assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
843     assert(offset !== undefined && offset !== null, 'missing offset')
844     assert(offset + 7 < buf.length,
845         'Trying to write beyond buffer length')
846     verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
847   }
848
849   var len = buf.length
850   if (offset >= len)
851     return
852
853   ieee754.write(buf, value, offset, littleEndian, 52, 8)
854 }
855
856 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
857   _writeDouble(this, value, offset, true, noAssert)
858 }
859
860 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
861   _writeDouble(this, value, offset, false, noAssert)
862 }
863
864 // fill(value, start=0, end=buffer.length)
865 Buffer.prototype.fill = function (value, start, end) {
866   if (!value) value = 0
867   if (!start) start = 0
868   if (!end) end = this.length
869
870   if (typeof value === 'string') {
871     value = value.charCodeAt(0)
872   }
873
874   assert(typeof value === 'number' && !isNaN(value), 'value is not a number')
875   assert(end >= start, 'end < start')
876
877   // Fill 0 bytes; we're done
878   if (end === start) return
879   if (this.length === 0) return
880
881   assert(start >= 0 && start < this.length, 'start out of bounds')
882   assert(end >= 0 && end <= this.length, 'end out of bounds')
883
884   for (var i = start; i < end; i++) {
885     this[i] = value
886   }
887 }
888
889 Buffer.prototype.inspect = function () {
890   var out = []
891   var len = this.length
892   for (var i = 0; i < len; i++) {
893     out[i] = toHex(this[i])
894     if (i === exports.INSPECT_MAX_BYTES) {
895       out[i + 1] = '...'
896       break
897     }
898   }
899   return '<Buffer ' + out.join(' ') + '>'
900 }
901
902 /**
903  * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
904  * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
905  */
906 Buffer.prototype.toArrayBuffer = function () {
907   if (typeof Uint8Array === 'function') {
908     if (Buffer._useTypedArrays) {
909       return (new Buffer(this)).buffer
910     } else {
911       var buf = new Uint8Array(this.length)
912       for (var i = 0, len = buf.length; i < len; i += 1)
913         buf[i] = this[i]
914       return buf.buffer
915     }
916   } else {
917     throw new Error('Buffer.toArrayBuffer not supported in this browser')
918   }
919 }
920
921 // HELPER FUNCTIONS
922 // ================
923
924 function stringtrim (str) {
925   if (str.trim) return str.trim()
926   return str.replace(/^\s+|\s+$/g, '')
927 }
928
929 var BP = Buffer.prototype
930
931 /**
932  * Augment the Uint8Array *instance* (not the class!) with Buffer methods
933  */
934 function augment (arr) {
935   arr._isBuffer = true
936
937   // save reference to original Uint8Array get/set methods before overwriting
938   arr._get = arr.get
939   arr._set = arr.set
940
941   // deprecated, will be removed in node 0.13+
942   arr.get = BP.get
943   arr.set = BP.set
944
945   arr.write = BP.write
946   arr.toString = BP.toString
947   arr.toLocaleString = BP.toString
948   arr.toJSON = BP.toJSON
949   arr.copy = BP.copy
950   arr.slice = BP.slice
951   arr.readUInt8 = BP.readUInt8
952   arr.readUInt16LE = BP.readUInt16LE
953   arr.readUInt16BE = BP.readUInt16BE
954   arr.readUInt32LE = BP.readUInt32LE
955   arr.readUInt32BE = BP.readUInt32BE
956   arr.readInt8 = BP.readInt8
957   arr.readInt16LE = BP.readInt16LE
958   arr.readInt16BE = BP.readInt16BE
959   arr.readInt32LE = BP.readInt32LE
960   arr.readInt32BE = BP.readInt32BE
961   arr.readFloatLE = BP.readFloatLE
962   arr.readFloatBE = BP.readFloatBE
963   arr.readDoubleLE = BP.readDoubleLE
964   arr.readDoubleBE = BP.readDoubleBE
965   arr.writeUInt8 = BP.writeUInt8
966   arr.writeUInt16LE = BP.writeUInt16LE
967   arr.writeUInt16BE = BP.writeUInt16BE
968   arr.writeUInt32LE = BP.writeUInt32LE
969   arr.writeUInt32BE = BP.writeUInt32BE
970   arr.writeInt8 = BP.writeInt8
971   arr.writeInt16LE = BP.writeInt16LE
972   arr.writeInt16BE = BP.writeInt16BE
973   arr.writeInt32LE = BP.writeInt32LE
974   arr.writeInt32BE = BP.writeInt32BE
975   arr.writeFloatLE = BP.writeFloatLE
976   arr.writeFloatBE = BP.writeFloatBE
977   arr.writeDoubleLE = BP.writeDoubleLE
978   arr.writeDoubleBE = BP.writeDoubleBE
979   arr.fill = BP.fill
980   arr.inspect = BP.inspect
981   arr.toArrayBuffer = BP.toArrayBuffer
982
983   return arr
984 }
985
986 // slice(start, end)
987 function clamp (index, len, defaultValue) {
988   if (typeof index !== 'number') return defaultValue
989   index = ~~index;  // Coerce to integer.
990   if (index >= len) return len
991   if (index >= 0) return index
992   index += len
993   if (index >= 0) return index
994   return 0
995 }
996
997 function coerce (length) {
998   // Coerce length to a number (possibly NaN), round up
999   // in case it's fractional (e.g. 123.456) then do a
1000   // double negate to coerce a NaN to 0. Easy, right?
1001   length = ~~Math.ceil(+length)
1002   return length < 0 ? 0 : length
1003 }
1004
1005 function isArray (subject) {
1006   return (Array.isArray || function (subject) {
1007     return Object.prototype.toString.call(subject) === '[object Array]'
1008   })(subject)
1009 }
1010
1011 function isArrayish (subject) {
1012   return isArray(subject) || Buffer.isBuffer(subject) ||
1013       subject && typeof subject === 'object' &&
1014       typeof subject.length === 'number'
1015 }
1016
1017 function toHex (n) {
1018   if (n < 16) return '0' + n.toString(16)
1019   return n.toString(16)
1020 }
1021
1022 function utf8ToBytes (str) {
1023   var byteArray = []
1024   for (var i = 0; i < str.length; i++) {
1025     var b = str.charCodeAt(i)
1026     if (b <= 0x7F)
1027       byteArray.push(str.charCodeAt(i))
1028     else {
1029       var start = i
1030       if (b >= 0xD800 && b <= 0xDFFF) i++
1031       var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
1032       for (var j = 0; j < h.length; j++)
1033         byteArray.push(parseInt(h[j], 16))
1034     }
1035   }
1036   return byteArray
1037 }
1038
1039 function asciiToBytes (str) {
1040   var byteArray = []
1041   for (var i = 0; i < str.length; i++) {
1042     // Node's code seems to be doing this and not & 0x7F..
1043     byteArray.push(str.charCodeAt(i) & 0xFF)
1044   }
1045   return byteArray
1046 }
1047
1048 function utf16leToBytes (str) {
1049   var c, hi, lo
1050   var byteArray = []
1051   for (var i = 0; i < str.length; i++) {
1052     c = str.charCodeAt(i)
1053     hi = c >> 8
1054     lo = c % 256
1055     byteArray.push(lo)
1056     byteArray.push(hi)
1057   }
1058
1059   return byteArray
1060 }
1061
1062 function base64ToBytes (str) {
1063   return base64.toByteArray(str)
1064 }
1065
1066 function blitBuffer (src, dst, offset, length) {
1067   var pos
1068   for (var i = 0; i < length; i++) {
1069     if ((i + offset >= dst.length) || (i >= src.length))
1070       break
1071     dst[i + offset] = src[i]
1072   }
1073   return i
1074 }
1075
1076 function decodeUtf8Char (str) {
1077   try {
1078     return decodeURIComponent(str)
1079   } catch (err) {
1080     return String.fromCharCode(0xFFFD) // UTF 8 invalid char
1081   }
1082 }
1083
1084 /*
1085  * We have to make sure that the value is a valid integer. This means that it
1086  * is non-negative. It has no fractional component and that it does not
1087  * exceed the maximum allowed value.
1088  */
1089 function verifuint (value, max) {
1090   assert(typeof value === 'number', 'cannot write a non-number as a number')
1091   assert(value >= 0,
1092       'specified a negative value for writing an unsigned value')
1093   assert(value <= max, 'value is larger than maximum value for type')
1094   assert(Math.floor(value) === value, 'value has a fractional component')
1095 }
1096
1097 function verifsint (value, max, min) {
1098   assert(typeof value === 'number', 'cannot write a non-number as a number')
1099   assert(value <= max, 'value larger than maximum allowed value')
1100   assert(value >= min, 'value smaller than minimum allowed value')
1101   assert(Math.floor(value) === value, 'value has a fractional component')
1102 }
1103
1104 function verifIEEE754 (value, max, min) {
1105   assert(typeof value === 'number', 'cannot write a non-number as a number')
1106   assert(value <= max, 'value larger than maximum allowed value')
1107   assert(value >= min, 'value smaller than minimum allowed value')
1108 }
1109
1110 function assert (test, message) {
1111   if (!test) throw new Error(message || 'Failed assertion')
1112 }
1113
1114 },{"base64-js":2,"ieee754":3}],2:[function(require,module,exports){
1115 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1116
1117 ;(function (exports) {
1118         'use strict';
1119
1120   var Arr = (typeof Uint8Array !== 'undefined')
1121     ? Uint8Array
1122     : Array
1123
1124         var ZERO   = '0'.charCodeAt(0)
1125         var PLUS   = '+'.charCodeAt(0)
1126         var SLASH  = '/'.charCodeAt(0)
1127         var NUMBER = '0'.charCodeAt(0)
1128         var LOWER  = 'a'.charCodeAt(0)
1129         var UPPER  = 'A'.charCodeAt(0)
1130
1131         function decode (elt) {
1132                 var code = elt.charCodeAt(0)
1133                 if (code === PLUS)
1134                         return 62 // '+'
1135                 if (code === SLASH)
1136                         return 63 // '/'
1137                 if (code < NUMBER)
1138                         return -1 //no match
1139                 if (code < NUMBER + 10)
1140                         return code - NUMBER + 26 + 26
1141                 if (code < UPPER + 26)
1142                         return code - UPPER
1143                 if (code < LOWER + 26)
1144                         return code - LOWER + 26
1145         }
1146
1147         function b64ToByteArray (b64) {
1148                 var i, j, l, tmp, placeHolders, arr
1149
1150                 if (b64.length % 4 > 0) {
1151                         throw new Error('Invalid string. Length must be a multiple of 4')
1152                 }
1153
1154                 // the number of equal signs (place holders)
1155                 // if there are two placeholders, than the two characters before it
1156                 // represent one byte
1157                 // if there is only one, then the three characters before it represent 2 bytes
1158                 // this is just a cheap hack to not do indexOf twice
1159                 var len = b64.length
1160                 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
1161
1162                 // base64 is 4/3 + up to two characters of the original data
1163                 arr = new Arr(b64.length * 3 / 4 - placeHolders)
1164
1165                 // if there are placeholders, only get up to the last complete 4 chars
1166                 l = placeHolders > 0 ? b64.length - 4 : b64.length
1167
1168                 var L = 0
1169
1170                 function push (v) {
1171                         arr[L++] = v
1172                 }
1173
1174                 for (i = 0, j = 0; i < l; i += 4, j += 3) {
1175                         tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
1176                         push((tmp & 0xFF0000) >> 16)
1177                         push((tmp & 0xFF00) >> 8)
1178                         push(tmp & 0xFF)
1179                 }
1180
1181                 if (placeHolders === 2) {
1182                         tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
1183                         push(tmp & 0xFF)
1184                 } else if (placeHolders === 1) {
1185                         tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
1186                         push((tmp >> 8) & 0xFF)
1187                         push(tmp & 0xFF)
1188                 }
1189
1190                 return arr
1191         }
1192
1193         function uint8ToBase64 (uint8) {
1194                 var i,
1195                         extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
1196                         output = "",
1197                         temp, length
1198
1199                 function encode (num) {
1200                         return lookup.charAt(num)
1201                 }
1202
1203                 function tripletToBase64 (num) {
1204                         return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
1205                 }
1206
1207                 // go through the array every three bytes, we'll deal with trailing stuff later
1208                 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
1209                         temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
1210                         output += tripletToBase64(temp)
1211                 }
1212
1213                 // pad the end with zeros, but make sure to not forget the extra bytes
1214                 switch (extraBytes) {
1215                         case 1:
1216                                 temp = uint8[uint8.length - 1]
1217                                 output += encode(temp >> 2)
1218                                 output += encode((temp << 4) & 0x3F)
1219                                 output += '=='
1220                                 break
1221                         case 2:
1222                                 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
1223                                 output += encode(temp >> 10)
1224                                 output += encode((temp >> 4) & 0x3F)
1225                                 output += encode((temp << 2) & 0x3F)
1226                                 output += '='
1227                                 break
1228                 }
1229
1230                 return output
1231         }
1232
1233         module.exports.toByteArray = b64ToByteArray
1234         module.exports.fromByteArray = uint8ToBase64
1235 }())
1236
1237 },{}],3:[function(require,module,exports){
1238 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
1239   var e, m,
1240       eLen = nBytes * 8 - mLen - 1,
1241       eMax = (1 << eLen) - 1,
1242       eBias = eMax >> 1,
1243       nBits = -7,
1244       i = isLE ? (nBytes - 1) : 0,
1245       d = isLE ? -1 : 1,
1246       s = buffer[offset + i];
1247
1248   i += d;
1249
1250   e = s & ((1 << (-nBits)) - 1);
1251   s >>= (-nBits);
1252   nBits += eLen;
1253   for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
1254
1255   m = e & ((1 << (-nBits)) - 1);
1256   e >>= (-nBits);
1257   nBits += mLen;
1258   for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
1259
1260   if (e === 0) {
1261     e = 1 - eBias;
1262   } else if (e === eMax) {
1263     return m ? NaN : ((s ? -1 : 1) * Infinity);
1264   } else {
1265     m = m + Math.pow(2, mLen);
1266     e = e - eBias;
1267   }
1268   return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
1269 };
1270
1271 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
1272   var e, m, c,
1273       eLen = nBytes * 8 - mLen - 1,
1274       eMax = (1 << eLen) - 1,
1275       eBias = eMax >> 1,
1276       rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
1277       i = isLE ? 0 : (nBytes - 1),
1278       d = isLE ? 1 : -1,
1279       s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
1280
1281   value = Math.abs(value);
1282
1283   if (isNaN(value) || value === Infinity) {
1284     m = isNaN(value) ? 1 : 0;
1285     e = eMax;
1286   } else {
1287     e = Math.floor(Math.log(value) / Math.LN2);
1288     if (value * (c = Math.pow(2, -e)) < 1) {
1289       e--;
1290       c *= 2;
1291     }
1292     if (e + eBias >= 1) {
1293       value += rt / c;
1294     } else {
1295       value += rt * Math.pow(2, 1 - eBias);
1296     }
1297     if (value * c >= 2) {
1298       e++;
1299       c /= 2;
1300     }
1301
1302     if (e + eBias >= eMax) {
1303       m = 0;
1304       e = eMax;
1305     } else if (e + eBias >= 1) {
1306       m = (value * c - 1) * Math.pow(2, mLen);
1307       e = e + eBias;
1308     } else {
1309       m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1310       e = 0;
1311     }
1312   }
1313
1314   for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
1315
1316   e = (e << mLen) | m;
1317   eLen += mLen;
1318   for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
1319
1320   buffer[offset + i - d] |= s * 128;
1321 };
1322
1323 },{}],4:[function(require,module,exports){
1324 // Copyright Joyent, Inc. and other Node contributors.
1325 //
1326 // Permission is hereby granted, free of charge, to any person obtaining a
1327 // copy of this software and associated documentation files (the
1328 // "Software"), to deal in the Software without restriction, including
1329 // without limitation the rights to use, copy, modify, merge, publish,
1330 // distribute, sublicense, and/or sell copies of the Software, and to permit
1331 // persons to whom the Software is furnished to do so, subject to the
1332 // following conditions:
1333 //
1334 // The above copyright notice and this permission notice shall be included
1335 // in all copies or substantial portions of the Software.
1336 //
1337 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1338 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1339 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1340 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1341 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1342 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1343 // USE OR OTHER DEALINGS IN THE SOFTWARE.
1344
1345 function EventEmitter() {
1346   this._events = this._events || {};
1347   this._maxListeners = this._maxListeners || undefined;
1348 }
1349 module.exports = EventEmitter;
1350
1351 // Backwards-compat with node 0.10.x
1352 EventEmitter.EventEmitter = EventEmitter;
1353
1354 EventEmitter.prototype._events = undefined;
1355 EventEmitter.prototype._maxListeners = undefined;
1356
1357 // By default EventEmitters will print a warning if more than 10 listeners are
1358 // added to it. This is a useful default which helps finding memory leaks.
1359 EventEmitter.defaultMaxListeners = 10;
1360
1361 // Obviously not all Emitters should be limited to 10. This function allows
1362 // that to be increased. Set to zero for unlimited.
1363 EventEmitter.prototype.setMaxListeners = function(n) {
1364   if (!isNumber(n) || n < 0 || isNaN(n))
1365     throw TypeError('n must be a positive number');
1366   this._maxListeners = n;
1367   return this;
1368 };
1369
1370 EventEmitter.prototype.emit = function(type) {
1371   var er, handler, len, args, i, listeners;
1372
1373   if (!this._events)
1374     this._events = {};
1375
1376   // If there is no 'error' event listener then throw.
1377   if (type === 'error') {
1378     if (!this._events.error ||
1379         (isObject(this._events.error) && !this._events.error.length)) {
1380       er = arguments[1];
1381       if (er instanceof Error) {
1382         throw er; // Unhandled 'error' event
1383       } else {
1384         throw TypeError('Uncaught, unspecified "error" event.');
1385       }
1386       return false;
1387     }
1388   }
1389
1390   handler = this._events[type];
1391
1392   if (isUndefined(handler))
1393     return false;
1394
1395   if (isFunction(handler)) {
1396     switch (arguments.length) {
1397       // fast cases
1398       case 1:
1399         handler.call(this);
1400         break;
1401       case 2:
1402         handler.call(this, arguments[1]);
1403         break;
1404       case 3:
1405         handler.call(this, arguments[1], arguments[2]);
1406         break;
1407       // slower
1408       default:
1409         len = arguments.length;
1410         args = new Array(len - 1);
1411         for (i = 1; i < len; i++)
1412           args[i - 1] = arguments[i];
1413         handler.apply(this, args);
1414     }
1415   } else if (isObject(handler)) {
1416     len = arguments.length;
1417     args = new Array(len - 1);
1418     for (i = 1; i < len; i++)
1419       args[i - 1] = arguments[i];
1420
1421     listeners = handler.slice();
1422     len = listeners.length;
1423     for (i = 0; i < len; i++)
1424       listeners[i].apply(this, args);
1425   }
1426
1427   return true;
1428 };
1429
1430 EventEmitter.prototype.addListener = function(type, listener) {
1431   var m;
1432
1433   if (!isFunction(listener))
1434     throw TypeError('listener must be a function');
1435
1436   if (!this._events)
1437     this._events = {};
1438
1439   // To avoid recursion in the case that type === "newListener"! Before
1440   // adding it to the listeners, first emit "newListener".
1441   if (this._events.newListener)
1442     this.emit('newListener', type,
1443               isFunction(listener.listener) ?
1444               listener.listener : listener);
1445
1446   if (!this._events[type])
1447     // Optimize the case of one listener. Don't need the extra array object.
1448     this._events[type] = listener;
1449   else if (isObject(this._events[type]))
1450     // If we've already got an array, just append.
1451     this._events[type].push(listener);
1452   else
1453     // Adding the second element, need to change to array.
1454     this._events[type] = [this._events[type], listener];
1455
1456   // Check for listener leak
1457   if (isObject(this._events[type]) && !this._events[type].warned) {
1458     var m;
1459     if (!isUndefined(this._maxListeners)) {
1460       m = this._maxListeners;
1461     } else {
1462       m = EventEmitter.defaultMaxListeners;
1463     }
1464
1465     if (m && m > 0 && this._events[type].length > m) {
1466       this._events[type].warned = true;
1467       console.error('(node) warning: possible EventEmitter memory ' +
1468                     'leak detected. %d listeners added. ' +
1469                     'Use emitter.setMaxListeners() to increase limit.',
1470                     this._events[type].length);
1471       console.trace();
1472     }
1473   }
1474
1475   return this;
1476 };
1477
1478 EventEmitter.prototype.on = EventEmitter.prototype.addListener;
1479
1480 EventEmitter.prototype.once = function(type, listener) {
1481   if (!isFunction(listener))
1482     throw TypeError('listener must be a function');
1483
1484   var fired = false;
1485
1486   function g() {
1487     this.removeListener(type, g);
1488
1489     if (!fired) {
1490       fired = true;
1491       listener.apply(this, arguments);
1492     }
1493   }
1494
1495   g.listener = listener;
1496   this.on(type, g);
1497
1498   return this;
1499 };
1500
1501 // emits a 'removeListener' event iff the listener was removed
1502 EventEmitter.prototype.removeListener = function(type, listener) {
1503   var list, position, length, i;
1504
1505   if (!isFunction(listener))
1506     throw TypeError('listener must be a function');
1507
1508   if (!this._events || !this._events[type])
1509     return this;
1510
1511   list = this._events[type];
1512   length = list.length;
1513   position = -1;
1514
1515   if (list === listener ||
1516       (isFunction(list.listener) && list.listener === listener)) {
1517     delete this._events[type];
1518     if (this._events.removeListener)
1519       this.emit('removeListener', type, listener);
1520
1521   } else if (isObject(list)) {
1522     for (i = length; i-- > 0;) {
1523       if (list[i] === listener ||
1524           (list[i].listener && list[i].listener === listener)) {
1525         position = i;
1526         break;
1527       }
1528     }
1529
1530     if (position < 0)
1531       return this;
1532
1533     if (list.length === 1) {
1534       list.length = 0;
1535       delete this._events[type];
1536     } else {
1537       list.splice(position, 1);
1538     }
1539
1540     if (this._events.removeListener)
1541       this.emit('removeListener', type, listener);
1542   }
1543
1544   return this;
1545 };
1546
1547 EventEmitter.prototype.removeAllListeners = function(type) {
1548   var key, listeners;
1549
1550   if (!this._events)
1551     return this;
1552
1553   // not listening for removeListener, no need to emit
1554   if (!this._events.removeListener) {
1555     if (arguments.length === 0)
1556       this._events = {};
1557     else if (this._events[type])
1558       delete this._events[type];
1559     return this;
1560   }
1561
1562   // emit removeListener for all listeners on all events
1563   if (arguments.length === 0) {
1564     for (key in this._events) {
1565       if (key === 'removeListener') continue;
1566       this.removeAllListeners(key);
1567     }
1568     this.removeAllListeners('removeListener');
1569     this._events = {};
1570     return this;
1571   }
1572
1573   listeners = this._events[type];
1574
1575   if (isFunction(listeners)) {
1576     this.removeListener(type, listeners);
1577   } else {
1578     // LIFO order
1579     while (listeners.length)
1580       this.removeListener(type, listeners[listeners.length - 1]);
1581   }
1582   delete this._events[type];
1583
1584   return this;
1585 };
1586
1587 EventEmitter.prototype.listeners = function(type) {
1588   var ret;
1589   if (!this._events || !this._events[type])
1590     ret = [];
1591   else if (isFunction(this._events[type]))
1592     ret = [this._events[type]];
1593   else
1594     ret = this._events[type].slice();
1595   return ret;
1596 };
1597
1598 EventEmitter.listenerCount = function(emitter, type) {
1599   var ret;
1600   if (!emitter._events || !emitter._events[type])
1601     ret = 0;
1602   else if (isFunction(emitter._events[type]))
1603     ret = 1;
1604   else
1605     ret = emitter._events[type].length;
1606   return ret;
1607 };
1608
1609 function isFunction(arg) {
1610   return typeof arg === 'function';
1611 }
1612
1613 function isNumber(arg) {
1614   return typeof arg === 'number';
1615 }
1616
1617 function isObject(arg) {
1618   return typeof arg === 'object' && arg !== null;
1619 }
1620
1621 function isUndefined(arg) {
1622   return arg === void 0;
1623 }
1624
1625 },{}],5:[function(require,module,exports){
1626 if (typeof Object.create === 'function') {
1627   // implementation from standard node.js 'util' module
1628   module.exports = function inherits(ctor, superCtor) {
1629     ctor.super_ = superCtor
1630     ctor.prototype = Object.create(superCtor.prototype, {
1631       constructor: {
1632         value: ctor,
1633         enumerable: false,
1634         writable: true,
1635         configurable: true
1636       }
1637     });
1638   };
1639 } else {
1640   // old school shim for old browsers
1641   module.exports = function inherits(ctor, superCtor) {
1642     ctor.super_ = superCtor
1643     var TempCtor = function () {}
1644     TempCtor.prototype = superCtor.prototype
1645     ctor.prototype = new TempCtor()
1646     ctor.prototype.constructor = ctor
1647   }
1648 }
1649
1650 },{}],6:[function(require,module,exports){
1651 // shim for using process in browser
1652
1653 var process = module.exports = {};
1654
1655 process.nextTick = (function () {
1656     var canSetImmediate = typeof window !== 'undefined'
1657     && window.setImmediate;
1658     var canPost = typeof window !== 'undefined'
1659     && window.postMessage && window.addEventListener
1660     ;
1661
1662     if (canSetImmediate) {
1663         return function (f) { return window.setImmediate(f) };
1664     }
1665
1666     if (canPost) {
1667         var queue = [];
1668         window.addEventListener('message', function (ev) {
1669             var source = ev.source;
1670             if ((source === window || source === null) && ev.data === 'process-tick') {
1671                 ev.stopPropagation();
1672                 if (queue.length > 0) {
1673                     var fn = queue.shift();
1674                     fn();
1675                 }
1676             }
1677         }, true);
1678
1679         return function nextTick(fn) {
1680             queue.push(fn);
1681             window.postMessage('process-tick', '*');
1682         };
1683     }
1684
1685     return function nextTick(fn) {
1686         setTimeout(fn, 0);
1687     };
1688 })();
1689
1690 process.title = 'browser';
1691 process.browser = true;
1692 process.env = {};
1693 process.argv = [];
1694
1695 process.binding = function (name) {
1696     throw new Error('process.binding is not supported');
1697 }
1698
1699 // TODO(shtylman)
1700 process.cwd = function () { return '/' };
1701 process.chdir = function (dir) {
1702     throw new Error('process.chdir is not supported');
1703 };
1704
1705 },{}],7:[function(require,module,exports){
1706 (function (process){
1707 // Copyright Joyent, Inc. and other Node contributors.
1708 //
1709 // Permission is hereby granted, free of charge, to any person obtaining a
1710 // copy of this software and associated documentation files (the
1711 // "Software"), to deal in the Software without restriction, including
1712 // without limitation the rights to use, copy, modify, merge, publish,
1713 // distribute, sublicense, and/or sell copies of the Software, and to permit
1714 // persons to whom the Software is furnished to do so, subject to the
1715 // following conditions:
1716 //
1717 // The above copyright notice and this permission notice shall be included
1718 // in all copies or substantial portions of the Software.
1719 //
1720 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1721 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1722 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1723 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1724 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1725 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1726 // USE OR OTHER DEALINGS IN THE SOFTWARE.
1727
1728 // resolves . and .. elements in a path array with directory names there
1729 // must be no slashes, empty elements, or device names (c:\) in the array
1730 // (so also no leading and trailing slashes - it does not distinguish
1731 // relative and absolute paths)
1732 function normalizeArray(parts, allowAboveRoot) {
1733   // if the path tries to go above the root, `up` ends up > 0
1734   var up = 0;
1735   for (var i = parts.length - 1; i >= 0; i--) {
1736     var last = parts[i];
1737     if (last === '.') {
1738       parts.splice(i, 1);
1739     } else if (last === '..') {
1740       parts.splice(i, 1);
1741       up++;
1742     } else if (up) {
1743       parts.splice(i, 1);
1744       up--;
1745     }
1746   }
1747
1748   // if the path is allowed to go above the root, restore leading ..s
1749   if (allowAboveRoot) {
1750     for (; up--; up) {
1751       parts.unshift('..');
1752     }
1753   }
1754
1755   return parts;
1756 }
1757
1758 // Split a filename into [root, dir, basename, ext], unix version
1759 // 'root' is just a slash, or nothing.
1760 var splitPathRe =
1761     /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
1762 var splitPath = function(filename) {
1763   return splitPathRe.exec(filename).slice(1);
1764 };
1765
1766 // path.resolve([from ...], to)
1767 // posix version
1768 exports.resolve = function() {
1769   var resolvedPath = '',
1770       resolvedAbsolute = false;
1771
1772   for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1773     var path = (i >= 0) ? arguments[i] : process.cwd();
1774
1775     // Skip empty and invalid entries
1776     if (typeof path !== 'string') {
1777       throw new TypeError('Arguments to path.resolve must be strings');
1778     } else if (!path) {
1779       continue;
1780     }
1781
1782     resolvedPath = path + '/' + resolvedPath;
1783     resolvedAbsolute = path.charAt(0) === '/';
1784   }
1785
1786   // At this point the path should be resolved to a full absolute path, but
1787   // handle relative paths to be safe (might happen when process.cwd() fails)
1788
1789   // Normalize the path
1790   resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
1791     return !!p;
1792   }), !resolvedAbsolute).join('/');
1793
1794   return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
1795 };
1796
1797 // path.normalize(path)
1798 // posix version
1799 exports.normalize = function(path) {
1800   var isAbsolute = exports.isAbsolute(path),
1801       trailingSlash = substr(path, -1) === '/';
1802
1803   // Normalize the path
1804   path = normalizeArray(filter(path.split('/'), function(p) {
1805     return !!p;
1806   }), !isAbsolute).join('/');
1807
1808   if (!path && !isAbsolute) {
1809     path = '.';
1810   }
1811   if (path && trailingSlash) {
1812     path += '/';
1813   }
1814
1815   return (isAbsolute ? '/' : '') + path;
1816 };
1817
1818 // posix version
1819 exports.isAbsolute = function(path) {
1820   return path.charAt(0) === '/';
1821 };
1822
1823 // posix version
1824 exports.join = function() {
1825   var paths = Array.prototype.slice.call(arguments, 0);
1826   return exports.normalize(filter(paths, function(p, index) {
1827     if (typeof p !== 'string') {
1828       throw new TypeError('Arguments to path.join must be strings');
1829     }
1830     return p;
1831   }).join('/'));
1832 };
1833
1834
1835 // path.relative(from, to)
1836 // posix version
1837 exports.relative = function(from, to) {
1838   from = exports.resolve(from).substr(1);
1839   to = exports.resolve(to).substr(1);
1840
1841   function trim(arr) {
1842     var start = 0;
1843     for (; start < arr.length; start++) {
1844       if (arr[start] !== '') break;
1845     }
1846
1847     var end = arr.length - 1;
1848     for (; end >= 0; end--) {
1849       if (arr[end] !== '') break;
1850     }
1851
1852     if (start > end) return [];
1853     return arr.slice(start, end - start + 1);
1854   }
1855
1856   var fromParts = trim(from.split('/'));
1857   var toParts = trim(to.split('/'));
1858
1859   var length = Math.min(fromParts.length, toParts.length);
1860   var samePartsLength = length;
1861   for (var i = 0; i < length; i++) {
1862     if (fromParts[i] !== toParts[i]) {
1863       samePartsLength = i;
1864       break;
1865     }
1866   }
1867
1868   var outputParts = [];
1869   for (var i = samePartsLength; i < fromParts.length; i++) {
1870     outputParts.push('..');
1871   }
1872
1873   outputParts = outputParts.concat(toParts.slice(samePartsLength));
1874
1875   return outputParts.join('/');
1876 };
1877
1878 exports.sep = '/';
1879 exports.delimiter = ':';
1880
1881 exports.dirname = function(path) {
1882   var result = splitPath(path),
1883       root = result[0],
1884       dir = result[1];
1885
1886   if (!root && !dir) {
1887     // No dirname whatsoever
1888     return '.';
1889   }
1890
1891   if (dir) {
1892     // It has a dirname, strip trailing slash
1893     dir = dir.substr(0, dir.length - 1);
1894   }
1895
1896   return root + dir;
1897 };
1898
1899
1900 exports.basename = function(path, ext) {
1901   var f = splitPath(path)[2];
1902   // TODO: make this comparison case-insensitive on windows?
1903   if (ext && f.substr(-1 * ext.length) === ext) {
1904     f = f.substr(0, f.length - ext.length);
1905   }
1906   return f;
1907 };
1908
1909
1910 exports.extname = function(path) {
1911   return splitPath(path)[3];
1912 };
1913
1914 function filter (xs, f) {
1915     if (xs.filter) return xs.filter(f);
1916     var res = [];
1917     for (var i = 0; i < xs.length; i++) {
1918         if (f(xs[i], i, xs)) res.push(xs[i]);
1919     }
1920     return res;
1921 }
1922
1923 // String.prototype.substr - negative index don't work in IE8
1924 var substr = 'ab'.substr(-1) === 'b'
1925     ? function (str, start, len) { return str.substr(start, len) }
1926     : function (str, start, len) {
1927         if (start < 0) start = str.length + start;
1928         return str.substr(start, len);
1929     }
1930 ;
1931
1932 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
1933 },{"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6}],8:[function(require,module,exports){
1934 // Copyright Joyent, Inc. and other Node contributors.
1935 //
1936 // Permission is hereby granted, free of charge, to any person obtaining a
1937 // copy of this software and associated documentation files (the
1938 // "Software"), to deal in the Software without restriction, including
1939 // without limitation the rights to use, copy, modify, merge, publish,
1940 // distribute, sublicense, and/or sell copies of the Software, and to permit
1941 // persons to whom the Software is furnished to do so, subject to the
1942 // following conditions:
1943 //
1944 // The above copyright notice and this permission notice shall be included
1945 // in all copies or substantial portions of the Software.
1946 //
1947 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1948 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1949 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1950 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1951 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1952 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1953 // USE OR OTHER DEALINGS IN THE SOFTWARE.
1954
1955 // a duplex stream is just a stream that is both readable and writable.
1956 // Since JS doesn't have multiple prototypal inheritance, this class
1957 // prototypally inherits from Readable, and then parasitically from
1958 // Writable.
1959
1960 module.exports = Duplex;
1961 var inherits = require('inherits');
1962 var setImmediate = require('process/browser.js').nextTick;
1963 var Readable = require('./readable.js');
1964 var Writable = require('./writable.js');
1965
1966 inherits(Duplex, Readable);
1967
1968 Duplex.prototype.write = Writable.prototype.write;
1969 Duplex.prototype.end = Writable.prototype.end;
1970 Duplex.prototype._write = Writable.prototype._write;
1971
1972 function Duplex(options) {
1973   if (!(this instanceof Duplex))
1974     return new Duplex(options);
1975
1976   Readable.call(this, options);
1977   Writable.call(this, options);
1978
1979   if (options && options.readable === false)
1980     this.readable = false;
1981
1982   if (options && options.writable === false)
1983     this.writable = false;
1984
1985   this.allowHalfOpen = true;
1986   if (options && options.allowHalfOpen === false)
1987     this.allowHalfOpen = false;
1988
1989   this.once('end', onend);
1990 }
1991
1992 // the no-half-open enforcer
1993 function onend() {
1994   // if we allow half-open state, or if the writable side ended,
1995   // then we're ok.
1996   if (this.allowHalfOpen || this._writableState.ended)
1997     return;
1998
1999   // no more data can be written.
2000   // But allow more writes to happen in this tick.
2001   var self = this;
2002   setImmediate(function () {
2003     self.end();
2004   });
2005 }
2006
2007 },{"./readable.js":12,"./writable.js":14,"inherits":5,"process/browser.js":10}],9:[function(require,module,exports){
2008 // Copyright Joyent, Inc. and other Node contributors.
2009 //
2010 // Permission is hereby granted, free of charge, to any person obtaining a
2011 // copy of this software and associated documentation files (the
2012 // "Software"), to deal in the Software without restriction, including
2013 // without limitation the rights to use, copy, modify, merge, publish,
2014 // distribute, sublicense, and/or sell copies of the Software, and to permit
2015 // persons to whom the Software is furnished to do so, subject to the
2016 // following conditions:
2017 //
2018 // The above copyright notice and this permission notice shall be included
2019 // in all copies or substantial portions of the Software.
2020 //
2021 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2022 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2023 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2024 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2025 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2026 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2027 // USE OR OTHER DEALINGS IN THE SOFTWARE.
2028
2029 module.exports = Stream;
2030
2031 var EE = require('events').EventEmitter;
2032 var inherits = require('inherits');
2033
2034 inherits(Stream, EE);
2035 Stream.Readable = require('./readable.js');
2036 Stream.Writable = require('./writable.js');
2037 Stream.Duplex = require('./duplex.js');
2038 Stream.Transform = require('./transform.js');
2039 Stream.PassThrough = require('./passthrough.js');
2040
2041 // Backwards-compat with node 0.4.x
2042 Stream.Stream = Stream;
2043
2044
2045
2046 // old-style streams.  Note that the pipe method (the only relevant
2047 // part of this class) is overridden in the Readable class.
2048
2049 function Stream() {
2050   EE.call(this);
2051 }
2052
2053 Stream.prototype.pipe = function(dest, options) {
2054   var source = this;
2055
2056   function ondata(chunk) {
2057     if (dest.writable) {
2058       if (false === dest.write(chunk) && source.pause) {
2059         source.pause();
2060       }
2061     }
2062   }
2063
2064   source.on('data', ondata);
2065
2066   function ondrain() {
2067     if (source.readable && source.resume) {
2068       source.resume();
2069     }
2070   }
2071
2072   dest.on('drain', ondrain);
2073
2074   // If the 'end' option is not supplied, dest.end() will be called when
2075   // source gets the 'end' or 'close' events.  Only dest.end() once.
2076   if (!dest._isStdio && (!options || options.end !== false)) {
2077     source.on('end', onend);
2078     source.on('close', onclose);
2079   }
2080
2081   var didOnEnd = false;
2082   function onend() {
2083     if (didOnEnd) return;
2084     didOnEnd = true;
2085
2086     dest.end();
2087   }
2088
2089
2090   function onclose() {
2091     if (didOnEnd) return;
2092     didOnEnd = true;
2093
2094     if (typeof dest.destroy === 'function') dest.destroy();
2095   }
2096
2097   // don't leave dangling pipes when there are errors.
2098   function onerror(er) {
2099     cleanup();
2100     if (EE.listenerCount(this, 'error') === 0) {
2101       throw er; // Unhandled stream error in pipe.
2102     }
2103   }
2104
2105   source.on('error', onerror);
2106   dest.on('error', onerror);
2107
2108   // remove all the event listeners that were added.
2109   function cleanup() {
2110     source.removeListener('data', ondata);
2111     dest.removeListener('drain', ondrain);
2112
2113     source.removeListener('end', onend);
2114     source.removeListener('close', onclose);
2115
2116     source.removeListener('error', onerror);
2117     dest.removeListener('error', onerror);
2118
2119     source.removeListener('end', cleanup);
2120     source.removeListener('close', cleanup);
2121
2122     dest.removeListener('close', cleanup);
2123   }
2124
2125   source.on('end', cleanup);
2126   source.on('close', cleanup);
2127
2128   dest.on('close', cleanup);
2129
2130   dest.emit('pipe', source);
2131
2132   // Allow for unix-like usage: A.pipe(B).pipe(C)
2133   return dest;
2134 };
2135
2136 },{"./duplex.js":8,"./passthrough.js":11,"./readable.js":12,"./transform.js":13,"./writable.js":14,"events":4,"inherits":5}],10:[function(require,module,exports){
2137 module.exports=require(6)
2138 },{}],11:[function(require,module,exports){
2139 // Copyright Joyent, Inc. and other Node contributors.
2140 //
2141 // Permission is hereby granted, free of charge, to any person obtaining a
2142 // copy of this software and associated documentation files (the
2143 // "Software"), to deal in the Software without restriction, including
2144 // without limitation the rights to use, copy, modify, merge, publish,
2145 // distribute, sublicense, and/or sell copies of the Software, and to permit
2146 // persons to whom the Software is furnished to do so, subject to the
2147 // following conditions:
2148 //
2149 // The above copyright notice and this permission notice shall be included
2150 // in all copies or substantial portions of the Software.
2151 //
2152 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2153 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2154 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2155 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2156 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2157 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2158 // USE OR OTHER DEALINGS IN THE SOFTWARE.
2159
2160 // a passthrough stream.
2161 // basically just the most minimal sort of Transform stream.
2162 // Every written chunk gets output as-is.
2163
2164 module.exports = PassThrough;
2165
2166 var Transform = require('./transform.js');
2167 var inherits = require('inherits');
2168 inherits(PassThrough, Transform);
2169
2170 function PassThrough(options) {
2171   if (!(this instanceof PassThrough))
2172     return new PassThrough(options);
2173
2174   Transform.call(this, options);
2175 }
2176
2177 PassThrough.prototype._transform = function(chunk, encoding, cb) {
2178   cb(null, chunk);
2179 };
2180
2181 },{"./transform.js":13,"inherits":5}],12:[function(require,module,exports){
2182 (function (process){
2183 // Copyright Joyent, Inc. and other Node contributors.
2184 //
2185 // Permission is hereby granted, free of charge, to any person obtaining a
2186 // copy of this software and associated documentation files (the
2187 // "Software"), to deal in the Software without restriction, including
2188 // without limitation the rights to use, copy, modify, merge, publish,
2189 // distribute, sublicense, and/or sell copies of the Software, and to permit
2190 // persons to whom the Software is furnished to do so, subject to the
2191 // following conditions:
2192 //
2193 // The above copyright notice and this permission notice shall be included
2194 // in all copies or substantial portions of the Software.
2195 //
2196 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2197 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2198 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2199 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2200 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2201 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2202 // USE OR OTHER DEALINGS IN THE SOFTWARE.
2203
2204 module.exports = Readable;
2205 Readable.ReadableState = ReadableState;
2206
2207 var EE = require('events').EventEmitter;
2208 var Stream = require('./index.js');
2209 var Buffer = require('buffer').Buffer;
2210 var setImmediate = require('process/browser.js').nextTick;
2211 var StringDecoder;
2212
2213 var inherits = require('inherits');
2214 inherits(Readable, Stream);
2215
2216 function ReadableState(options, stream) {
2217   options = options || {};
2218
2219   // the point at which it stops calling _read() to fill the buffer
2220   // Note: 0 is a valid value, means "don't call _read preemptively ever"
2221   var hwm = options.highWaterMark;
2222   this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
2223
2224   // cast to ints.
2225   this.highWaterMark = ~~this.highWaterMark;
2226
2227   this.buffer = [];
2228   this.length = 0;
2229   this.pipes = null;
2230   this.pipesCount = 0;
2231   this.flowing = false;
2232   this.ended = false;
2233   this.endEmitted = false;
2234   this.reading = false;
2235
2236   // In streams that never have any data, and do push(null) right away,
2237   // the consumer can miss the 'end' event if they do some I/O before
2238   // consuming the stream.  So, we don't emit('end') until some reading
2239   // happens.
2240   this.calledRead = false;
2241
2242   // a flag to be able to tell if the onwrite cb is called immediately,
2243   // or on a later tick.  We set this to true at first, becuase any
2244   // actions that shouldn't happen until "later" should generally also
2245   // not happen before the first write call.
2246   this.sync = true;
2247
2248   // whenever we return null, then we set a flag to say
2249   // that we're awaiting a 'readable' event emission.
2250   this.needReadable = false;
2251   this.emittedReadable = false;
2252   this.readableListening = false;
2253
2254
2255   // object stream flag. Used to make read(n) ignore n and to
2256   // make all the buffer merging and length checks go away
2257   this.objectMode = !!options.objectMode;
2258
2259   // Crypto is kind of old and crusty.  Historically, its default string
2260   // encoding is 'binary' so we have to make this configurable.
2261   // Everything else in the universe uses 'utf8', though.
2262   this.defaultEncoding = options.defaultEncoding || 'utf8';
2263
2264   // when piping, we only care about 'readable' events that happen
2265   // after read()ing all the bytes and not getting any pushback.
2266   this.ranOut = false;
2267
2268   // the number of writers that are awaiting a drain event in .pipe()s
2269   this.awaitDrain = 0;
2270
2271   // if true, a maybeReadMore has been scheduled
2272   this.readingMore = false;
2273
2274   this.decoder = null;
2275   this.encoding = null;
2276   if (options.encoding) {
2277     if (!StringDecoder)
2278       StringDecoder = require('string_decoder').StringDecoder;
2279     this.decoder = new StringDecoder(options.encoding);
2280     this.encoding = options.encoding;
2281   }
2282 }
2283
2284 function Readable(options) {
2285   if (!(this instanceof Readable))
2286     return new Readable(options);
2287
2288   this._readableState = new ReadableState(options, this);
2289
2290   // legacy
2291   this.readable = true;
2292
2293   Stream.call(this);
2294 }
2295
2296 // Manually shove something into the read() buffer.
2297 // This returns true if the highWaterMark has not been hit yet,
2298 // similar to how Writable.write() returns true if you should
2299 // write() some more.
2300 Readable.prototype.push = function(chunk, encoding) {
2301   var state = this._readableState;
2302
2303   if (typeof chunk === 'string' && !state.objectMode) {
2304     encoding = encoding || state.defaultEncoding;
2305     if (encoding !== state.encoding) {
2306       chunk = new Buffer(chunk, encoding);
2307       encoding = '';
2308     }
2309   }
2310
2311   return readableAddChunk(this, state, chunk, encoding, false);
2312 };
2313
2314 // Unshift should *always* be something directly out of read()
2315 Readable.prototype.unshift = function(chunk) {
2316   var state = this._readableState;
2317   return readableAddChunk(this, state, chunk, '', true);
2318 };
2319
2320 function readableAddChunk(stream, state, chunk, encoding, addToFront) {
2321   var er = chunkInvalid(state, chunk);
2322   if (er) {
2323     stream.emit('error', er);
2324   } else if (chunk === null || chunk === undefined) {
2325     state.reading = false;
2326     if (!state.ended)
2327       onEofChunk(stream, state);
2328   } else if (state.objectMode || chunk && chunk.length > 0) {
2329     if (state.ended && !addToFront) {
2330       var e = new Error('stream.push() after EOF');
2331       stream.emit('error', e);
2332     } else if (state.endEmitted && addToFront) {
2333       var e = new Error('stream.unshift() after end event');
2334       stream.emit('error', e);
2335     } else {
2336       if (state.decoder && !addToFront && !encoding)
2337         chunk = state.decoder.write(chunk);
2338
2339       // update the buffer info.
2340       state.length += state.objectMode ? 1 : chunk.length;
2341       if (addToFront) {
2342         state.buffer.unshift(chunk);
2343       } else {
2344         state.reading = false;
2345         state.buffer.push(chunk);
2346       }
2347
2348       if (state.needReadable)
2349         emitReadable(stream);
2350
2351       maybeReadMore(stream, state);
2352     }
2353   } else if (!addToFront) {
2354     state.reading = false;
2355   }
2356
2357   return needMoreData(state);
2358 }
2359
2360
2361
2362 // if it's past the high water mark, we can push in some more.
2363 // Also, if we have no data yet, we can stand some
2364 // more bytes.  This is to work around cases where hwm=0,
2365 // such as the repl.  Also, if the push() triggered a
2366 // readable event, and the user called read(largeNumber) such that
2367 // needReadable was set, then we ought to push more, so that another
2368 // 'readable' event will be triggered.
2369 function needMoreData(state) {
2370   return !state.ended &&
2371          (state.needReadable ||
2372           state.length < state.highWaterMark ||
2373           state.length === 0);
2374 }
2375
2376 // backwards compatibility.
2377 Readable.prototype.setEncoding = function(enc) {
2378   if (!StringDecoder)
2379     StringDecoder = require('string_decoder').StringDecoder;
2380   this._readableState.decoder = new StringDecoder(enc);
2381   this._readableState.encoding = enc;
2382 };
2383
2384 // Don't raise the hwm > 128MB
2385 var MAX_HWM = 0x800000;
2386 function roundUpToNextPowerOf2(n) {
2387   if (n >= MAX_HWM) {
2388     n = MAX_HWM;
2389   } else {
2390     // Get the next highest power of 2
2391     n--;
2392     for (var p = 1; p < 32; p <<= 1) n |= n >> p;
2393     n++;
2394   }
2395   return n;
2396 }
2397
2398 function howMuchToRead(n, state) {
2399   if (state.length === 0 && state.ended)
2400     return 0;
2401
2402   if (state.objectMode)
2403     return n === 0 ? 0 : 1;
2404
2405   if (isNaN(n) || n === null) {
2406     // only flow one buffer at a time
2407     if (state.flowing && state.buffer.length)
2408       return state.buffer[0].length;
2409     else
2410       return state.length;
2411   }
2412
2413   if (n <= 0)
2414     return 0;
2415
2416   // If we're asking for more than the target buffer level,
2417   // then raise the water mark.  Bump up to the next highest
2418   // power of 2, to prevent increasing it excessively in tiny
2419   // amounts.
2420   if (n > state.highWaterMark)
2421     state.highWaterMark = roundUpToNextPowerOf2(n);
2422
2423   // don't have that much.  return null, unless we've ended.
2424   if (n > state.length) {
2425     if (!state.ended) {
2426       state.needReadable = true;
2427       return 0;
2428     } else
2429       return state.length;
2430   }
2431
2432   return n;
2433 }
2434
2435 // you can override either this method, or the async _read(n) below.
2436 Readable.prototype.read = function(n) {
2437   var state = this._readableState;
2438   state.calledRead = true;
2439   var nOrig = n;
2440
2441   if (typeof n !== 'number' || n > 0)
2442     state.emittedReadable = false;
2443
2444   // if we're doing read(0) to trigger a readable event, but we
2445   // already have a bunch of data in the buffer, then just trigger
2446   // the 'readable' event and move on.
2447   if (n === 0 &&
2448       state.needReadable &&
2449       (state.length >= state.highWaterMark || state.ended)) {
2450     emitReadable(this);
2451     return null;
2452   }
2453
2454   n = howMuchToRead(n, state);
2455
2456   // if we've ended, and we're now clear, then finish it up.
2457   if (n === 0 && state.ended) {
2458     if (state.length === 0)
2459       endReadable(this);
2460     return null;
2461   }
2462
2463   // All the actual chunk generation logic needs to be
2464   // *below* the call to _read.  The reason is that in certain
2465   // synthetic stream cases, such as passthrough streams, _read
2466   // may be a completely synchronous operation which may change
2467   // the state of the read buffer, providing enough data when
2468   // before there was *not* enough.
2469   //
2470   // So, the steps are:
2471   // 1. Figure out what the state of things will be after we do
2472   // a read from the buffer.
2473   //
2474   // 2. If that resulting state will trigger a _read, then call _read.
2475   // Note that this may be asynchronous, or synchronous.  Yes, it is
2476   // deeply ugly to write APIs this way, but that still doesn't mean
2477   // that the Readable class should behave improperly, as streams are
2478   // designed to be sync/async agnostic.
2479   // Take note if the _read call is sync or async (ie, if the read call
2480   // has returned yet), so that we know whether or not it's safe to emit
2481   // 'readable' etc.
2482   //
2483   // 3. Actually pull the requested chunks out of the buffer and return.
2484
2485   // if we need a readable event, then we need to do some reading.
2486   var doRead = state.needReadable;
2487
2488   // if we currently have less than the highWaterMark, then also read some
2489   if (state.length - n <= state.highWaterMark)
2490     doRead = true;
2491
2492   // however, if we've ended, then there's no point, and if we're already
2493   // reading, then it's unnecessary.
2494   if (state.ended || state.reading)
2495     doRead = false;
2496
2497   if (doRead) {
2498     state.reading = true;
2499     state.sync = true;
2500     // if the length is currently zero, then we *need* a readable event.
2501     if (state.length === 0)
2502       state.needReadable = true;
2503     // call internal read method
2504     this._read(state.highWaterMark);
2505     state.sync = false;
2506   }
2507
2508   // If _read called its callback synchronously, then `reading`
2509   // will be false, and we need to re-evaluate how much data we
2510   // can return to the user.
2511   if (doRead && !state.reading)
2512     n = howMuchToRead(nOrig, state);
2513
2514   var ret;
2515   if (n > 0)
2516     ret = fromList(n, state);
2517   else
2518     ret = null;
2519
2520   if (ret === null) {
2521     state.needReadable = true;
2522     n = 0;
2523   }
2524
2525   state.length -= n;
2526
2527   // If we have nothing in the buffer, then we want to know
2528   // as soon as we *do* get something into the buffer.
2529   if (state.length === 0 && !state.ended)
2530     state.needReadable = true;
2531
2532   // If we happened to read() exactly the remaining amount in the
2533   // buffer, and the EOF has been seen at this point, then make sure
2534   // that we emit 'end' on the very next tick.
2535   if (state.ended && !state.endEmitted && state.length === 0)
2536     endReadable(this);
2537
2538   return ret;
2539 };
2540
2541 function chunkInvalid(state, chunk) {
2542   var er = null;
2543   if (!Buffer.isBuffer(chunk) &&
2544       'string' !== typeof chunk &&
2545       chunk !== null &&
2546       chunk !== undefined &&
2547       !state.objectMode &&
2548       !er) {
2549     er = new TypeError('Invalid non-string/buffer chunk');
2550   }
2551   return er;
2552 }
2553
2554
2555 function onEofChunk(stream, state) {
2556   if (state.decoder && !state.ended) {
2557     var chunk = state.decoder.end();
2558     if (chunk && chunk.length) {
2559       state.buffer.push(chunk);
2560       state.length += state.objectMode ? 1 : chunk.length;
2561     }
2562   }
2563   state.ended = true;
2564
2565   // if we've ended and we have some data left, then emit
2566   // 'readable' now to make sure it gets picked up.
2567   if (state.length > 0)
2568     emitReadable(stream);
2569   else
2570     endReadable(stream);
2571 }
2572
2573 // Don't emit readable right away in sync mode, because this can trigger
2574 // another read() call => stack overflow.  This way, it might trigger
2575 // a nextTick recursion warning, but that's not so bad.
2576 function emitReadable(stream) {
2577   var state = stream._readableState;
2578   state.needReadable = false;
2579   if (state.emittedReadable)
2580     return;
2581
2582   state.emittedReadable = true;
2583   if (state.sync)
2584     setImmediate(function() {
2585       emitReadable_(stream);
2586     });
2587   else
2588     emitReadable_(stream);
2589 }
2590
2591 function emitReadable_(stream) {
2592   stream.emit('readable');
2593 }
2594
2595
2596 // at this point, the user has presumably seen the 'readable' event,
2597 // and called read() to consume some data.  that may have triggered
2598 // in turn another _read(n) call, in which case reading = true if
2599 // it's in progress.
2600 // However, if we're not ended, or reading, and the length < hwm,
2601 // then go ahead and try to read some more preemptively.
2602 function maybeReadMore(stream, state) {
2603   if (!state.readingMore) {
2604     state.readingMore = true;
2605     setImmediate(function() {
2606       maybeReadMore_(stream, state);
2607     });
2608   }
2609 }
2610
2611 function maybeReadMore_(stream, state) {
2612   var len = state.length;
2613   while (!state.reading && !state.flowing && !state.ended &&
2614          state.length < state.highWaterMark) {
2615     stream.read(0);
2616     if (len === state.length)
2617       // didn't get any data, stop spinning.
2618       break;
2619     else
2620       len = state.length;
2621   }
2622   state.readingMore = false;
2623 }
2624
2625 // abstract method.  to be overridden in specific implementation classes.
2626 // call cb(er, data) where data is <= n in length.
2627 // for virtual (non-string, non-buffer) streams, "length" is somewhat
2628 // arbitrary, and perhaps not very meaningful.
2629 Readable.prototype._read = function(n) {
2630   this.emit('error', new Error('not implemented'));
2631 };
2632
2633 Readable.prototype.pipe = function(dest, pipeOpts) {
2634   var src = this;
2635   var state = this._readableState;
2636
2637   switch (state.pipesCount) {
2638     case 0:
2639       state.pipes = dest;
2640       break;
2641     case 1:
2642       state.pipes = [state.pipes, dest];
2643       break;
2644     default:
2645       state.pipes.push(dest);
2646       break;
2647   }
2648   state.pipesCount += 1;
2649
2650   var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
2651               dest !== process.stdout &&
2652               dest !== process.stderr;
2653
2654   var endFn = doEnd ? onend : cleanup;
2655   if (state.endEmitted)
2656     setImmediate(endFn);
2657   else
2658     src.once('end', endFn);
2659
2660   dest.on('unpipe', onunpipe);
2661   function onunpipe(readable) {
2662     if (readable !== src) return;
2663     cleanup();
2664   }
2665
2666   function onend() {
2667     dest.end();
2668   }
2669
2670   // when the dest drains, it reduces the awaitDrain counter
2671   // on the source.  This would be more elegant with a .once()
2672   // handler in flow(), but adding and removing repeatedly is
2673   // too slow.
2674   var ondrain = pipeOnDrain(src);
2675   dest.on('drain', ondrain);
2676
2677   function cleanup() {
2678     // cleanup event handlers once the pipe is broken
2679     dest.removeListener('close', onclose);
2680     dest.removeListener('finish', onfinish);
2681     dest.removeListener('drain', ondrain);
2682     dest.removeListener('error', onerror);
2683     dest.removeListener('unpipe', onunpipe);
2684     src.removeListener('end', onend);
2685     src.removeListener('end', cleanup);
2686
2687     // if the reader is waiting for a drain event from this
2688     // specific writer, then it would cause it to never start
2689     // flowing again.
2690     // So, if this is awaiting a drain, then we just call it now.
2691     // If we don't know, then assume that we are waiting for one.
2692     if (!dest._writableState || dest._writableState.needDrain)
2693       ondrain();
2694   }
2695
2696   // if the dest has an error, then stop piping into it.
2697   // however, don't suppress the throwing behavior for this.
2698   // check for listeners before emit removes one-time listeners.
2699   var errListeners = EE.listenerCount(dest, 'error');
2700   function onerror(er) {
2701     unpipe();
2702     if (errListeners === 0 && EE.listenerCount(dest, 'error') === 0)
2703       dest.emit('error', er);
2704   }
2705   dest.once('error', onerror);
2706
2707   // Both close and finish should trigger unpipe, but only once.
2708   function onclose() {
2709     dest.removeListener('finish', onfinish);
2710     unpipe();
2711   }
2712   dest.once('close', onclose);
2713   function onfinish() {
2714     dest.removeListener('close', onclose);
2715     unpipe();
2716   }
2717   dest.once('finish', onfinish);
2718
2719   function unpipe() {
2720     src.unpipe(dest);
2721   }
2722
2723   // tell the dest that it's being piped to
2724   dest.emit('pipe', src);
2725
2726   // start the flow if it hasn't been started already.
2727   if (!state.flowing) {
2728     // the handler that waits for readable events after all
2729     // the data gets sucked out in flow.
2730     // This would be easier to follow with a .once() handler
2731     // in flow(), but that is too slow.
2732     this.on('readable', pipeOnReadable);
2733
2734     state.flowing = true;
2735     setImmediate(function() {
2736       flow(src);
2737     });
2738   }
2739
2740   return dest;
2741 };
2742
2743 function pipeOnDrain(src) {
2744   return function() {
2745     var dest = this;
2746     var state = src._readableState;
2747     state.awaitDrain--;
2748     if (state.awaitDrain === 0)
2749       flow(src);
2750   };
2751 }
2752
2753 function flow(src) {
2754   var state = src._readableState;
2755   var chunk;
2756   state.awaitDrain = 0;
2757
2758   function write(dest, i, list) {
2759     var written = dest.write(chunk);
2760     if (false === written) {
2761       state.awaitDrain++;
2762     }
2763   }
2764
2765   while (state.pipesCount && null !== (chunk = src.read())) {
2766
2767     if (state.pipesCount === 1)
2768       write(state.pipes, 0, null);
2769     else
2770       forEach(state.pipes, write);
2771
2772     src.emit('data', chunk);
2773
2774     // if anyone needs a drain, then we have to wait for that.
2775     if (state.awaitDrain > 0)
2776       return;
2777   }
2778
2779   // if every destination was unpiped, either before entering this
2780   // function, or in the while loop, then stop flowing.
2781   //
2782   // NB: This is a pretty rare edge case.
2783   if (state.pipesCount === 0) {
2784     state.flowing = false;
2785
2786     // if there were data event listeners added, then switch to old mode.
2787     if (EE.listenerCount(src, 'data') > 0)
2788       emitDataEvents(src);
2789     return;
2790   }
2791
2792   // at this point, no one needed a drain, so we just ran out of data
2793   // on the next readable event, start it over again.
2794   state.ranOut = true;
2795 }
2796
2797 function pipeOnReadable() {
2798   if (this._readableState.ranOut) {
2799     this._readableState.ranOut = false;
2800     flow(this);
2801   }
2802 }
2803
2804
2805 Readable.prototype.unpipe = function(dest) {
2806   var state = this._readableState;
2807
2808   // if we're not piping anywhere, then do nothing.
2809   if (state.pipesCount === 0)
2810     return this;
2811
2812   // just one destination.  most common case.
2813   if (state.pipesCount === 1) {
2814     // passed in one, but it's not the right one.
2815     if (dest && dest !== state.pipes)
2816       return this;
2817
2818     if (!dest)
2819       dest = state.pipes;
2820
2821     // got a match.
2822     state.pipes = null;
2823     state.pipesCount = 0;
2824     this.removeListener('readable', pipeOnReadable);
2825     state.flowing = false;
2826     if (dest)
2827       dest.emit('unpipe', this);
2828     return this;
2829   }
2830
2831   // slow case. multiple pipe destinations.
2832
2833   if (!dest) {
2834     // remove all.
2835     var dests = state.pipes;
2836     var len = state.pipesCount;
2837     state.pipes = null;
2838     state.pipesCount = 0;
2839     this.removeListener('readable', pipeOnReadable);
2840     state.flowing = false;
2841
2842     for (var i = 0; i < len; i++)
2843       dests[i].emit('unpipe', this);
2844     return this;
2845   }
2846
2847   // try to find the right one.
2848   var i = indexOf(state.pipes, dest);
2849   if (i === -1)
2850     return this;
2851
2852   state.pipes.splice(i, 1);
2853   state.pipesCount -= 1;
2854   if (state.pipesCount === 1)
2855     state.pipes = state.pipes[0];
2856
2857   dest.emit('unpipe', this);
2858
2859   return this;
2860 };
2861
2862 // set up data events if they are asked for
2863 // Ensure readable listeners eventually get something
2864 Readable.prototype.on = function(ev, fn) {
2865   var res = Stream.prototype.on.call(this, ev, fn);
2866
2867   if (ev === 'data' && !this._readableState.flowing)
2868     emitDataEvents(this);
2869
2870   if (ev === 'readable' && this.readable) {
2871     var state = this._readableState;
2872     if (!state.readableListening) {
2873       state.readableListening = true;
2874       state.emittedReadable = false;
2875       state.needReadable = true;
2876       if (!state.reading) {
2877         this.read(0);
2878       } else if (state.length) {
2879         emitReadable(this, state);
2880       }
2881     }
2882   }
2883
2884   return res;
2885 };
2886 Readable.prototype.addListener = Readable.prototype.on;
2887
2888 // pause() and resume() are remnants of the legacy readable stream API
2889 // If the user uses them, then switch into old mode.
2890 Readable.prototype.resume = function() {
2891   emitDataEvents(this);
2892   this.read(0);
2893   this.emit('resume');
2894 };
2895
2896 Readable.prototype.pause = function() {
2897   emitDataEvents(this, true);
2898   this.emit('pause');
2899 };
2900
2901 function emitDataEvents(stream, startPaused) {
2902   var state = stream._readableState;
2903
2904   if (state.flowing) {
2905     // https://github.com/isaacs/readable-stream/issues/16
2906     throw new Error('Cannot switch to old mode now.');
2907   }
2908
2909   var paused = startPaused || false;
2910   var readable = false;
2911
2912   // convert to an old-style stream.
2913   stream.readable = true;
2914   stream.pipe = Stream.prototype.pipe;
2915   stream.on = stream.addListener = Stream.prototype.on;
2916
2917   stream.on('readable', function() {
2918     readable = true;
2919
2920     var c;
2921     while (!paused && (null !== (c = stream.read())))
2922       stream.emit('data', c);
2923
2924     if (c === null) {
2925       readable = false;
2926       stream._readableState.needReadable = true;
2927     }
2928   });
2929
2930   stream.pause = function() {
2931     paused = true;
2932     this.emit('pause');
2933   };
2934
2935   stream.resume = function() {
2936     paused = false;
2937     if (readable)
2938       setImmediate(function() {
2939         stream.emit('readable');
2940       });
2941     else
2942       this.read(0);
2943     this.emit('resume');
2944   };
2945
2946   // now make it start, just in case it hadn't already.
2947   stream.emit('readable');
2948 }
2949
2950 // wrap an old-style stream as the async data source.
2951 // This is *not* part of the readable stream interface.
2952 // It is an ugly unfortunate mess of history.
2953 Readable.prototype.wrap = function(stream) {
2954   var state = this._readableState;
2955   var paused = false;
2956
2957   var self = this;
2958   stream.on('end', function() {
2959     if (state.decoder && !state.ended) {
2960       var chunk = state.decoder.end();
2961       if (chunk && chunk.length)
2962         self.push(chunk);
2963     }
2964
2965     self.push(null);
2966   });
2967
2968   stream.on('data', function(chunk) {
2969     if (state.decoder)
2970       chunk = state.decoder.write(chunk);
2971     if (!chunk || !state.objectMode && !chunk.length)
2972       return;
2973
2974     var ret = self.push(chunk);
2975     if (!ret) {
2976       paused = true;
2977       stream.pause();
2978     }
2979   });
2980
2981   // proxy all the other methods.
2982   // important when wrapping filters and duplexes.
2983   for (var i in stream) {
2984     if (typeof stream[i] === 'function' &&
2985         typeof this[i] === 'undefined') {
2986       this[i] = function(method) { return function() {
2987         return stream[method].apply(stream, arguments);
2988       }}(i);
2989     }
2990   }
2991
2992   // proxy certain important events.
2993   var events = ['error', 'close', 'destroy', 'pause', 'resume'];
2994   forEach(events, function(ev) {
2995     stream.on(ev, function (x) {
2996       return self.emit.apply(self, ev, x);
2997     });
2998   });
2999
3000   // when we try to consume some more bytes, simply unpause the
3001   // underlying stream.
3002   self._read = function(n) {
3003     if (paused) {
3004       paused = false;
3005       stream.resume();
3006     }
3007   };
3008
3009   return self;
3010 };
3011
3012
3013
3014 // exposed for testing purposes only.
3015 Readable._fromList = fromList;
3016
3017 // Pluck off n bytes from an array of buffers.
3018 // Length is the combined lengths of all the buffers in the list.
3019 function fromList(n, state) {
3020   var list = state.buffer;
3021   var length = state.length;
3022   var stringMode = !!state.decoder;
3023   var objectMode = !!state.objectMode;
3024   var ret;
3025
3026   // nothing in the list, definitely empty.
3027   if (list.length === 0)
3028     return null;
3029
3030   if (length === 0)
3031     ret = null;
3032   else if (objectMode)
3033     ret = list.shift();
3034   else if (!n || n >= length) {
3035     // read it all, truncate the array.
3036     if (stringMode)
3037       ret = list.join('');
3038     else
3039       ret = Buffer.concat(list, length);
3040     list.length = 0;
3041   } else {
3042     // read just some of it.
3043     if (n < list[0].length) {
3044       // just take a part of the first list item.
3045       // slice is the same for buffers and strings.
3046       var buf = list[0];
3047       ret = buf.slice(0, n);
3048       list[0] = buf.slice(n);
3049     } else if (n === list[0].length) {
3050       // first list is a perfect match
3051       ret = list.shift();
3052     } else {
3053       // complex case.
3054       // we have enough to cover it, but it spans past the first buffer.
3055       if (stringMode)
3056         ret = '';
3057       else
3058         ret = new Buffer(n);
3059
3060       var c = 0;
3061       for (var i = 0, l = list.length; i < l && c < n; i++) {
3062         var buf = list[0];
3063         var cpy = Math.min(n - c, buf.length);
3064
3065         if (stringMode)
3066           ret += buf.slice(0, cpy);
3067         else
3068           buf.copy(ret, c, 0, cpy);
3069
3070         if (cpy < buf.length)
3071           list[0] = buf.slice(cpy);
3072         else
3073           list.shift();
3074
3075         c += cpy;
3076       }
3077     }
3078   }
3079
3080   return ret;
3081 }
3082
3083 function endReadable(stream) {
3084   var state = stream._readableState;
3085
3086   // If we get here before consuming all the bytes, then that is a
3087   // bug in node.  Should never happen.
3088   if (state.length > 0)
3089     throw new Error('endReadable called on non-empty stream');
3090
3091   if (!state.endEmitted && state.calledRead) {
3092     state.ended = true;
3093     setImmediate(function() {
3094       // Check that we didn't get one last unshift.
3095       if (!state.endEmitted && state.length === 0) {
3096         state.endEmitted = true;
3097         stream.readable = false;
3098         stream.emit('end');
3099       }
3100     });
3101   }
3102 }
3103
3104 function forEach (xs, f) {
3105   for (var i = 0, l = xs.length; i < l; i++) {
3106     f(xs[i], i);
3107   }
3108 }
3109
3110 function indexOf (xs, x) {
3111   for (var i = 0, l = xs.length; i < l; i++) {
3112     if (xs[i] === x) return i;
3113   }
3114   return -1;
3115 }
3116
3117 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
3118 },{"./index.js":9,"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"buffer":1,"events":4,"inherits":5,"process/browser.js":10,"string_decoder":15}],13:[function(require,module,exports){
3119 // Copyright Joyent, Inc. and other Node contributors.
3120 //
3121 // Permission is hereby granted, free of charge, to any person obtaining a
3122 // copy of this software and associated documentation files (the
3123 // "Software"), to deal in the Software without restriction, including
3124 // without limitation the rights to use, copy, modify, merge, publish,
3125 // distribute, sublicense, and/or sell copies of the Software, and to permit
3126 // persons to whom the Software is furnished to do so, subject to the
3127 // following conditions:
3128 //
3129 // The above copyright notice and this permission notice shall be included
3130 // in all copies or substantial portions of the Software.
3131 //
3132 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3133 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3134 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3135 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3136 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3137 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3138 // USE OR OTHER DEALINGS IN THE SOFTWARE.
3139
3140 // a transform stream is a readable/writable stream where you do
3141 // something with the data.  Sometimes it's called a "filter",
3142 // but that's not a great name for it, since that implies a thing where
3143 // some bits pass through, and others are simply ignored.  (That would
3144 // be a valid example of a transform, of course.)
3145 //
3146 // While the output is causally related to the input, it's not a
3147 // necessarily symmetric or synchronous transformation.  For example,
3148 // a zlib stream might take multiple plain-text writes(), and then
3149 // emit a single compressed chunk some time in the future.
3150 //
3151 // Here's how this works:
3152 //
3153 // The Transform stream has all the aspects of the readable and writable
3154 // stream classes.  When you write(chunk), that calls _write(chunk,cb)
3155 // internally, and returns false if there's a lot of pending writes
3156 // buffered up.  When you call read(), that calls _read(n) until
3157 // there's enough pending readable data buffered up.
3158 //
3159 // In a transform stream, the written data is placed in a buffer.  When
3160 // _read(n) is called, it transforms the queued up data, calling the
3161 // buffered _write cb's as it consumes chunks.  If consuming a single
3162 // written chunk would result in multiple output chunks, then the first
3163 // outputted bit calls the readcb, and subsequent chunks just go into
3164 // the read buffer, and will cause it to emit 'readable' if necessary.
3165 //
3166 // This way, back-pressure is actually determined by the reading side,
3167 // since _read has to be called to start processing a new chunk.  However,
3168 // a pathological inflate type of transform can cause excessive buffering
3169 // here.  For example, imagine a stream where every byte of input is
3170 // interpreted as an integer from 0-255, and then results in that many
3171 // bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
3172 // 1kb of data being output.  In this case, you could write a very small
3173 // amount of input, and end up with a very large amount of output.  In
3174 // such a pathological inflating mechanism, there'd be no way to tell
3175 // the system to stop doing the transform.  A single 4MB write could
3176 // cause the system to run out of memory.
3177 //
3178 // However, even in such a pathological case, only a single written chunk
3179 // would be consumed, and then the rest would wait (un-transformed) until
3180 // the results of the previous transformed chunk were consumed.
3181
3182 module.exports = Transform;
3183
3184 var Duplex = require('./duplex.js');
3185 var inherits = require('inherits');
3186 inherits(Transform, Duplex);
3187
3188
3189 function TransformState(options, stream) {
3190   this.afterTransform = function(er, data) {
3191     return afterTransform(stream, er, data);
3192   };
3193
3194   this.needTransform = false;
3195   this.transforming = false;
3196   this.writecb = null;
3197   this.writechunk = null;
3198 }
3199
3200 function afterTransform(stream, er, data) {
3201   var ts = stream._transformState;
3202   ts.transforming = false;
3203
3204   var cb = ts.writecb;
3205
3206   if (!cb)
3207     return stream.emit('error', new Error('no writecb in Transform class'));
3208
3209   ts.writechunk = null;
3210   ts.writecb = null;
3211
3212   if (data !== null && data !== undefined)
3213     stream.push(data);
3214
3215   if (cb)
3216     cb(er);
3217
3218   var rs = stream._readableState;
3219   rs.reading = false;
3220   if (rs.needReadable || rs.length < rs.highWaterMark) {
3221     stream._read(rs.highWaterMark);
3222   }
3223 }
3224
3225
3226 function Transform(options) {
3227   if (!(this instanceof Transform))
3228     return new Transform(options);
3229
3230   Duplex.call(this, options);
3231
3232   var ts = this._transformState = new TransformState(options, this);
3233
3234   // when the writable side finishes, then flush out anything remaining.
3235   var stream = this;
3236
3237   // start out asking for a readable event once data is transformed.
3238   this._readableState.needReadable = true;
3239
3240   // we have implemented the _read method, and done the other things
3241   // that Readable wants before the first _read call, so unset the
3242   // sync guard flag.
3243   this._readableState.sync = false;
3244
3245   this.once('finish', function() {
3246     if ('function' === typeof this._flush)
3247       this._flush(function(er) {
3248         done(stream, er);
3249       });
3250     else
3251       done(stream);
3252   });
3253 }
3254
3255 Transform.prototype.push = function(chunk, encoding) {
3256   this._transformState.needTransform = false;
3257   return Duplex.prototype.push.call(this, chunk, encoding);
3258 };
3259
3260 // This is the part where you do stuff!
3261 // override this function in implementation classes.
3262 // 'chunk' is an input chunk.
3263 //
3264 // Call `push(newChunk)` to pass along transformed output
3265 // to the readable side.  You may call 'push' zero or more times.
3266 //
3267 // Call `cb(err)` when you are done with this chunk.  If you pass
3268 // an error, then that'll put the hurt on the whole operation.  If you
3269 // never call cb(), then you'll never get another chunk.
3270 Transform.prototype._transform = function(chunk, encoding, cb) {
3271   throw new Error('not implemented');
3272 };
3273
3274 Transform.prototype._write = function(chunk, encoding, cb) {
3275   var ts = this._transformState;
3276   ts.writecb = cb;
3277   ts.writechunk = chunk;
3278   ts.writeencoding = encoding;
3279   if (!ts.transforming) {
3280     var rs = this._readableState;
3281     if (ts.needTransform ||
3282         rs.needReadable ||
3283         rs.length < rs.highWaterMark)
3284       this._read(rs.highWaterMark);
3285   }
3286 };
3287
3288 // Doesn't matter what the args are here.
3289 // _transform does all the work.
3290 // That we got here means that the readable side wants more data.
3291 Transform.prototype._read = function(n) {
3292   var ts = this._transformState;
3293
3294   if (ts.writechunk && ts.writecb && !ts.transforming) {
3295     ts.transforming = true;
3296     this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
3297   } else {
3298     // mark that we need a transform, so that any data that comes in
3299     // will get processed, now that we've asked for it.
3300     ts.needTransform = true;
3301   }
3302 };
3303
3304
3305 function done(stream, er) {
3306   if (er)
3307     return stream.emit('error', er);
3308
3309   // if there's nothing in the write buffer, then that means
3310   // that nothing more will ever be provided
3311   var ws = stream._writableState;
3312   var rs = stream._readableState;
3313   var ts = stream._transformState;
3314
3315   if (ws.length)
3316     throw new Error('calling transform done when ws.length != 0');
3317
3318   if (ts.transforming)
3319     throw new Error('calling transform done when still transforming');
3320
3321   return stream.push(null);
3322 }
3323
3324 },{"./duplex.js":8,"inherits":5}],14:[function(require,module,exports){
3325 // Copyright Joyent, Inc. and other Node contributors.
3326 //
3327 // Permission is hereby granted, free of charge, to any person obtaining a
3328 // copy of this software and associated documentation files (the
3329 // "Software"), to deal in the Software without restriction, including
3330 // without limitation the rights to use, copy, modify, merge, publish,
3331 // distribute, sublicense, and/or sell copies of the Software, and to permit
3332 // persons to whom the Software is furnished to do so, subject to the
3333 // following conditions:
3334 //
3335 // The above copyright notice and this permission notice shall be included
3336 // in all copies or substantial portions of the Software.
3337 //
3338 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3339 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3340 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3341 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3342 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3343 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3344 // USE OR OTHER DEALINGS IN THE SOFTWARE.
3345
3346 // A bit simpler than readable streams.
3347 // Implement an async ._write(chunk, cb), and it'll handle all
3348 // the drain event emission and buffering.
3349
3350 module.exports = Writable;
3351 Writable.WritableState = WritableState;
3352
3353 var isUint8Array = typeof Uint8Array !== 'undefined'
3354   ? function (x) { return x instanceof Uint8Array }
3355   : function (x) {
3356     return x && x.constructor && x.constructor.name === 'Uint8Array'
3357   }
3358 ;
3359 var isArrayBuffer = typeof ArrayBuffer !== 'undefined'
3360   ? function (x) { return x instanceof ArrayBuffer }
3361   : function (x) {
3362     return x && x.constructor && x.constructor.name === 'ArrayBuffer'
3363   }
3364 ;
3365
3366 var inherits = require('inherits');
3367 var Stream = require('./index.js');
3368 var setImmediate = require('process/browser.js').nextTick;
3369 var Buffer = require('buffer').Buffer;
3370
3371 inherits(Writable, Stream);
3372
3373 function WriteReq(chunk, encoding, cb) {
3374   this.chunk = chunk;
3375   this.encoding = encoding;
3376   this.callback = cb;
3377 }
3378
3379 function WritableState(options, stream) {
3380   options = options || {};
3381
3382   // the point at which write() starts returning false
3383   // Note: 0 is a valid value, means that we always return false if
3384   // the entire buffer is not flushed immediately on write()
3385   var hwm = options.highWaterMark;
3386   this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
3387
3388   // object stream flag to indicate whether or not this stream
3389   // contains buffers or objects.
3390   this.objectMode = !!options.objectMode;
3391
3392   // cast to ints.
3393   this.highWaterMark = ~~this.highWaterMark;
3394
3395   this.needDrain = false;
3396   // at the start of calling end()
3397   this.ending = false;
3398   // when end() has been called, and returned
3399   this.ended = false;
3400   // when 'finish' is emitted
3401   this.finished = false;
3402
3403   // should we decode strings into buffers before passing to _write?
3404   // this is here so that some node-core streams can optimize string
3405   // handling at a lower level.
3406   var noDecode = options.decodeStrings === false;
3407   this.decodeStrings = !noDecode;
3408
3409   // Crypto is kind of old and crusty.  Historically, its default string
3410   // encoding is 'binary' so we have to make this configurable.
3411   // Everything else in the universe uses 'utf8', though.
3412   this.defaultEncoding = options.defaultEncoding || 'utf8';
3413
3414   // not an actual buffer we keep track of, but a measurement
3415   // of how much we're waiting to get pushed to some underlying
3416   // socket or file.
3417   this.length = 0;
3418
3419   // a flag to see when we're in the middle of a write.
3420   this.writing = false;
3421
3422   // a flag to be able to tell if the onwrite cb is called immediately,
3423   // or on a later tick.  We set this to true at first, becuase any
3424   // actions that shouldn't happen until "later" should generally also
3425   // not happen before the first write call.
3426   this.sync = true;
3427
3428   // a flag to know if we're processing previously buffered items, which
3429   // may call the _write() callback in the same tick, so that we don't
3430   // end up in an overlapped onwrite situation.
3431   this.bufferProcessing = false;
3432
3433   // the callback that's passed to _write(chunk,cb)
3434   this.onwrite = function(er) {
3435     onwrite(stream, er);
3436   };
3437
3438   // the callback that the user supplies to write(chunk,encoding,cb)
3439   this.writecb = null;
3440
3441   // the amount that is being written when _write is called.
3442   this.writelen = 0;
3443
3444   this.buffer = [];
3445 }
3446
3447 function Writable(options) {
3448   // Writable ctor is applied to Duplexes, though they're not
3449   // instanceof Writable, they're instanceof Readable.
3450   if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
3451     return new Writable(options);
3452
3453   this._writableState = new WritableState(options, this);
3454
3455   // legacy.
3456   this.writable = true;
3457
3458   Stream.call(this);
3459 }
3460
3461 // Otherwise people can pipe Writable streams, which is just wrong.
3462 Writable.prototype.pipe = function() {
3463   this.emit('error', new Error('Cannot pipe. Not readable.'));
3464 };
3465
3466
3467 function writeAfterEnd(stream, state, cb) {
3468   var er = new Error('write after end');
3469   // TODO: defer error events consistently everywhere, not just the cb
3470   stream.emit('error', er);
3471   setImmediate(function() {
3472     cb(er);
3473   });
3474 }
3475
3476 // If we get something that is not a buffer, string, null, or undefined,
3477 // and we're not in objectMode, then that's an error.
3478 // Otherwise stream chunks are all considered to be of length=1, and the
3479 // watermarks determine how many objects to keep in the buffer, rather than
3480 // how many bytes or characters.
3481 function validChunk(stream, state, chunk, cb) {
3482   var valid = true;
3483   if (!Buffer.isBuffer(chunk) &&
3484       'string' !== typeof chunk &&
3485       chunk !== null &&
3486       chunk !== undefined &&
3487       !state.objectMode) {
3488     var er = new TypeError('Invalid non-string/buffer chunk');
3489     stream.emit('error', er);
3490     setImmediate(function() {
3491       cb(er);
3492     });
3493     valid = false;
3494   }
3495   return valid;
3496 }
3497
3498 Writable.prototype.write = function(chunk, encoding, cb) {
3499   var state = this._writableState;
3500   var ret = false;
3501
3502   if (typeof encoding === 'function') {
3503     cb = encoding;
3504     encoding = null;
3505   }
3506
3507   if (!Buffer.isBuffer(chunk) && isUint8Array(chunk))
3508     chunk = new Buffer(chunk);
3509   if (isArrayBuffer(chunk) && typeof Uint8Array !== 'undefined')
3510     chunk = new Buffer(new Uint8Array(chunk));
3511   
3512   if (Buffer.isBuffer(chunk))
3513     encoding = 'buffer';
3514   else if (!encoding)
3515     encoding = state.defaultEncoding;
3516
3517   if (typeof cb !== 'function')
3518     cb = function() {};
3519
3520   if (state.ended)
3521     writeAfterEnd(this, state, cb);
3522   else if (validChunk(this, state, chunk, cb))
3523     ret = writeOrBuffer(this, state, chunk, encoding, cb);
3524
3525   return ret;
3526 };
3527
3528 function decodeChunk(state, chunk, encoding) {
3529   if (!state.objectMode &&
3530       state.decodeStrings !== false &&
3531       typeof chunk === 'string') {
3532     chunk = new Buffer(chunk, encoding);
3533   }
3534   return chunk;
3535 }
3536
3537 // if we're already writing something, then just put this
3538 // in the queue, and wait our turn.  Otherwise, call _write
3539 // If we return false, then we need a drain event, so set that flag.
3540 function writeOrBuffer(stream, state, chunk, encoding, cb) {
3541   chunk = decodeChunk(state, chunk, encoding);
3542   var len = state.objectMode ? 1 : chunk.length;
3543
3544   state.length += len;
3545
3546   var ret = state.length < state.highWaterMark;
3547   state.needDrain = !ret;
3548
3549   if (state.writing)
3550     state.buffer.push(new WriteReq(chunk, encoding, cb));
3551   else
3552     doWrite(stream, state, len, chunk, encoding, cb);
3553
3554   return ret;
3555 }
3556
3557 function doWrite(stream, state, len, chunk, encoding, cb) {
3558   state.writelen = len;
3559   state.writecb = cb;
3560   state.writing = true;
3561   state.sync = true;
3562   stream._write(chunk, encoding, state.onwrite);
3563   state.sync = false;
3564 }
3565
3566 function onwriteError(stream, state, sync, er, cb) {
3567   if (sync)
3568     setImmediate(function() {
3569       cb(er);
3570     });
3571   else
3572     cb(er);
3573
3574   stream.emit('error', er);
3575 }
3576
3577 function onwriteStateUpdate(state) {
3578   state.writing = false;
3579   state.writecb = null;
3580   state.length -= state.writelen;
3581   state.writelen = 0;
3582 }
3583
3584 function onwrite(stream, er) {
3585   var state = stream._writableState;
3586   var sync = state.sync;
3587   var cb = state.writecb;
3588
3589   onwriteStateUpdate(state);
3590
3591   if (er)
3592     onwriteError(stream, state, sync, er, cb);
3593   else {
3594     // Check if we're actually ready to finish, but don't emit yet
3595     var finished = needFinish(stream, state);
3596
3597     if (!finished && !state.bufferProcessing && state.buffer.length)
3598       clearBuffer(stream, state);
3599
3600     if (sync) {
3601       setImmediate(function() {
3602         afterWrite(stream, state, finished, cb);
3603       });
3604     } else {
3605       afterWrite(stream, state, finished, cb);
3606     }
3607   }
3608 }
3609
3610 function afterWrite(stream, state, finished, cb) {
3611   if (!finished)
3612     onwriteDrain(stream, state);
3613   cb();
3614   if (finished)
3615     finishMaybe(stream, state);
3616 }
3617
3618 // Must force callback to be called on nextTick, so that we don't
3619 // emit 'drain' before the write() consumer gets the 'false' return
3620 // value, and has a chance to attach a 'drain' listener.
3621 function onwriteDrain(stream, state) {
3622   if (state.length === 0 && state.needDrain) {
3623     state.needDrain = false;
3624     stream.emit('drain');
3625   }
3626 }
3627
3628
3629 // if there's something in the buffer waiting, then process it
3630 function clearBuffer(stream, state) {
3631   state.bufferProcessing = true;
3632
3633   for (var c = 0; c < state.buffer.length; c++) {
3634     var entry = state.buffer[c];
3635     var chunk = entry.chunk;
3636     var encoding = entry.encoding;
3637     var cb = entry.callback;
3638     var len = state.objectMode ? 1 : chunk.length;
3639
3640     doWrite(stream, state, len, chunk, encoding, cb);
3641
3642     // if we didn't call the onwrite immediately, then
3643     // it means that we need to wait until it does.
3644     // also, that means that the chunk and cb are currently
3645     // being processed, so move the buffer counter past them.
3646     if (state.writing) {
3647       c++;
3648       break;
3649     }
3650   }
3651
3652   state.bufferProcessing = false;
3653   if (c < state.buffer.length)
3654     state.buffer = state.buffer.slice(c);
3655   else
3656     state.buffer.length = 0;
3657 }
3658
3659 Writable.prototype._write = function(chunk, encoding, cb) {
3660   cb(new Error('not implemented'));
3661 };
3662
3663 Writable.prototype.end = function(chunk, encoding, cb) {
3664   var state = this._writableState;
3665
3666   if (typeof chunk === 'function') {
3667     cb = chunk;
3668     chunk = null;
3669     encoding = null;
3670   } else if (typeof encoding === 'function') {
3671     cb = encoding;
3672     encoding = null;
3673   }
3674
3675   if (typeof chunk !== 'undefined' && chunk !== null)
3676     this.write(chunk, encoding);
3677
3678   // ignore unnecessary end() calls.
3679   if (!state.ending && !state.finished)
3680     endWritable(this, state, cb);
3681 };
3682
3683
3684 function needFinish(stream, state) {
3685   return (state.ending &&
3686           state.length === 0 &&
3687           !state.finished &&
3688           !state.writing);
3689 }
3690
3691 function finishMaybe(stream, state) {
3692   var need = needFinish(stream, state);
3693   if (need) {
3694     state.finished = true;
3695     stream.emit('finish');
3696   }
3697   return need;
3698 }
3699
3700 function endWritable(stream, state, cb) {
3701   state.ending = true;
3702   finishMaybe(stream, state);
3703   if (cb) {
3704     if (state.finished)
3705       setImmediate(cb);
3706     else
3707       stream.once('finish', cb);
3708   }
3709   state.ended = true;
3710 }
3711
3712 },{"./index.js":9,"buffer":1,"inherits":5,"process/browser.js":10}],15:[function(require,module,exports){
3713 // Copyright Joyent, Inc. and other Node contributors.
3714 //
3715 // Permission is hereby granted, free of charge, to any person obtaining a
3716 // copy of this software and associated documentation files (the
3717 // "Software"), to deal in the Software without restriction, including
3718 // without limitation the rights to use, copy, modify, merge, publish,
3719 // distribute, sublicense, and/or sell copies of the Software, and to permit
3720 // persons to whom the Software is furnished to do so, subject to the
3721 // following conditions:
3722 //
3723 // The above copyright notice and this permission notice shall be included
3724 // in all copies or substantial portions of the Software.
3725 //
3726 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3727 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3728 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3729 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3730 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3731 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3732 // USE OR OTHER DEALINGS IN THE SOFTWARE.
3733
3734 var Buffer = require('buffer').Buffer;
3735
3736 function assertEncoding(encoding) {
3737   if (encoding && !Buffer.isEncoding(encoding)) {
3738     throw new Error('Unknown encoding: ' + encoding);
3739   }
3740 }
3741
3742 var StringDecoder = exports.StringDecoder = function(encoding) {
3743   this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
3744   assertEncoding(encoding);
3745   switch (this.encoding) {
3746     case 'utf8':
3747       // CESU-8 represents each of Surrogate Pair by 3-bytes
3748       this.surrogateSize = 3;
3749       break;
3750     case 'ucs2':
3751     case 'utf16le':
3752       // UTF-16 represents each of Surrogate Pair by 2-bytes
3753       this.surrogateSize = 2;
3754       this.detectIncompleteChar = utf16DetectIncompleteChar;
3755       break;
3756     case 'base64':
3757       // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
3758       this.surrogateSize = 3;
3759       this.detectIncompleteChar = base64DetectIncompleteChar;
3760       break;
3761     default:
3762       this.write = passThroughWrite;
3763       return;
3764   }
3765
3766   this.charBuffer = new Buffer(6);
3767   this.charReceived = 0;
3768   this.charLength = 0;
3769 };
3770
3771
3772 StringDecoder.prototype.write = function(buffer) {
3773   var charStr = '';
3774   var offset = 0;
3775
3776   // if our last write ended with an incomplete multibyte character
3777   while (this.charLength) {
3778     // determine how many remaining bytes this buffer has to offer for this char
3779     var i = (buffer.length >= this.charLength - this.charReceived) ?
3780                 this.charLength - this.charReceived :
3781                 buffer.length;
3782
3783     // add the new bytes to the char buffer
3784     buffer.copy(this.charBuffer, this.charReceived, offset, i);
3785     this.charReceived += (i - offset);
3786     offset = i;
3787
3788     if (this.charReceived < this.charLength) {
3789       // still not enough chars in this buffer? wait for more ...
3790       return '';
3791     }
3792
3793     // get the character that was split
3794     charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
3795
3796     // lead surrogate (D800-DBFF) is also the incomplete character
3797     var charCode = charStr.charCodeAt(charStr.length - 1);
3798     if (charCode >= 0xD800 && charCode <= 0xDBFF) {
3799       this.charLength += this.surrogateSize;
3800       charStr = '';
3801       continue;
3802     }
3803     this.charReceived = this.charLength = 0;
3804
3805     // if there are no more bytes in this buffer, just emit our char
3806     if (i == buffer.length) return charStr;
3807
3808     // otherwise cut off the characters end from the beginning of this buffer
3809     buffer = buffer.slice(i, buffer.length);
3810     break;
3811   }
3812
3813   var lenIncomplete = this.detectIncompleteChar(buffer);
3814
3815   var end = buffer.length;
3816   if (this.charLength) {
3817     // buffer the incomplete character bytes we got
3818     buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);
3819     this.charReceived = lenIncomplete;
3820     end -= lenIncomplete;
3821   }
3822
3823   charStr += buffer.toString(this.encoding, 0, end);
3824
3825   var end = charStr.length - 1;
3826   var charCode = charStr.charCodeAt(end);
3827   // lead surrogate (D800-DBFF) is also the incomplete character
3828   if (charCode >= 0xD800 && charCode <= 0xDBFF) {
3829     var size = this.surrogateSize;
3830     this.charLength += size;
3831     this.charReceived += size;
3832     this.charBuffer.copy(this.charBuffer, size, 0, size);
3833     this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);
3834     return charStr.substring(0, end);
3835   }
3836
3837   // or just emit the charStr
3838   return charStr;
3839 };
3840
3841 StringDecoder.prototype.detectIncompleteChar = function(buffer) {
3842   // determine how many bytes we have to check at the end of this buffer
3843   var i = (buffer.length >= 3) ? 3 : buffer.length;
3844
3845   // Figure out if one of the last i bytes of our buffer announces an
3846   // incomplete char.
3847   for (; i > 0; i--) {
3848     var c = buffer[buffer.length - i];
3849
3850     // See http://en.wikipedia.org/wiki/UTF-8#Description
3851
3852     // 110XXXXX
3853     if (i == 1 && c >> 5 == 0x06) {
3854       this.charLength = 2;
3855       break;
3856     }
3857
3858     // 1110XXXX
3859     if (i <= 2 && c >> 4 == 0x0E) {
3860       this.charLength = 3;
3861       break;
3862     }
3863
3864     // 11110XXX
3865     if (i <= 3 && c >> 3 == 0x1E) {
3866       this.charLength = 4;
3867       break;
3868     }
3869   }
3870
3871   return i;
3872 };
3873
3874 StringDecoder.prototype.end = function(buffer) {
3875   var res = '';
3876   if (buffer && buffer.length)
3877     res = this.write(buffer);
3878
3879   if (this.charReceived) {
3880     var cr = this.charReceived;
3881     var buf = this.charBuffer;
3882     var enc = this.encoding;
3883     res += buf.slice(0, cr).toString(enc);
3884   }
3885
3886   return res;
3887 };
3888
3889 function passThroughWrite(buffer) {
3890   return buffer.toString(this.encoding);
3891 }
3892
3893 function utf16DetectIncompleteChar(buffer) {
3894   var incomplete = this.charReceived = buffer.length % 2;
3895   this.charLength = incomplete ? 2 : 0;
3896   return incomplete;
3897 }
3898
3899 function base64DetectIncompleteChar(buffer) {
3900   var incomplete = this.charReceived = buffer.length % 3;
3901   this.charLength = incomplete ? 3 : 0;
3902   return incomplete;
3903 }
3904
3905 },{"buffer":1}],16:[function(require,module,exports){
3906 module.exports = function isBuffer(arg) {
3907   return arg && typeof arg === 'object'
3908     && typeof arg.copy === 'function'
3909     && typeof arg.fill === 'function'
3910     && typeof arg.readUInt8 === 'function';
3911 }
3912 },{}],17:[function(require,module,exports){
3913 (function (process,global){
3914 // Copyright Joyent, Inc. and other Node contributors.
3915 //
3916 // Permission is hereby granted, free of charge, to any person obtaining a
3917 // copy of this software and associated documentation files (the
3918 // "Software"), to deal in the Software without restriction, including
3919 // without limitation the rights to use, copy, modify, merge, publish,
3920 // distribute, sublicense, and/or sell copies of the Software, and to permit
3921 // persons to whom the Software is furnished to do so, subject to the
3922 // following conditions:
3923 //
3924 // The above copyright notice and this permission notice shall be included
3925 // in all copies or substantial portions of the Software.
3926 //
3927 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3928 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3929 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3930 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3931 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3932 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3933 // USE OR OTHER DEALINGS IN THE SOFTWARE.
3934
3935 var formatRegExp = /%[sdj%]/g;
3936 exports.format = function(f) {
3937   if (!isString(f)) {
3938     var objects = [];
3939     for (var i = 0; i < arguments.length; i++) {
3940       objects.push(inspect(arguments[i]));
3941     }
3942     return objects.join(' ');
3943   }
3944
3945   var i = 1;
3946   var args = arguments;
3947   var len = args.length;
3948   var str = String(f).replace(formatRegExp, function(x) {
3949     if (x === '%%') return '%';
3950     if (i >= len) return x;
3951     switch (x) {
3952       case '%s': return String(args[i++]);
3953       case '%d': return Number(args[i++]);
3954       case '%j':
3955         try {
3956           return JSON.stringify(args[i++]);
3957         } catch (_) {
3958           return '[Circular]';
3959         }
3960       default:
3961         return x;
3962     }
3963   });
3964   for (var x = args[i]; i < len; x = args[++i]) {
3965     if (isNull(x) || !isObject(x)) {
3966       str += ' ' + x;
3967     } else {
3968       str += ' ' + inspect(x);
3969     }
3970   }
3971   return str;
3972 };
3973
3974
3975 // Mark that a method should not be used.
3976 // Returns a modified function which warns once by default.
3977 // If --no-deprecation is set, then it is a no-op.
3978 exports.deprecate = function(fn, msg) {
3979   // Allow for deprecating things in the process of starting up.
3980   if (isUndefined(global.process)) {
3981     return function() {
3982       return exports.deprecate(fn, msg).apply(this, arguments);
3983     };
3984   }
3985
3986   if (process.noDeprecation === true) {
3987     return fn;
3988   }
3989
3990   var warned = false;
3991   function deprecated() {
3992     if (!warned) {
3993       if (process.throwDeprecation) {
3994         throw new Error(msg);
3995       } else if (process.traceDeprecation) {
3996         console.trace(msg);
3997       } else {
3998         console.error(msg);
3999       }
4000       warned = true;
4001     }
4002     return fn.apply(this, arguments);
4003   }
4004
4005   return deprecated;
4006 };
4007
4008
4009 var debugs = {};
4010 var debugEnviron;
4011 exports.debuglog = function(set) {
4012   if (isUndefined(debugEnviron))
4013     debugEnviron = process.env.NODE_DEBUG || '';
4014   set = set.toUpperCase();
4015   if (!debugs[set]) {
4016     if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
4017       var pid = process.pid;
4018       debugs[set] = function() {
4019         var msg = exports.format.apply(exports, arguments);
4020         console.error('%s %d: %s', set, pid, msg);
4021       };
4022     } else {
4023       debugs[set] = function() {};
4024     }
4025   }
4026   return debugs[set];
4027 };
4028
4029
4030 /**
4031  * Echos the value of a value. Trys to print the value out
4032  * in the best way possible given the different types.
4033  *
4034  * @param {Object} obj The object to print out.
4035  * @param {Object} opts Optional options object that alters the output.
4036  */
4037 /* legacy: obj, showHidden, depth, colors*/
4038 function inspect(obj, opts) {
4039   // default options
4040   var ctx = {
4041     seen: [],
4042     stylize: stylizeNoColor
4043   };
4044   // legacy...
4045   if (arguments.length >= 3) ctx.depth = arguments[2];
4046   if (arguments.length >= 4) ctx.colors = arguments[3];
4047   if (isBoolean(opts)) {
4048     // legacy...
4049     ctx.showHidden = opts;
4050   } else if (opts) {
4051     // got an "options" object
4052     exports._extend(ctx, opts);
4053   }
4054   // set default options
4055   if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
4056   if (isUndefined(ctx.depth)) ctx.depth = 2;
4057   if (isUndefined(ctx.colors)) ctx.colors = false;
4058   if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
4059   if (ctx.colors) ctx.stylize = stylizeWithColor;
4060   return formatValue(ctx, obj, ctx.depth);
4061 }
4062 exports.inspect = inspect;
4063
4064
4065 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
4066 inspect.colors = {
4067   'bold' : [1, 22],
4068   'italic' : [3, 23],
4069   'underline' : [4, 24],
4070   'inverse' : [7, 27],
4071   'white' : [37, 39],
4072   'grey' : [90, 39],
4073   'black' : [30, 39],
4074   'blue' : [34, 39],
4075   'cyan' : [36, 39],
4076   'green' : [32, 39],
4077   'magenta' : [35, 39],
4078   'red' : [31, 39],
4079   'yellow' : [33, 39]
4080 };
4081
4082 // Don't use 'blue' not visible on cmd.exe
4083 inspect.styles = {
4084   'special': 'cyan',
4085   'number': 'yellow',
4086   'boolean': 'yellow',
4087   'undefined': 'grey',
4088   'null': 'bold',
4089   'string': 'green',
4090   'date': 'magenta',
4091   // "name": intentionally not styling
4092   'regexp': 'red'
4093 };
4094
4095
4096 function stylizeWithColor(str, styleType) {
4097   var style = inspect.styles[styleType];
4098
4099   if (style) {
4100     return '\u001b[' + inspect.colors[style][0] + 'm' + str +
4101            '\u001b[' + inspect.colors[style][1] + 'm';
4102   } else {
4103     return str;
4104   }
4105 }
4106
4107
4108 function stylizeNoColor(str, styleType) {
4109   return str;
4110 }
4111
4112
4113 function arrayToHash(array) {
4114   var hash = {};
4115
4116   array.forEach(function(val, idx) {
4117     hash[val] = true;
4118   });
4119
4120   return hash;
4121 }
4122
4123
4124 function formatValue(ctx, value, recurseTimes) {
4125   // Provide a hook for user-specified inspect functions.
4126   // Check that value is an object with an inspect function on it
4127   if (ctx.customInspect &&
4128       value &&
4129       isFunction(value.inspect) &&
4130       // Filter out the util module, it's inspect function is special
4131       value.inspect !== exports.inspect &&
4132       // Also filter out any prototype objects using the circular check.
4133       !(value.constructor && value.constructor.prototype === value)) {
4134     var ret = value.inspect(recurseTimes, ctx);
4135     if (!isString(ret)) {
4136       ret = formatValue(ctx, ret, recurseTimes);
4137     }
4138     return ret;
4139   }
4140
4141   // Primitive types cannot have properties
4142   var primitive = formatPrimitive(ctx, value);
4143   if (primitive) {
4144     return primitive;
4145   }
4146
4147   // Look up the keys of the object.
4148   var keys = Object.keys(value);
4149   var visibleKeys = arrayToHash(keys);
4150
4151   if (ctx.showHidden) {
4152     keys = Object.getOwnPropertyNames(value);
4153   }
4154
4155   // IE doesn't make error fields non-enumerable
4156   // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
4157   if (isError(value)
4158       && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
4159     return formatError(value);
4160   }
4161
4162   // Some type of object without properties can be shortcutted.
4163   if (keys.length === 0) {
4164     if (isFunction(value)) {
4165       var name = value.name ? ': ' + value.name : '';
4166       return ctx.stylize('[Function' + name + ']', 'special');
4167     }
4168     if (isRegExp(value)) {
4169       return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
4170     }
4171     if (isDate(value)) {
4172       return ctx.stylize(Date.prototype.toString.call(value), 'date');
4173     }
4174     if (isError(value)) {
4175       return formatError(value);
4176     }
4177   }
4178
4179   var base = '', array = false, braces = ['{', '}'];
4180
4181   // Make Array say that they are Array
4182   if (isArray(value)) {
4183     array = true;
4184     braces = ['[', ']'];
4185   }
4186
4187   // Make functions say that they are functions
4188   if (isFunction(value)) {
4189     var n = value.name ? ': ' + value.name : '';
4190     base = ' [Function' + n + ']';
4191   }
4192
4193   // Make RegExps say that they are RegExps
4194   if (isRegExp(value)) {
4195     base = ' ' + RegExp.prototype.toString.call(value);
4196   }
4197
4198   // Make dates with properties first say the date
4199   if (isDate(value)) {
4200     base = ' ' + Date.prototype.toUTCString.call(value);
4201   }
4202
4203   // Make error with message first say the error
4204   if (isError(value)) {
4205     base = ' ' + formatError(value);
4206   }
4207
4208   if (keys.length === 0 && (!array || value.length == 0)) {
4209     return braces[0] + base + braces[1];
4210   }
4211
4212   if (recurseTimes < 0) {
4213     if (isRegExp(value)) {
4214       return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
4215     } else {
4216       return ctx.stylize('[Object]', 'special');
4217     }
4218   }
4219
4220   ctx.seen.push(value);
4221
4222   var output;
4223   if (array) {
4224     output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
4225   } else {
4226     output = keys.map(function(key) {
4227       return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
4228     });
4229   }
4230
4231   ctx.seen.pop();
4232
4233   return reduceToSingleString(output, base, braces);
4234 }
4235
4236
4237 function formatPrimitive(ctx, value) {
4238   if (isUndefined(value))
4239     return ctx.stylize('undefined', 'undefined');
4240   if (isString(value)) {
4241     var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
4242                                              .replace(/'/g, "\\'")
4243                                              .replace(/\\"/g, '"') + '\'';
4244     return ctx.stylize(simple, 'string');
4245   }
4246   if (isNumber(value))
4247     return ctx.stylize('' + value, 'number');
4248   if (isBoolean(value))
4249     return ctx.stylize('' + value, 'boolean');
4250   // For some reason typeof null is "object", so special case here.
4251   if (isNull(value))
4252     return ctx.stylize('null', 'null');
4253 }
4254
4255
4256 function formatError(value) {
4257   return '[' + Error.prototype.toString.call(value) + ']';
4258 }
4259
4260
4261 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
4262   var output = [];
4263   for (var i = 0, l = value.length; i < l; ++i) {
4264     if (hasOwnProperty(value, String(i))) {
4265       output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
4266           String(i), true));
4267     } else {
4268       output.push('');
4269     }
4270   }
4271   keys.forEach(function(key) {
4272     if (!key.match(/^\d+$/)) {
4273       output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
4274           key, true));
4275     }
4276   });
4277   return output;
4278 }
4279
4280
4281 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
4282   var name, str, desc;
4283   desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
4284   if (desc.get) {
4285     if (desc.set) {
4286       str = ctx.stylize('[Getter/Setter]', 'special');
4287     } else {
4288       str = ctx.stylize('[Getter]', 'special');
4289     }
4290   } else {
4291     if (desc.set) {
4292       str = ctx.stylize('[Setter]', 'special');
4293     }
4294   }
4295   if (!hasOwnProperty(visibleKeys, key)) {
4296     name = '[' + key + ']';
4297   }
4298   if (!str) {
4299     if (ctx.seen.indexOf(desc.value) < 0) {
4300       if (isNull(recurseTimes)) {
4301         str = formatValue(ctx, desc.value, null);
4302       } else {
4303         str = formatValue(ctx, desc.value, recurseTimes - 1);
4304       }
4305       if (str.indexOf('\n') > -1) {
4306         if (array) {
4307           str = str.split('\n').map(function(line) {
4308             return '  ' + line;
4309           }).join('\n').substr(2);
4310         } else {
4311           str = '\n' + str.split('\n').map(function(line) {
4312             return '   ' + line;
4313           }).join('\n');
4314         }
4315       }
4316     } else {
4317       str = ctx.stylize('[Circular]', 'special');
4318     }
4319   }
4320   if (isUndefined(name)) {
4321     if (array && key.match(/^\d+$/)) {
4322       return str;
4323     }
4324     name = JSON.stringify('' + key);
4325     if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
4326       name = name.substr(1, name.length - 2);
4327       name = ctx.stylize(name, 'name');
4328     } else {
4329       name = name.replace(/'/g, "\\'")
4330                  .replace(/\\"/g, '"')
4331                  .replace(/(^"|"$)/g, "'");
4332       name = ctx.stylize(name, 'string');
4333     }
4334   }
4335
4336   return name + ': ' + str;
4337 }
4338
4339
4340 function reduceToSingleString(output, base, braces) {
4341   var numLinesEst = 0;
4342   var length = output.reduce(function(prev, cur) {
4343     numLinesEst++;
4344     if (cur.indexOf('\n') >= 0) numLinesEst++;
4345     return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
4346   }, 0);
4347
4348   if (length > 60) {
4349     return braces[0] +
4350            (base === '' ? '' : base + '\n ') +
4351            ' ' +
4352            output.join(',\n  ') +
4353            ' ' +
4354            braces[1];
4355   }
4356
4357   return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
4358 }
4359
4360
4361 // NOTE: These type checking functions intentionally don't use `instanceof`
4362 // because it is fragile and can be easily faked with `Object.create()`.
4363 function isArray(ar) {
4364   return Array.isArray(ar);
4365 }
4366 exports.isArray = isArray;
4367
4368 function isBoolean(arg) {
4369   return typeof arg === 'boolean';
4370 }
4371 exports.isBoolean = isBoolean;
4372
4373 function isNull(arg) {
4374   return arg === null;
4375 }
4376 exports.isNull = isNull;
4377
4378 function isNullOrUndefined(arg) {
4379   return arg == null;
4380 }
4381 exports.isNullOrUndefined = isNullOrUndefined;
4382
4383 function isNumber(arg) {
4384   return typeof arg === 'number';
4385 }
4386 exports.isNumber = isNumber;
4387
4388 function isString(arg) {
4389   return typeof arg === 'string';
4390 }
4391 exports.isString = isString;
4392
4393 function isSymbol(arg) {
4394   return typeof arg === 'symbol';
4395 }
4396 exports.isSymbol = isSymbol;
4397
4398 function isUndefined(arg) {
4399   return arg === void 0;
4400 }
4401 exports.isUndefined = isUndefined;
4402
4403 function isRegExp(re) {
4404   return isObject(re) && objectToString(re) === '[object RegExp]';
4405 }
4406 exports.isRegExp = isRegExp;
4407
4408 function isObject(arg) {
4409   return typeof arg === 'object' && arg !== null;
4410 }
4411 exports.isObject = isObject;
4412
4413 function isDate(d) {
4414   return isObject(d) && objectToString(d) === '[object Date]';
4415 }
4416 exports.isDate = isDate;
4417
4418 function isError(e) {
4419   return isObject(e) &&
4420       (objectToString(e) === '[object Error]' || e instanceof Error);
4421 }
4422 exports.isError = isError;
4423
4424 function isFunction(arg) {
4425   return typeof arg === 'function';
4426 }
4427 exports.isFunction = isFunction;
4428
4429 function isPrimitive(arg) {
4430   return arg === null ||
4431          typeof arg === 'boolean' ||
4432          typeof arg === 'number' ||
4433          typeof arg === 'string' ||
4434          typeof arg === 'symbol' ||  // ES6 symbol
4435          typeof arg === 'undefined';
4436 }
4437 exports.isPrimitive = isPrimitive;
4438
4439 exports.isBuffer = require('./support/isBuffer');
4440
4441 function objectToString(o) {
4442   return Object.prototype.toString.call(o);
4443 }
4444
4445
4446 function pad(n) {
4447   return n < 10 ? '0' + n.toString(10) : n.toString(10);
4448 }
4449
4450
4451 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
4452               'Oct', 'Nov', 'Dec'];
4453
4454 // 26 Feb 16:19:34
4455 function timestamp() {
4456   var d = new Date();
4457   var time = [pad(d.getHours()),
4458               pad(d.getMinutes()),
4459               pad(d.getSeconds())].join(':');
4460   return [d.getDate(), months[d.getMonth()], time].join(' ');
4461 }
4462
4463
4464 // log is just a thin wrapper to console.log that prepends a timestamp
4465 exports.log = function() {
4466   console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
4467 };
4468
4469
4470 /**
4471  * Inherit the prototype methods from one constructor into another.
4472  *
4473  * The Function.prototype.inherits from lang.js rewritten as a standalone
4474  * function (not on Function.prototype). NOTE: If this file is to be loaded
4475  * during bootstrapping this function needs to be rewritten using some native
4476  * functions as prototype setup using normal JavaScript does not work as
4477  * expected during bootstrapping (see mirror.js in r114903).
4478  *
4479  * @param {function} ctor Constructor function which needs to inherit the
4480  *     prototype.
4481  * @param {function} superCtor Constructor function to inherit prototype from.
4482  */
4483 exports.inherits = require('inherits');
4484
4485 exports._extend = function(origin, add) {
4486   // Don't do anything if add isn't an object
4487   if (!add || !isObject(add)) return origin;
4488
4489   var keys = Object.keys(add);
4490   var i = keys.length;
4491   while (i--) {
4492     origin[keys[i]] = add[keys[i]];
4493   }
4494   return origin;
4495 };
4496
4497 function hasOwnProperty(obj, prop) {
4498   return Object.prototype.hasOwnProperty.call(obj, prop);
4499 }
4500
4501 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4502 },{"./support/isBuffer":16,"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"inherits":5}],18:[function(require,module,exports){
4503 module.exports = isFunction
4504
4505 var toString = Object.prototype.toString
4506
4507 function isFunction (fn) {
4508   var string = toString.call(fn)
4509   return string === '[object Function]' ||
4510     (typeof fn === 'function' && string !== '[object RegExp]') ||
4511     (typeof window !== 'undefined' &&
4512      // IE8 and below
4513      (fn === window.setTimeout ||
4514       fn === window.alert ||
4515       fn === window.confirm ||
4516       fn === window.prompt))
4517 };
4518
4519 },{}],19:[function(require,module,exports){
4520 (function (process){
4521 var defined = require('defined');
4522 var createDefaultStream = require('./lib/default_stream');
4523 var Test = require('./lib/test');
4524 var createResult = require('./lib/results');
4525
4526 var canEmitExit = typeof process !== 'undefined' && process
4527     && typeof process.on === 'function'
4528 ;
4529 var canExit = typeof process !== 'undefined' && process
4530     && typeof process.exit === 'function'
4531 ;
4532
4533 var nextTick = typeof setImmediate !== 'undefined'
4534     ? setImmediate
4535     : process.nextTick
4536 ;
4537
4538 exports = module.exports = (function () {
4539     var harness;
4540     var lazyLoad = function () {
4541         if (!harness) harness = createExitHarness({
4542             autoclose: !canEmitExit
4543         });
4544
4545         return harness.apply(this, arguments);
4546     };
4547
4548     lazyLoad.only = function () {
4549         if (!harness) harness = createExitHarness({
4550             autoclose: !canEmitExit
4551         });
4552
4553         return harness.only.apply(this, arguments);
4554     }
4555
4556     return lazyLoad
4557 })();
4558
4559 function createExitHarness (conf) {
4560     if (!conf) conf = {};
4561     var harness = createHarness({
4562         autoclose: defined(conf.autoclose, false)
4563     });
4564     
4565     var stream = harness.createStream();
4566     var es = stream.pipe(createDefaultStream());
4567     if (canEmitExit) {
4568         es.on('error', function (err) { harness._exitCode = 1 });
4569     }
4570     
4571     var ended = false;
4572     stream.on('end', function () { ended = true });
4573     
4574     if (conf.exit === false) return harness;
4575     if (!canEmitExit || !canExit) return harness;
4576     
4577     var _error;
4578
4579     process.on('uncaughtException', function (err) {
4580         if (err && err.code === 'EPIPE' && err.errno === 'EPIPE'
4581         && err.syscall === 'write') return;
4582         
4583         _error = err
4584         
4585         throw err
4586     })
4587
4588     process.on('exit', function (code) {
4589         if (_error) {
4590             return
4591         }
4592
4593         if (!ended) {
4594             for (var i = 0; i < harness._tests.length; i++) {
4595                 var t = harness._tests[i];
4596                 t._exit();
4597             }
4598         }
4599         harness.close();
4600         process.exit(code || harness._exitCode);
4601     });
4602     
4603     return harness;
4604 }
4605
4606 exports.createHarness = createHarness;
4607 exports.Test = Test;
4608 exports.test = exports; // tap compat
4609
4610 var exitInterval;
4611
4612 function createHarness (conf_) {
4613     if (!conf_) conf_ = {};
4614     var results = createResult();
4615     if (conf_.autoclose !== false) {
4616         results.once('done', function () { results.close() });
4617     }
4618     
4619     var test = function (name, conf, cb) {
4620         var t = new Test(name, conf, cb);
4621         test._tests.push(t);
4622         
4623         (function inspectCode (st) {
4624             st.on('test', function sub (st_) {
4625                 inspectCode(st_);
4626             });
4627             st.on('result', function (r) {
4628                 if (!r.ok) test._exitCode = 1
4629             });
4630         })(t);
4631         
4632         results.push(t);
4633         return t;
4634     };
4635     
4636     test._tests = [];
4637     
4638     test.createStream = function () {
4639         return results.createStream();
4640     };
4641     
4642     var only = false;
4643     test.only = function (name) {
4644         if (only) throw new Error('there can only be one only test');
4645         results.only(name);
4646         only = true;
4647         return test.apply(null, arguments);
4648     };
4649     test._exitCode = 0;
4650     
4651     test.close = function () { results.close() };
4652     
4653     return test;
4654 }
4655
4656 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
4657 },{"./lib/default_stream":20,"./lib/results":21,"./lib/test":22,"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"defined":26}],20:[function(require,module,exports){
4658 var through = require('through');
4659
4660 module.exports = function () {
4661     var line = '';
4662     var stream = through(write, flush);
4663     return stream;
4664     
4665     function write (buf) {
4666         for (var i = 0; i < buf.length; i++) {
4667             var c = typeof buf === 'string'
4668                 ? buf.charAt(i)
4669                 : String.fromCharCode(buf[i])
4670             ;
4671             if (c === '\n') flush();
4672             else line += c;
4673         }
4674     }
4675     
4676     function flush () {
4677         try { console.log(line); }
4678         catch (e) { stream.emit('error', e) }
4679         line = '';
4680     }
4681 };
4682
4683 },{"through":32}],21:[function(require,module,exports){
4684 (function (process){
4685 var Stream = require('stream');
4686 var EventEmitter = require('events').EventEmitter;
4687 var inherits = require('inherits');
4688 var json = typeof JSON === 'object' ? JSON : require('jsonify');
4689 var through = require('through');
4690 var resumer = require('resumer');
4691 var nextTick = typeof setImmediate !== 'undefined'
4692     ? setImmediate
4693     : process.nextTick
4694 ;
4695
4696 module.exports = Results;
4697 inherits(Results, EventEmitter);
4698
4699 function Results () {
4700     if (!(this instanceof Results)) return new Results;
4701     this.count = 0;
4702     this.fail = 0;
4703     this.pass = 0;
4704     this._stream = through();
4705     this.tests = [];
4706 }
4707
4708 Results.prototype.createStream = function () {
4709     var self = this;
4710     var output = resumer();
4711     output.queue('TAP version 13\n');
4712     
4713     nextTick(function () {
4714         var t = getNextTest(self);
4715         if (t) t.run()
4716         else self.emit('done')
4717     });
4718     self._stream.pipe(output);
4719     
4720     return output;
4721 };
4722
4723 Results.prototype.push = function (t) {
4724     var self = this;
4725     self.tests.push(t);
4726     self._watch(t);
4727     t.once('end', function () {
4728         var nt = getNextTest(self);
4729         if (nt) nt.run()
4730         else self.emit('done')
4731     });
4732 };
4733
4734 Results.prototype.only = function (name) {
4735     if (this._only) {
4736         self.count ++;
4737         self.fail ++;
4738         write('not ok ' + self.count + ' already called .only()\n');
4739     }
4740     this._only = name;
4741 };
4742
4743 Results.prototype._watch = function (t) {
4744     var self = this;
4745     var write = function (s) { self._stream.queue(s) };
4746     t.once('prerun', function () {
4747         write('# ' + t.name + '\n');
4748     });
4749
4750     t.on('result', function (res) {
4751         if (typeof res === 'string') {
4752             write('# ' + res + '\n');
4753             return;
4754         }
4755         write(encodeResult(res, self.count + 1));
4756         self.count ++;
4757         
4758         if (res.ok) self.pass ++
4759         else self.fail ++
4760     });
4761
4762     t.on('test', function (st) { self._watch(st) });
4763 };
4764
4765 Results.prototype.close = function () {
4766     var self = this;
4767     if (self.closed) self._stream.emit('error', new Error('ALREADY CLOSED'));
4768     self.closed = true;
4769     var write = function (s) { self._stream.queue(s) };
4770     
4771     write('\n1..' + self.count + '\n');
4772     write('# tests ' + self.count + '\n');
4773     write('# pass  ' + self.pass + '\n');
4774     if (self.fail) write('# fail  ' + self.fail + '\n')
4775     else write('\n# ok\n')
4776     
4777     self._stream.queue(null);
4778 };
4779
4780 function encodeResult (res, count) {
4781     var output = '';
4782     output += (res.ok ? 'ok ' : 'not ok ') + count;
4783     output += res.name ? ' ' + res.name.toString().replace(/\s+/g, ' ') : '';
4784     
4785     if (res.skip) output += ' # SKIP';
4786     else if (res.todo) output += ' # TODO';
4787     
4788     output += '\n';
4789     if (res.ok) return output;
4790     
4791     var outer = '  ';
4792     var inner = outer + '  ';
4793     output += outer + '---\n';
4794     output += inner + 'operator: ' + res.operator + '\n';
4795     
4796     var ex = json.stringify(res.expected, getSerialize()) || '';
4797     var ac = json.stringify(res.actual, getSerialize()) || '';
4798     
4799     if (Math.max(ex.length, ac.length) > 65) {
4800         output += inner + 'expected:\n' + inner + '  ' + ex + '\n';
4801         output += inner + 'actual:\n' + inner + '  ' + ac + '\n';
4802     }
4803     else {
4804         output += inner + 'expected: ' + ex + '\n';
4805         output += inner + 'actual:   ' + ac + '\n';
4806     }
4807     if (res.at) {
4808         output += inner + 'at: ' + res.at + '\n';
4809     }
4810     if (res.operator === 'error' && res.actual && res.actual.stack) {
4811         var lines = String(res.actual.stack).split('\n');
4812         output += inner + 'stack:\n';
4813         output += inner + '  ' + lines[0] + '\n';
4814         for (var i = 1; i < lines.length; i++) {
4815             output += inner + lines[i] + '\n';
4816         }
4817     }
4818     
4819     output += outer + '...\n';
4820     return output;
4821 }
4822
4823 function getSerialize () {
4824     var seen = [];
4825     
4826     return function (key, value) {
4827         var ret = value;
4828         if (typeof value === 'object' && value) {
4829             var found = false;
4830             for (var i = 0; i < seen.length; i++) {
4831                 if (seen[i] === value) {
4832                     found = true
4833                     break;
4834                 }
4835             }
4836             
4837             if (found) ret = '[Circular]'
4838             else seen.push(value)
4839         }
4840         return ret;
4841     };
4842 }
4843
4844 function getNextTest(results) {
4845     if (!results._only) {
4846         return results.tests.shift();
4847     }
4848
4849     do {
4850         var t = results.tests.shift();
4851         if (!t) {
4852             return null;
4853         }
4854         if (results._only === t.name) {
4855             return t;
4856         }
4857     } while (results.tests.length !== 0)
4858 }
4859
4860 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
4861 },{"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"events":4,"inherits":27,"jsonify":28,"resumer":31,"stream":9,"through":32}],22:[function(require,module,exports){
4862 (function (process,__dirname){
4863 var Stream = require('stream');
4864 var deepEqual = require('deep-equal');
4865 var defined = require('defined');
4866 var path = require('path');
4867 var inherits = require('util').inherits;
4868 var EventEmitter = require('events').EventEmitter;
4869
4870 module.exports = Test;
4871
4872 var nextTick = typeof setImmediate !== 'undefined'
4873     ? setImmediate
4874     : process.nextTick
4875 ;
4876
4877 inherits(Test, EventEmitter);
4878
4879 function Test (name_, opts_, cb_) {
4880     var self = this;
4881     var name = '(anonymous)';
4882     var opts = {};
4883     var cb;
4884     
4885     for (var i = 0; i < arguments.length; i++) {
4886         switch (typeof arguments[i]) {
4887             case 'string':
4888                 name = arguments[i];
4889                 break;
4890             case 'object':
4891                 opts = arguments[i] || opts;
4892                 break;
4893             case 'function':
4894                 cb = arguments[i];
4895         }
4896     }
4897     
4898     this.readable = true;
4899     this.name = name || '(anonymous)';
4900     this.assertCount = 0;
4901     this.pendingCount = 0;
4902     this._skip = opts.skip || false;
4903     this._plan = undefined;
4904     this._cb = cb;
4905     this._progeny = [];
4906     this._ok = true;
4907 }
4908
4909 Test.prototype.run = function () {
4910     if (this._skip) {
4911         return this.end();
4912     }
4913     this.emit('prerun');
4914     try {
4915         this._cb(this);
4916     }
4917     catch (err) {
4918         this.error(err);
4919         this.end();
4920         return;
4921     }
4922     this.emit('run');
4923 };
4924
4925 Test.prototype.test = function (name, opts, cb) {
4926     var self = this;
4927     var t = new Test(name, opts, cb);
4928     this._progeny.push(t);
4929     this.pendingCount++;
4930     this.emit('test', t);
4931     t.on('prerun', function () {
4932         self.assertCount++;
4933     })
4934
4935     if (!self._pendingAsserts()) {
4936         nextTick(function () {
4937             self.end();
4938         });
4939     }
4940
4941     nextTick(function() {
4942         if (!self._plan && self.pendingCount == self._progeny.length) {
4943             self.end();
4944         }
4945     });
4946 };
4947
4948 Test.prototype.comment = function (msg) {
4949     this.emit('result', msg.trim().replace(/^#\s*/, ''));
4950 };
4951
4952 Test.prototype.plan = function (n) {
4953     this._plan = n;
4954     this.emit('plan', n);
4955 };
4956
4957 Test.prototype.end = function () {
4958     var self = this;
4959
4960     if (this._progeny.length) {
4961         var t = this._progeny.shift();
4962         t.on('end', function () {
4963             self.end();
4964         });
4965         t.run();
4966         return;
4967     }
4968     
4969     if (!this.ended) this.emit('end');
4970     var pendingAsserts = this._pendingAsserts();
4971     if (!this._planError && this._plan !== undefined && pendingAsserts) {
4972         this._planError = true;
4973         this.fail('plan != count', {
4974             expected : this._plan,
4975             actual : this.assertCount
4976         });
4977     }
4978     this.ended = true;
4979 };
4980
4981 Test.prototype._exit = function () {
4982     if (this._plan !== undefined &&
4983         !this._planError && this.assertCount !== this._plan) {
4984         this._planError = true;
4985         this.fail('plan != count', {
4986             expected : this._plan,
4987             actual : this.assertCount,
4988             exiting : true
4989         });
4990     }
4991     else if (!this.ended) {
4992         this.fail('test exited without ending', {
4993             exiting: true
4994         });
4995     }
4996 };
4997
4998 Test.prototype._pendingAsserts = function () {
4999     if (this._plan === undefined) {
5000         return 1;
5001     } else {
5002         return this._plan -
5003             (this._progeny.length + this.assertCount);
5004     }
5005 }
5006
5007 Test.prototype._assert = function assert (ok, opts) {
5008     var self = this;
5009     var extra = opts.extra || {};
5010     
5011     var res = {
5012         id : self.assertCount ++,
5013         ok : Boolean(ok),
5014         skip : defined(extra.skip, opts.skip),
5015         name : defined(extra.message, opts.message, '(unnamed assert)'),
5016         operator : defined(extra.operator, opts.operator),
5017         actual : defined(extra.actual, opts.actual),
5018         expected : defined(extra.expected, opts.expected)
5019     };
5020     this._ok = Boolean(this._ok && ok);
5021     
5022     if (!ok) {
5023         res.error = defined(extra.error, opts.error, new Error(res.name));
5024     }
5025     
5026     var e = new Error('exception');
5027     var err = (e.stack || '').split('\n');
5028     var dir = path.dirname(__dirname) + '/';
5029     
5030     for (var i = 0; i < err.length; i++) {
5031         var m = /^\s*\bat\s+(.+)/.exec(err[i]);
5032         if (!m) continue;
5033         
5034         var s = m[1].split(/\s+/);
5035         var filem = /(\/[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[1]);
5036         if (!filem) {
5037             filem = /(\/[^:\s]+:(\d+)(?::(\d+))?)/.exec(s[3]);
5038             
5039             if (!filem) continue;
5040         }
5041         
5042         if (filem[1].slice(0, dir.length) === dir) continue;
5043         
5044         res.functionName = s[0];
5045         res.file = filem[1];
5046         res.line = Number(filem[2]);
5047         if (filem[3]) res.column = filem[3];
5048         
5049         res.at = m[1];
5050         break;
5051     }
5052     
5053     self.emit('result', res);
5054     
5055     var pendingAsserts = self._pendingAsserts();
5056     if (!pendingAsserts) {
5057         if (extra.exiting) {
5058             self.end();
5059         } else {
5060             nextTick(function () {
5061                 self.end();
5062             });
5063         }
5064     }
5065     
5066     if (!self._planError && pendingAsserts < 0) {
5067         self._planError = true;
5068         self.fail('plan != count', {
5069             expected : self._plan,
5070             actual : self._plan - pendingAsserts
5071         });
5072     }
5073 };
5074
5075 Test.prototype.fail = function (msg, extra) {
5076     this._assert(false, {
5077         message : msg,
5078         operator : 'fail',
5079         extra : extra
5080     });
5081 };
5082
5083 Test.prototype.pass = function (msg, extra) {
5084     this._assert(true, {
5085         message : msg,
5086         operator : 'pass',
5087         extra : extra
5088     });
5089 };
5090
5091 Test.prototype.skip = function (msg, extra) {
5092     this._assert(true, {
5093         message : msg,
5094         operator : 'skip',
5095         skip : true,
5096         extra : extra
5097     });
5098 };
5099
5100 Test.prototype.ok
5101 = Test.prototype['true']
5102 = Test.prototype.assert
5103 = function (value, msg, extra) {
5104     this._assert(value, {
5105         message : msg,
5106         operator : 'ok',
5107         expected : true,
5108         actual : value,
5109         extra : extra
5110     });
5111 };
5112
5113 Test.prototype.notOk
5114 = Test.prototype['false']
5115 = Test.prototype.notok
5116 = function (value, msg, extra) {
5117     this._assert(!value, {
5118         message : msg,
5119         operator : 'notOk',
5120         expected : false,
5121         actual : value,
5122         extra : extra
5123     });
5124 };
5125
5126 Test.prototype.error
5127 = Test.prototype.ifError
5128 = Test.prototype.ifErr
5129 = Test.prototype.iferror
5130 = function (err, msg, extra) {
5131     this._assert(!err, {
5132         message : defined(msg, String(err)),
5133         operator : 'error',
5134         actual : err,
5135         extra : extra
5136     });
5137 };
5138
5139 Test.prototype.equal
5140 = Test.prototype.equals
5141 = Test.prototype.isEqual
5142 = Test.prototype.is
5143 = Test.prototype.strictEqual
5144 = Test.prototype.strictEquals
5145 = function (a, b, msg, extra) {
5146     this._assert(a === b, {
5147         message : defined(msg, 'should be equal'),
5148         operator : 'equal',
5149         actual : a,
5150         expected : b,
5151         extra : extra
5152     });
5153 };
5154
5155 Test.prototype.notEqual
5156 = Test.prototype.notEquals
5157 = Test.prototype.notStrictEqual
5158 = Test.prototype.notStrictEquals
5159 = Test.prototype.isNotEqual
5160 = Test.prototype.isNot
5161 = Test.prototype.not
5162 = Test.prototype.doesNotEqual
5163 = Test.prototype.isInequal
5164 = function (a, b, msg, extra) {
5165     this._assert(a !== b, {
5166         message : defined(msg, 'should not be equal'),
5167         operator : 'notEqual',
5168         actual : a,
5169         notExpected : b,
5170         extra : extra
5171     });
5172 };
5173
5174 Test.prototype.deepEqual
5175 = Test.prototype.deepEquals
5176 = Test.prototype.isEquivalent
5177 = Test.prototype.same
5178 = function (a, b, msg, extra) {
5179     this._assert(deepEqual(a, b, { strict: true }), {
5180         message : defined(msg, 'should be equivalent'),
5181         operator : 'deepEqual',
5182         actual : a,
5183         expected : b,
5184         extra : extra
5185     });
5186 };
5187
5188 Test.prototype.deepLooseEqual
5189 = Test.prototype.looseEqual
5190 = Test.prototype.looseEquals
5191 = function (a, b, msg, extra) {
5192     this._assert(deepEqual(a, b), {
5193         message : defined(msg, 'should be equivalent'),
5194         operator : 'deepLooseEqual',
5195         actual : a,
5196         expected : b,
5197         extra : extra
5198     });
5199 };
5200
5201 Test.prototype.notDeepEqual
5202 = Test.prototype.notEquivalent
5203 = Test.prototype.notDeeply
5204 = Test.prototype.notSame
5205 = Test.prototype.isNotDeepEqual
5206 = Test.prototype.isNotDeeply
5207 = Test.prototype.isNotEquivalent
5208 = Test.prototype.isInequivalent
5209 = function (a, b, msg, extra) {
5210     this._assert(!deepEqual(a, b, { strict: true }), {
5211         message : defined(msg, 'should not be equivalent'),
5212         operator : 'notDeepEqual',
5213         actual : a,
5214         notExpected : b,
5215         extra : extra
5216     });
5217 };
5218
5219 Test.prototype.notDeepLooseEqual
5220 = Test.prototype.notLooseEqual
5221 = Test.prototype.notLooseEquals
5222 = function (a, b, msg, extra) {
5223     this._assert(deepEqual(a, b), {
5224         message : defined(msg, 'should be equivalent'),
5225         operator : 'notDeepLooseEqual',
5226         actual : a,
5227         expected : b,
5228         extra : extra
5229     });
5230 };
5231
5232 Test.prototype['throws'] = function (fn, expected, msg, extra) {
5233     if (typeof expected === 'string') {
5234         msg = expected;
5235         expected = undefined;
5236     }
5237     var caught = undefined;
5238     try {
5239         fn();
5240     }
5241     catch (err) {
5242         caught = { error : err };
5243         var message = err.message;
5244         delete err.message;
5245         err.message = message;
5246     }
5247
5248     var passed = caught;
5249
5250     if (expected instanceof RegExp) {
5251         passed = expected.test(caught && caught.error);
5252         expected = String(expected);
5253     }
5254
5255     this._assert(passed, {
5256         message : defined(msg, 'should throw'),
5257         operator : 'throws',
5258         actual : caught && caught.error,
5259         expected : expected,
5260         error: !passed && caught && caught.error,
5261         extra : extra
5262     });
5263 };
5264
5265 Test.prototype.doesNotThrow = function (fn, expected, msg, extra) {
5266     if (typeof expected === 'string') {
5267         msg = expected;
5268         expected = undefined;
5269     }
5270     var caught = undefined;
5271     try {
5272         fn();
5273     }
5274     catch (err) {
5275         caught = { error : err };
5276     }
5277     this._assert(!caught, {
5278         message : defined(msg, 'should throw'),
5279         operator : 'throws',
5280         actual : caught && caught.error,
5281         expected : expected,
5282         error : caught && caught.error,
5283         extra : extra
5284     });
5285 };
5286
5287 // vim: set softtabstop=4 shiftwidth=4:
5288
5289 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"/node_modules/tape/lib")
5290 },{"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"deep-equal":23,"defined":26,"events":4,"path":7,"stream":9,"util":17}],23:[function(require,module,exports){
5291 var pSlice = Array.prototype.slice;
5292 var objectKeys = require('./lib/keys.js');
5293 var isArguments = require('./lib/is_arguments.js');
5294
5295 var deepEqual = module.exports = function (actual, expected, opts) {
5296   if (!opts) opts = {};
5297   // 7.1. All identical values are equivalent, as determined by ===.
5298   if (actual === expected) {
5299     return true;
5300
5301   } else if (actual instanceof Date && expected instanceof Date) {
5302     return actual.getTime() === expected.getTime();
5303
5304   // 7.3. Other pairs that do not both pass typeof value == 'object',
5305   // equivalence is determined by ==.
5306   } else if (typeof actual != 'object' && typeof expected != 'object') {
5307     return opts.strict ? actual === expected : actual == expected;
5308
5309   // 7.4. For all other Object pairs, including Array objects, equivalence is
5310   // determined by having the same number of owned properties (as verified
5311   // with Object.prototype.hasOwnProperty.call), the same set of keys
5312   // (although not necessarily the same order), equivalent values for every
5313   // corresponding key, and an identical 'prototype' property. Note: this
5314   // accounts for both named and indexed properties on Arrays.
5315   } else {
5316     return objEquiv(actual, expected, opts);
5317   }
5318 }
5319
5320 function isUndefinedOrNull(value) {
5321   return value === null || value === undefined;
5322 }
5323
5324 function objEquiv(a, b, opts) {
5325   if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
5326     return false;
5327   // an identical 'prototype' property.
5328   if (a.prototype !== b.prototype) return false;
5329   //~~~I've managed to break Object.keys through screwy arguments passing.
5330   //   Converting to array solves the problem.
5331   if (isArguments(a)) {
5332     if (!isArguments(b)) {
5333       return false;
5334     }
5335     a = pSlice.call(a);
5336     b = pSlice.call(b);
5337     return deepEqual(a, b, opts);
5338   }
5339   try {
5340     var ka = objectKeys(a),
5341         kb = objectKeys(b),
5342         key, i;
5343   } catch (e) {//happens when one is a string literal and the other isn't
5344     return false;
5345   }
5346   // having the same number of owned properties (keys incorporates
5347   // hasOwnProperty)
5348   if (ka.length != kb.length)
5349     return false;
5350   //the same set of keys (although not necessarily the same order),
5351   ka.sort();
5352   kb.sort();
5353   //~~~cheap key test
5354   for (i = ka.length - 1; i >= 0; i--) {
5355     if (ka[i] != kb[i])
5356       return false;
5357   }
5358   //equivalent values for every corresponding key, and
5359   //~~~possibly expensive deep test
5360   for (i = ka.length - 1; i >= 0; i--) {
5361     key = ka[i];
5362     if (!deepEqual(a[key], b[key], opts)) return false;
5363   }
5364   return true;
5365 }
5366
5367 },{"./lib/is_arguments.js":24,"./lib/keys.js":25}],24:[function(require,module,exports){
5368 var supportsArgumentsClass = (function(){
5369   return Object.prototype.toString.call(arguments)
5370 })() == '[object Arguments]';
5371
5372 exports = module.exports = supportsArgumentsClass ? supported : unsupported;
5373
5374 exports.supported = supported;
5375 function supported(object) {
5376   return Object.prototype.toString.call(object) == '[object Arguments]';
5377 };
5378
5379 exports.unsupported = unsupported;
5380 function unsupported(object){
5381   return object &&
5382     typeof object == 'object' &&
5383     typeof object.length == 'number' &&
5384     Object.prototype.hasOwnProperty.call(object, 'callee') &&
5385     !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
5386     false;
5387 };
5388
5389 },{}],25:[function(require,module,exports){
5390 exports = module.exports = typeof Object.keys === 'function'
5391   ? Object.keys : shim;
5392
5393 exports.shim = shim;
5394 function shim (obj) {
5395   var keys = [];
5396   for (var key in obj) keys.push(key);
5397   return keys;
5398 }
5399
5400 },{}],26:[function(require,module,exports){
5401 module.exports = function () {
5402     for (var i = 0; i < arguments.length; i++) {
5403         if (arguments[i] !== undefined) return arguments[i];
5404     }
5405 };
5406
5407 },{}],27:[function(require,module,exports){
5408 module.exports=require(5)
5409 },{}],28:[function(require,module,exports){
5410 exports.parse = require('./lib/parse');
5411 exports.stringify = require('./lib/stringify');
5412
5413 },{"./lib/parse":29,"./lib/stringify":30}],29:[function(require,module,exports){
5414 var at, // The index of the current character
5415     ch, // The current character
5416     escapee = {
5417         '"':  '"',
5418         '\\': '\\',
5419         '/':  '/',
5420         b:    '\b',
5421         f:    '\f',
5422         n:    '\n',
5423         r:    '\r',
5424         t:    '\t'
5425     },
5426     text,
5427
5428     error = function (m) {
5429         // Call error when something is wrong.
5430         throw {
5431             name:    'SyntaxError',
5432             message: m,
5433             at:      at,
5434             text:    text
5435         };
5436     },
5437     
5438     next = function (c) {
5439         // If a c parameter is provided, verify that it matches the current character.
5440         if (c && c !== ch) {
5441             error("Expected '" + c + "' instead of '" + ch + "'");
5442         }
5443         
5444         // Get the next character. When there are no more characters,
5445         // return the empty string.
5446         
5447         ch = text.charAt(at);
5448         at += 1;
5449         return ch;
5450     },
5451     
5452     number = function () {
5453         // Parse a number value.
5454         var number,
5455             string = '';
5456         
5457         if (ch === '-') {
5458             string = '-';
5459             next('-');
5460         }
5461         while (ch >= '0' && ch <= '9') {
5462             string += ch;
5463             next();
5464         }
5465         if (ch === '.') {
5466             string += '.';
5467             while (next() && ch >= '0' && ch <= '9') {
5468                 string += ch;
5469             }
5470         }
5471         if (ch === 'e' || ch === 'E') {
5472             string += ch;
5473             next();
5474             if (ch === '-' || ch === '+') {
5475                 string += ch;
5476                 next();
5477             }
5478             while (ch >= '0' && ch <= '9') {
5479                 string += ch;
5480                 next();
5481             }
5482         }
5483         number = +string;
5484         if (!isFinite(number)) {
5485             error("Bad number");
5486         } else {
5487             return number;
5488         }
5489     },
5490     
5491     string = function () {
5492         // Parse a string value.
5493         var hex,
5494             i,
5495             string = '',
5496             uffff;
5497         
5498         // When parsing for string values, we must look for " and \ characters.
5499         if (ch === '"') {
5500             while (next()) {
5501                 if (ch === '"') {
5502                     next();
5503                     return string;
5504                 } else if (ch === '\\') {
5505                     next();
5506                     if (ch === 'u') {
5507                         uffff = 0;
5508                         for (i = 0; i < 4; i += 1) {
5509                             hex = parseInt(next(), 16);
5510                             if (!isFinite(hex)) {
5511                                 break;
5512                             }
5513                             uffff = uffff * 16 + hex;
5514                         }
5515                         string += String.fromCharCode(uffff);
5516                     } else if (typeof escapee[ch] === 'string') {
5517                         string += escapee[ch];
5518                     } else {
5519                         break;
5520                     }
5521                 } else {
5522                     string += ch;
5523                 }
5524             }
5525         }
5526         error("Bad string");
5527     },
5528
5529     white = function () {
5530
5531 // Skip whitespace.
5532
5533         while (ch && ch <= ' ') {
5534             next();
5535         }
5536     },
5537
5538     word = function () {
5539
5540 // true, false, or null.
5541
5542         switch (ch) {
5543         case 't':
5544             next('t');
5545             next('r');
5546             next('u');
5547             next('e');
5548             return true;
5549         case 'f':
5550             next('f');
5551             next('a');
5552             next('l');
5553             next('s');
5554             next('e');
5555             return false;
5556         case 'n':
5557             next('n');
5558             next('u');
5559             next('l');
5560             next('l');
5561             return null;
5562         }
5563         error("Unexpected '" + ch + "'");
5564     },
5565
5566     value,  // Place holder for the value function.
5567
5568     array = function () {
5569
5570 // Parse an array value.
5571
5572         var array = [];
5573
5574         if (ch === '[') {
5575             next('[');
5576             white();
5577             if (ch === ']') {
5578                 next(']');
5579                 return array;   // empty array
5580             }
5581             while (ch) {
5582                 array.push(value());
5583                 white();
5584                 if (ch === ']') {
5585                     next(']');
5586                     return array;
5587                 }
5588                 next(',');
5589                 white();
5590             }
5591         }
5592         error("Bad array");
5593     },
5594
5595     object = function () {
5596
5597 // Parse an object value.
5598
5599         var key,
5600             object = {};
5601
5602         if (ch === '{') {
5603             next('{');
5604             white();
5605             if (ch === '}') {
5606                 next('}');
5607                 return object;   // empty object
5608             }
5609             while (ch) {
5610                 key = string();
5611                 white();
5612                 next(':');
5613                 if (Object.hasOwnProperty.call(object, key)) {
5614                     error('Duplicate key "' + key + '"');
5615                 }
5616                 object[key] = value();
5617                 white();
5618                 if (ch === '}') {
5619                     next('}');
5620                     return object;
5621                 }
5622                 next(',');
5623                 white();
5624             }
5625         }
5626         error("Bad object");
5627     };
5628
5629 value = function () {
5630
5631 // Parse a JSON value. It could be an object, an array, a string, a number,
5632 // or a word.
5633
5634     white();
5635     switch (ch) {
5636     case '{':
5637         return object();
5638     case '[':
5639         return array();
5640     case '"':
5641         return string();
5642     case '-':
5643         return number();
5644     default:
5645         return ch >= '0' && ch <= '9' ? number() : word();
5646     }
5647 };
5648
5649 // Return the json_parse function. It will have access to all of the above
5650 // functions and variables.
5651
5652 module.exports = function (source, reviver) {
5653     var result;
5654     
5655     text = source;
5656     at = 0;
5657     ch = ' ';
5658     result = value();
5659     white();
5660     if (ch) {
5661         error("Syntax error");
5662     }
5663
5664     // If there is a reviver function, we recursively walk the new structure,
5665     // passing each name/value pair to the reviver function for possible
5666     // transformation, starting with a temporary root object that holds the result
5667     // in an empty key. If there is not a reviver function, we simply return the
5668     // result.
5669
5670     return typeof reviver === 'function' ? (function walk(holder, key) {
5671         var k, v, value = holder[key];
5672         if (value && typeof value === 'object') {
5673             for (k in value) {
5674                 if (Object.prototype.hasOwnProperty.call(value, k)) {
5675                     v = walk(value, k);
5676                     if (v !== undefined) {
5677                         value[k] = v;
5678                     } else {
5679                         delete value[k];
5680                     }
5681                 }
5682             }
5683         }
5684         return reviver.call(holder, key, value);
5685     }({'': result}, '')) : result;
5686 };
5687
5688 },{}],30:[function(require,module,exports){
5689 var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
5690     escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
5691     gap,
5692     indent,
5693     meta = {    // table of character substitutions
5694         '\b': '\\b',
5695         '\t': '\\t',
5696         '\n': '\\n',
5697         '\f': '\\f',
5698         '\r': '\\r',
5699         '"' : '\\"',
5700         '\\': '\\\\'
5701     },
5702     rep;
5703
5704 function quote(string) {
5705     // If the string contains no control characters, no quote characters, and no
5706     // backslash characters, then we can safely slap some quotes around it.
5707     // Otherwise we must also replace the offending characters with safe escape
5708     // sequences.
5709     
5710     escapable.lastIndex = 0;
5711     return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
5712         var c = meta[a];
5713         return typeof c === 'string' ? c :
5714             '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
5715     }) + '"' : '"' + string + '"';
5716 }
5717
5718 function str(key, holder) {
5719     // Produce a string from holder[key].
5720     var i,          // The loop counter.
5721         k,          // The member key.
5722         v,          // The member value.
5723         length,
5724         mind = gap,
5725         partial,
5726         value = holder[key];
5727     
5728     // If the value has a toJSON method, call it to obtain a replacement value.
5729     if (value && typeof value === 'object' &&
5730             typeof value.toJSON === 'function') {
5731         value = value.toJSON(key);
5732     }
5733     
5734     // If we were called with a replacer function, then call the replacer to
5735     // obtain a replacement value.
5736     if (typeof rep === 'function') {
5737         value = rep.call(holder, key, value);
5738     }
5739     
5740     // What happens next depends on the value's type.
5741     switch (typeof value) {
5742         case 'string':
5743             return quote(value);
5744         
5745         case 'number':
5746             // JSON numbers must be finite. Encode non-finite numbers as null.
5747             return isFinite(value) ? String(value) : 'null';
5748         
5749         case 'boolean':
5750         case 'null':
5751             // If the value is a boolean or null, convert it to a string. Note:
5752             // typeof null does not produce 'null'. The case is included here in
5753             // the remote chance that this gets fixed someday.
5754             return String(value);
5755             
5756         case 'object':
5757             if (!value) return 'null';
5758             gap += indent;
5759             partial = [];
5760             
5761             // Array.isArray
5762             if (Object.prototype.toString.apply(value) === '[object Array]') {
5763                 length = value.length;
5764                 for (i = 0; i < length; i += 1) {
5765                     partial[i] = str(i, value) || 'null';
5766                 }
5767                 
5768                 // Join all of the elements together, separated with commas, and
5769                 // wrap them in brackets.
5770                 v = partial.length === 0 ? '[]' : gap ?
5771                     '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
5772                     '[' + partial.join(',') + ']';
5773                 gap = mind;
5774                 return v;
5775             }
5776             
5777             // If the replacer is an array, use it to select the members to be
5778             // stringified.
5779             if (rep && typeof rep === 'object') {
5780                 length = rep.length;
5781                 for (i = 0; i < length; i += 1) {
5782                     k = rep[i];
5783                     if (typeof k === 'string') {
5784                         v = str(k, value);
5785                         if (v) {
5786                             partial.push(quote(k) + (gap ? ': ' : ':') + v);
5787                         }
5788                     }
5789                 }
5790             }
5791             else {
5792                 // Otherwise, iterate through all of the keys in the object.
5793                 for (k in value) {
5794                     if (Object.prototype.hasOwnProperty.call(value, k)) {
5795                         v = str(k, value);
5796                         if (v) {
5797                             partial.push(quote(k) + (gap ? ': ' : ':') + v);
5798                         }
5799                     }
5800                 }
5801             }
5802             
5803         // Join all of the member texts together, separated with commas,
5804         // and wrap them in braces.
5805
5806         v = partial.length === 0 ? '{}' : gap ?
5807             '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
5808             '{' + partial.join(',') + '}';
5809         gap = mind;
5810         return v;
5811     }
5812 }
5813
5814 module.exports = function (value, replacer, space) {
5815     var i;
5816     gap = '';
5817     indent = '';
5818     
5819     // If the space parameter is a number, make an indent string containing that
5820     // many spaces.
5821     if (typeof space === 'number') {
5822         for (i = 0; i < space; i += 1) {
5823             indent += ' ';
5824         }
5825     }
5826     // If the space parameter is a string, it will be used as the indent string.
5827     else if (typeof space === 'string') {
5828         indent = space;
5829     }
5830
5831     // If there is a replacer, it must be a function or an array.
5832     // Otherwise, throw an error.
5833     rep = replacer;
5834     if (replacer && typeof replacer !== 'function'
5835     && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
5836         throw new Error('JSON.stringify');
5837     }
5838     
5839     // Make a fake root object containing our value under the key of ''.
5840     // Return the result of stringifying the value.
5841     return str('', {'': value});
5842 };
5843
5844 },{}],31:[function(require,module,exports){
5845 (function (process){
5846 var through = require('through');
5847 var nextTick = typeof setImmediate !== 'undefined'
5848     ? setImmediate
5849     : process.nextTick
5850 ;
5851
5852 module.exports = function (write, end) {
5853     var tr = through(write, end);
5854     tr.pause();
5855     var resume = tr.resume;
5856     var pause = tr.pause;
5857     var paused = false;
5858     
5859     tr.pause = function () {
5860         paused = true;
5861         return pause.apply(this, arguments);
5862     };
5863     
5864     tr.resume = function () {
5865         paused = false;
5866         return resume.apply(this, arguments);
5867     };
5868     
5869     nextTick(function () {
5870         if (!paused) tr.resume();
5871     });
5872     
5873     return tr;
5874 };
5875
5876 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
5877 },{"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"through":32}],32:[function(require,module,exports){
5878 (function (process){
5879 var Stream = require('stream')
5880
5881 // through
5882 //
5883 // a stream that does nothing but re-emit the input.
5884 // useful for aggregating a series of changing but not ending streams into one stream)
5885
5886 exports = module.exports = through
5887 through.through = through
5888
5889 //create a readable writable stream.
5890
5891 function through (write, end, opts) {
5892   write = write || function (data) { this.queue(data) }
5893   end = end || function () { this.queue(null) }
5894
5895   var ended = false, destroyed = false, buffer = [], _ended = false
5896   var stream = new Stream()
5897   stream.readable = stream.writable = true
5898   stream.paused = false
5899
5900 //  stream.autoPause   = !(opts && opts.autoPause   === false)
5901   stream.autoDestroy = !(opts && opts.autoDestroy === false)
5902
5903   stream.write = function (data) {
5904     write.call(this, data)
5905     return !stream.paused
5906   }
5907
5908   function drain() {
5909     while(buffer.length && !stream.paused) {
5910       var data = buffer.shift()
5911       if(null === data)
5912         return stream.emit('end')
5913       else
5914         stream.emit('data', data)
5915     }
5916   }
5917
5918   stream.queue = stream.push = function (data) {
5919 //    console.error(ended)
5920     if(_ended) return stream
5921     if(data == null) _ended = true
5922     buffer.push(data)
5923     drain()
5924     return stream
5925   }
5926
5927   //this will be registered as the first 'end' listener
5928   //must call destroy next tick, to make sure we're after any
5929   //stream piped from here.
5930   //this is only a problem if end is not emitted synchronously.
5931   //a nicer way to do this is to make sure this is the last listener for 'end'
5932
5933   stream.on('end', function () {
5934     stream.readable = false
5935     if(!stream.writable && stream.autoDestroy)
5936       process.nextTick(function () {
5937         stream.destroy()
5938       })
5939   })
5940
5941   function _end () {
5942     stream.writable = false
5943     end.call(stream)
5944     if(!stream.readable && stream.autoDestroy)
5945       stream.destroy()
5946   }
5947
5948   stream.end = function (data) {
5949     if(ended) return
5950     ended = true
5951     if(arguments.length) stream.write(data)
5952     _end() // will emit or queue
5953     return stream
5954   }
5955
5956   stream.destroy = function () {
5957     if(destroyed) return
5958     destroyed = true
5959     ended = true
5960     buffer.length = 0
5961     stream.writable = stream.readable = false
5962     stream.emit('close')
5963     return stream
5964   }
5965
5966   stream.pause = function () {
5967     if(stream.paused) return
5968     stream.paused = true
5969     return stream
5970   }
5971
5972   stream.resume = function () {
5973     if(stream.paused) {
5974       stream.paused = false
5975       stream.emit('resume')
5976     }
5977     drain()
5978     //may have become paused again,
5979     //as drain emits 'data'.
5980     if(!stream.paused)
5981       stream.emit('drain')
5982     return stream
5983   }
5984   return stream
5985 }
5986
5987
5988 }).call(this,require("/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
5989 },{"/Users/stephen/.nvm/v0.10.24/lib/node_modules/testling/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":6,"stream":9}],33:[function(require,module,exports){
5990 var test = require('tape')
5991 var isFunction = require('./index.js')
5992
5993 test('isFunction', function (t) {
5994     t.ok(!isFunction(), 'undefined is not a function')
5995     t.ok(!isFunction(null), 'null is not a function')
5996     t.ok(!isFunction(''), 'string is not a function')
5997     t.ok(!isFunction(/a/), 'regex is not a function')
5998     t.ok(!isFunction(true), 'true is not a function')
5999     t.ok(!isFunction(false), 'false is not a function')
6000     t.ok(!isFunction(NaN), 'NaN is not a function')
6001     t.ok(!isFunction(42), '42 is not a function')
6002     t.ok(isFunction(function () {}), 'function is a function')
6003     t.ok(isFunction(setTimeout), 'setTimeout is a function')
6004     t.end()
6005 })
6006
6007 if (typeof window !== 'undefined') {
6008     test('browser quirks', function (t) {
6009         t.plan(2)
6010         
6011         t.ok(isFunction(window.alert), 'alert is a function')
6012
6013         window.testRegExpFromIframe = function (regexp) {
6014             t.ok(!isFunction(regexp))
6015         }
6016         
6017         var iframe = document.createElement('iframe')
6018         document.body.appendChild(iframe)
6019         
6020         iframe.contentWindow.document.write([
6021             "<html><body><script type=\"text/javascript\">",
6022             "parent.testRegExpFromIframe(/a/)",
6023             "</script></body></html>"
6024         ].join("\n"));
6025     })
6026 }
6027
6028 },{"./index.js":18,"tape":19}]},{},[33])