react-source 0.5.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,7 @@
1
1
  /**
2
- * JSXTransformer v0.5.2
2
+ * JSXTransformer v0.8.0
3
3
  */
4
- !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSXTransformer=e():"undefined"!=typeof global?global.JSXTransformer=e():"undefined"!=typeof self&&(self.JSXTransformer=e())}(function(){var define,module,exports;
5
- return (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){
4
+ !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSXTransformer=e():"undefined"!=typeof global?global.JSXTransformer=e():"undefined"!=typeof self&&(self.JSXTransformer=e())}(function(){var define,module,exports;return (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){
6
5
 
7
6
 
8
7
  //
@@ -431,2384 +430,7 @@ exports.extname = function(path) {
431
430
  return splitPath(path)[3];
432
431
  };
433
432
 
434
- },{"__browserify_process":5,"_shims":1,"util":3}],3:[function(require,module,exports){
435
- var Buffer=require("__browserify_Buffer").Buffer;// Copyright Joyent, Inc. and other Node contributors.
436
- //
437
- // Permission is hereby granted, free of charge, to any person obtaining a
438
- // copy of this software and associated documentation files (the
439
- // "Software"), to deal in the Software without restriction, including
440
- // without limitation the rights to use, copy, modify, merge, publish,
441
- // distribute, sublicense, and/or sell copies of the Software, and to permit
442
- // persons to whom the Software is furnished to do so, subject to the
443
- // following conditions:
444
- //
445
- // The above copyright notice and this permission notice shall be included
446
- // in all copies or substantial portions of the Software.
447
- //
448
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
449
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
450
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
451
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
452
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
453
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
454
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
455
-
456
- var shims = require('_shims');
457
-
458
- var formatRegExp = /%[sdj%]/g;
459
- exports.format = function(f) {
460
- if (!isString(f)) {
461
- var objects = [];
462
- for (var i = 0; i < arguments.length; i++) {
463
- objects.push(inspect(arguments[i]));
464
- }
465
- return objects.join(' ');
466
- }
467
-
468
- var i = 1;
469
- var args = arguments;
470
- var len = args.length;
471
- var str = String(f).replace(formatRegExp, function(x) {
472
- if (x === '%%') return '%';
473
- if (i >= len) return x;
474
- switch (x) {
475
- case '%s': return String(args[i++]);
476
- case '%d': return Number(args[i++]);
477
- case '%j':
478
- try {
479
- return JSON.stringify(args[i++]);
480
- } catch (_) {
481
- return '[Circular]';
482
- }
483
- default:
484
- return x;
485
- }
486
- });
487
- for (var x = args[i]; i < len; x = args[++i]) {
488
- if (isNull(x) || !isObject(x)) {
489
- str += ' ' + x;
490
- } else {
491
- str += ' ' + inspect(x);
492
- }
493
- }
494
- return str;
495
- };
496
-
497
- /**
498
- * Echos the value of a value. Trys to print the value out
499
- * in the best way possible given the different types.
500
- *
501
- * @param {Object} obj The object to print out.
502
- * @param {Object} opts Optional options object that alters the output.
503
- */
504
- /* legacy: obj, showHidden, depth, colors*/
505
- function inspect(obj, opts) {
506
- // default options
507
- var ctx = {
508
- seen: [],
509
- stylize: stylizeNoColor
510
- };
511
- // legacy...
512
- if (arguments.length >= 3) ctx.depth = arguments[2];
513
- if (arguments.length >= 4) ctx.colors = arguments[3];
514
- if (isBoolean(opts)) {
515
- // legacy...
516
- ctx.showHidden = opts;
517
- } else if (opts) {
518
- // got an "options" object
519
- exports._extend(ctx, opts);
520
- }
521
- // set default options
522
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
523
- if (isUndefined(ctx.depth)) ctx.depth = 2;
524
- if (isUndefined(ctx.colors)) ctx.colors = false;
525
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
526
- if (ctx.colors) ctx.stylize = stylizeWithColor;
527
- return formatValue(ctx, obj, ctx.depth);
528
- }
529
- exports.inspect = inspect;
530
-
531
-
532
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
533
- inspect.colors = {
534
- 'bold' : [1, 22],
535
- 'italic' : [3, 23],
536
- 'underline' : [4, 24],
537
- 'inverse' : [7, 27],
538
- 'white' : [37, 39],
539
- 'grey' : [90, 39],
540
- 'black' : [30, 39],
541
- 'blue' : [34, 39],
542
- 'cyan' : [36, 39],
543
- 'green' : [32, 39],
544
- 'magenta' : [35, 39],
545
- 'red' : [31, 39],
546
- 'yellow' : [33, 39]
547
- };
548
-
549
- // Don't use 'blue' not visible on cmd.exe
550
- inspect.styles = {
551
- 'special': 'cyan',
552
- 'number': 'yellow',
553
- 'boolean': 'yellow',
554
- 'undefined': 'grey',
555
- 'null': 'bold',
556
- 'string': 'green',
557
- 'date': 'magenta',
558
- // "name": intentionally not styling
559
- 'regexp': 'red'
560
- };
561
-
562
-
563
- function stylizeWithColor(str, styleType) {
564
- var style = inspect.styles[styleType];
565
-
566
- if (style) {
567
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
568
- '\u001b[' + inspect.colors[style][1] + 'm';
569
- } else {
570
- return str;
571
- }
572
- }
573
-
574
-
575
- function stylizeNoColor(str, styleType) {
576
- return str;
577
- }
578
-
579
-
580
- function arrayToHash(array) {
581
- var hash = {};
582
-
583
- shims.forEach(array, function(val, idx) {
584
- hash[val] = true;
585
- });
586
-
587
- return hash;
588
- }
589
-
590
-
591
- function formatValue(ctx, value, recurseTimes) {
592
- // Provide a hook for user-specified inspect functions.
593
- // Check that value is an object with an inspect function on it
594
- if (ctx.customInspect &&
595
- value &&
596
- isFunction(value.inspect) &&
597
- // Filter out the util module, it's inspect function is special
598
- value.inspect !== exports.inspect &&
599
- // Also filter out any prototype objects using the circular check.
600
- !(value.constructor && value.constructor.prototype === value)) {
601
- var ret = value.inspect(recurseTimes);
602
- if (!isString(ret)) {
603
- ret = formatValue(ctx, ret, recurseTimes);
604
- }
605
- return ret;
606
- }
607
-
608
- // Primitive types cannot have properties
609
- var primitive = formatPrimitive(ctx, value);
610
- if (primitive) {
611
- return primitive;
612
- }
613
-
614
- // Look up the keys of the object.
615
- var keys = shims.keys(value);
616
- var visibleKeys = arrayToHash(keys);
617
-
618
- if (ctx.showHidden) {
619
- keys = shims.getOwnPropertyNames(value);
620
- }
621
-
622
- // Some type of object without properties can be shortcutted.
623
- if (keys.length === 0) {
624
- if (isFunction(value)) {
625
- var name = value.name ? ': ' + value.name : '';
626
- return ctx.stylize('[Function' + name + ']', 'special');
627
- }
628
- if (isRegExp(value)) {
629
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
630
- }
631
- if (isDate(value)) {
632
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
633
- }
634
- if (isError(value)) {
635
- return formatError(value);
636
- }
637
- }
638
-
639
- var base = '', array = false, braces = ['{', '}'];
640
-
641
- // Make Array say that they are Array
642
- if (isArray(value)) {
643
- array = true;
644
- braces = ['[', ']'];
645
- }
646
-
647
- // Make functions say that they are functions
648
- if (isFunction(value)) {
649
- var n = value.name ? ': ' + value.name : '';
650
- base = ' [Function' + n + ']';
651
- }
652
-
653
- // Make RegExps say that they are RegExps
654
- if (isRegExp(value)) {
655
- base = ' ' + RegExp.prototype.toString.call(value);
656
- }
657
-
658
- // Make dates with properties first say the date
659
- if (isDate(value)) {
660
- base = ' ' + Date.prototype.toUTCString.call(value);
661
- }
662
-
663
- // Make error with message first say the error
664
- if (isError(value)) {
665
- base = ' ' + formatError(value);
666
- }
667
-
668
- if (keys.length === 0 && (!array || value.length == 0)) {
669
- return braces[0] + base + braces[1];
670
- }
671
-
672
- if (recurseTimes < 0) {
673
- if (isRegExp(value)) {
674
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
675
- } else {
676
- return ctx.stylize('[Object]', 'special');
677
- }
678
- }
679
-
680
- ctx.seen.push(value);
681
-
682
- var output;
683
- if (array) {
684
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
685
- } else {
686
- output = keys.map(function(key) {
687
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
688
- });
689
- }
690
-
691
- ctx.seen.pop();
692
-
693
- return reduceToSingleString(output, base, braces);
694
- }
695
-
696
-
697
- function formatPrimitive(ctx, value) {
698
- if (isUndefined(value))
699
- return ctx.stylize('undefined', 'undefined');
700
- if (isString(value)) {
701
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
702
- .replace(/'/g, "\\'")
703
- .replace(/\\"/g, '"') + '\'';
704
- return ctx.stylize(simple, 'string');
705
- }
706
- if (isNumber(value))
707
- return ctx.stylize('' + value, 'number');
708
- if (isBoolean(value))
709
- return ctx.stylize('' + value, 'boolean');
710
- // For some reason typeof null is "object", so special case here.
711
- if (isNull(value))
712
- return ctx.stylize('null', 'null');
713
- }
714
-
715
-
716
- function formatError(value) {
717
- return '[' + Error.prototype.toString.call(value) + ']';
718
- }
719
-
720
-
721
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
722
- var output = [];
723
- for (var i = 0, l = value.length; i < l; ++i) {
724
- if (hasOwnProperty(value, String(i))) {
725
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
726
- String(i), true));
727
- } else {
728
- output.push('');
729
- }
730
- }
731
-
732
- shims.forEach(keys, function(key) {
733
- if (!key.match(/^\d+$/)) {
734
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
735
- key, true));
736
- }
737
- });
738
- return output;
739
- }
740
-
741
-
742
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
743
- var name, str, desc;
744
- desc = shims.getOwnPropertyDescriptor(value, key) || { value: value[key] };
745
- if (desc.get) {
746
- if (desc.set) {
747
- str = ctx.stylize('[Getter/Setter]', 'special');
748
- } else {
749
- str = ctx.stylize('[Getter]', 'special');
750
- }
751
- } else {
752
- if (desc.set) {
753
- str = ctx.stylize('[Setter]', 'special');
754
- }
755
- }
756
-
757
- if (!hasOwnProperty(visibleKeys, key)) {
758
- name = '[' + key + ']';
759
- }
760
- if (!str) {
761
- if (shims.indexOf(ctx.seen, desc.value) < 0) {
762
- if (isNull(recurseTimes)) {
763
- str = formatValue(ctx, desc.value, null);
764
- } else {
765
- str = formatValue(ctx, desc.value, recurseTimes - 1);
766
- }
767
- if (str.indexOf('\n') > -1) {
768
- if (array) {
769
- str = str.split('\n').map(function(line) {
770
- return ' ' + line;
771
- }).join('\n').substr(2);
772
- } else {
773
- str = '\n' + str.split('\n').map(function(line) {
774
- return ' ' + line;
775
- }).join('\n');
776
- }
777
- }
778
- } else {
779
- str = ctx.stylize('[Circular]', 'special');
780
- }
781
- }
782
- if (isUndefined(name)) {
783
- if (array && key.match(/^\d+$/)) {
784
- return str;
785
- }
786
- name = JSON.stringify('' + key);
787
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
788
- name = name.substr(1, name.length - 2);
789
- name = ctx.stylize(name, 'name');
790
- } else {
791
- name = name.replace(/'/g, "\\'")
792
- .replace(/\\"/g, '"')
793
- .replace(/(^"|"$)/g, "'");
794
- name = ctx.stylize(name, 'string');
795
- }
796
- }
797
-
798
- return name + ': ' + str;
799
- }
800
-
801
-
802
- function reduceToSingleString(output, base, braces) {
803
- var numLinesEst = 0;
804
- var length = shims.reduce(output, function(prev, cur) {
805
- numLinesEst++;
806
- if (cur.indexOf('\n') >= 0) numLinesEst++;
807
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
808
- }, 0);
809
-
810
- if (length > 60) {
811
- return braces[0] +
812
- (base === '' ? '' : base + '\n ') +
813
- ' ' +
814
- output.join(',\n ') +
815
- ' ' +
816
- braces[1];
817
- }
818
-
819
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
820
- }
821
-
822
-
823
- // NOTE: These type checking functions intentionally don't use `instanceof`
824
- // because it is fragile and can be easily faked with `Object.create()`.
825
- function isArray(ar) {
826
- return shims.isArray(ar);
827
- }
828
- exports.isArray = isArray;
829
-
830
- function isBoolean(arg) {
831
- return typeof arg === 'boolean';
832
- }
833
- exports.isBoolean = isBoolean;
834
-
835
- function isNull(arg) {
836
- return arg === null;
837
- }
838
- exports.isNull = isNull;
839
-
840
- function isNullOrUndefined(arg) {
841
- return arg == null;
842
- }
843
- exports.isNullOrUndefined = isNullOrUndefined;
844
-
845
- function isNumber(arg) {
846
- return typeof arg === 'number';
847
- }
848
- exports.isNumber = isNumber;
849
-
850
- function isString(arg) {
851
- return typeof arg === 'string';
852
- }
853
- exports.isString = isString;
854
-
855
- function isSymbol(arg) {
856
- return typeof arg === 'symbol';
857
- }
858
- exports.isSymbol = isSymbol;
859
-
860
- function isUndefined(arg) {
861
- return arg === void 0;
862
- }
863
- exports.isUndefined = isUndefined;
864
-
865
- function isRegExp(re) {
866
- return isObject(re) && objectToString(re) === '[object RegExp]';
867
- }
868
- exports.isRegExp = isRegExp;
869
-
870
- function isObject(arg) {
871
- return typeof arg === 'object' && arg;
872
- }
873
- exports.isObject = isObject;
874
-
875
- function isDate(d) {
876
- return isObject(d) && objectToString(d) === '[object Date]';
877
- }
878
- exports.isDate = isDate;
879
-
880
- function isError(e) {
881
- return isObject(e) && objectToString(e) === '[object Error]';
882
- }
883
- exports.isError = isError;
884
-
885
- function isFunction(arg) {
886
- return typeof arg === 'function';
887
- }
888
- exports.isFunction = isFunction;
889
-
890
- function isPrimitive(arg) {
891
- return arg === null ||
892
- typeof arg === 'boolean' ||
893
- typeof arg === 'number' ||
894
- typeof arg === 'string' ||
895
- typeof arg === 'symbol' || // ES6 symbol
896
- typeof arg === 'undefined';
897
- }
898
- exports.isPrimitive = isPrimitive;
899
-
900
- function isBuffer(arg) {
901
- return arg instanceof Buffer;
902
- }
903
- exports.isBuffer = isBuffer;
904
-
905
- function objectToString(o) {
906
- return Object.prototype.toString.call(o);
907
- }
908
-
909
-
910
- function pad(n) {
911
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
912
- }
913
-
914
-
915
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
916
- 'Oct', 'Nov', 'Dec'];
917
-
918
- // 26 Feb 16:19:34
919
- function timestamp() {
920
- var d = new Date();
921
- var time = [pad(d.getHours()),
922
- pad(d.getMinutes()),
923
- pad(d.getSeconds())].join(':');
924
- return [d.getDate(), months[d.getMonth()], time].join(' ');
925
- }
926
-
927
-
928
- // log is just a thin wrapper to console.log that prepends a timestamp
929
- exports.log = function() {
930
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
931
- };
932
-
933
-
934
- /**
935
- * Inherit the prototype methods from one constructor into another.
936
- *
937
- * The Function.prototype.inherits from lang.js rewritten as a standalone
938
- * function (not on Function.prototype). NOTE: If this file is to be loaded
939
- * during bootstrapping this function needs to be rewritten using some native
940
- * functions as prototype setup using normal JavaScript does not work as
941
- * expected during bootstrapping (see mirror.js in r114903).
942
- *
943
- * @param {function} ctor Constructor function which needs to inherit the
944
- * prototype.
945
- * @param {function} superCtor Constructor function to inherit prototype from.
946
- */
947
- exports.inherits = function(ctor, superCtor) {
948
- ctor.super_ = superCtor;
949
- ctor.prototype = shims.create(superCtor.prototype, {
950
- constructor: {
951
- value: ctor,
952
- enumerable: false,
953
- writable: true,
954
- configurable: true
955
- }
956
- });
957
- };
958
-
959
- exports._extend = function(origin, add) {
960
- // Don't do anything if add isn't an object
961
- if (!add || !isObject(add)) return origin;
962
-
963
- var keys = shims.keys(add);
964
- var i = keys.length;
965
- while (i--) {
966
- origin[keys[i]] = add[keys[i]];
967
- }
968
- return origin;
969
- };
970
-
971
- function hasOwnProperty(obj, prop) {
972
- return Object.prototype.hasOwnProperty.call(obj, prop);
973
- }
974
-
975
- },{"__browserify_Buffer":4,"_shims":1}],4:[function(require,module,exports){
976
- require=(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){
977
- exports.readIEEE754 = function(buffer, offset, isBE, mLen, nBytes) {
978
- var e, m,
979
- eLen = nBytes * 8 - mLen - 1,
980
- eMax = (1 << eLen) - 1,
981
- eBias = eMax >> 1,
982
- nBits = -7,
983
- i = isBE ? 0 : (nBytes - 1),
984
- d = isBE ? 1 : -1,
985
- s = buffer[offset + i];
986
-
987
- i += d;
988
-
989
- e = s & ((1 << (-nBits)) - 1);
990
- s >>= (-nBits);
991
- nBits += eLen;
992
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
993
-
994
- m = e & ((1 << (-nBits)) - 1);
995
- e >>= (-nBits);
996
- nBits += mLen;
997
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
998
-
999
- if (e === 0) {
1000
- e = 1 - eBias;
1001
- } else if (e === eMax) {
1002
- return m ? NaN : ((s ? -1 : 1) * Infinity);
1003
- } else {
1004
- m = m + Math.pow(2, mLen);
1005
- e = e - eBias;
1006
- }
1007
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
1008
- };
1009
-
1010
- exports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) {
1011
- var e, m, c,
1012
- eLen = nBytes * 8 - mLen - 1,
1013
- eMax = (1 << eLen) - 1,
1014
- eBias = eMax >> 1,
1015
- rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
1016
- i = isBE ? (nBytes - 1) : 0,
1017
- d = isBE ? -1 : 1,
1018
- s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
1019
-
1020
- value = Math.abs(value);
1021
-
1022
- if (isNaN(value) || value === Infinity) {
1023
- m = isNaN(value) ? 1 : 0;
1024
- e = eMax;
1025
- } else {
1026
- e = Math.floor(Math.log(value) / Math.LN2);
1027
- if (value * (c = Math.pow(2, -e)) < 1) {
1028
- e--;
1029
- c *= 2;
1030
- }
1031
- if (e + eBias >= 1) {
1032
- value += rt / c;
1033
- } else {
1034
- value += rt * Math.pow(2, 1 - eBias);
1035
- }
1036
- if (value * c >= 2) {
1037
- e++;
1038
- c /= 2;
1039
- }
1040
-
1041
- if (e + eBias >= eMax) {
1042
- m = 0;
1043
- e = eMax;
1044
- } else if (e + eBias >= 1) {
1045
- m = (value * c - 1) * Math.pow(2, mLen);
1046
- e = e + eBias;
1047
- } else {
1048
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1049
- e = 0;
1050
- }
1051
- }
1052
-
1053
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);
1054
-
1055
- e = (e << mLen) | m;
1056
- eLen += mLen;
1057
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);
1058
-
1059
- buffer[offset + i - d] |= s * 128;
1060
- };
1061
-
1062
- },{}],"q9TxCC":[function(require,module,exports){
1063
- var assert;
1064
- exports.Buffer = Buffer;
1065
- exports.SlowBuffer = Buffer;
1066
- Buffer.poolSize = 8192;
1067
- exports.INSPECT_MAX_BYTES = 50;
1068
-
1069
- function stringtrim(str) {
1070
- if (str.trim) return str.trim();
1071
- return str.replace(/^\s+|\s+$/g, '');
1072
- }
1073
-
1074
- function Buffer(subject, encoding, offset) {
1075
- if(!assert) assert= require('assert');
1076
- if (!(this instanceof Buffer)) {
1077
- return new Buffer(subject, encoding, offset);
1078
- }
1079
- this.parent = this;
1080
- this.offset = 0;
1081
-
1082
- // Work-around: node's base64 implementation
1083
- // allows for non-padded strings while base64-js
1084
- // does not..
1085
- if (encoding == "base64" && typeof subject == "string") {
1086
- subject = stringtrim(subject);
1087
- while (subject.length % 4 != 0) {
1088
- subject = subject + "=";
1089
- }
1090
- }
1091
-
1092
- var type;
1093
-
1094
- // Are we slicing?
1095
- if (typeof offset === 'number') {
1096
- this.length = coerce(encoding);
1097
- // slicing works, with limitations (no parent tracking/update)
1098
- // check https://github.com/toots/buffer-browserify/issues/19
1099
- for (var i = 0; i < this.length; i++) {
1100
- this[i] = subject.get(i+offset);
1101
- }
1102
- } else {
1103
- // Find the length
1104
- switch (type = typeof subject) {
1105
- case 'number':
1106
- this.length = coerce(subject);
1107
- break;
1108
-
1109
- case 'string':
1110
- this.length = Buffer.byteLength(subject, encoding);
1111
- break;
1112
-
1113
- case 'object': // Assume object is an array
1114
- this.length = coerce(subject.length);
1115
- break;
1116
-
1117
- default:
1118
- throw new Error('First argument needs to be a number, ' +
1119
- 'array or string.');
1120
- }
1121
-
1122
- // Treat array-ish objects as a byte array.
1123
- if (isArrayIsh(subject)) {
1124
- for (var i = 0; i < this.length; i++) {
1125
- if (subject instanceof Buffer) {
1126
- this[i] = subject.readUInt8(i);
1127
- }
1128
- else {
1129
- this[i] = subject[i];
1130
- }
1131
- }
1132
- } else if (type == 'string') {
1133
- // We are a string
1134
- this.length = this.write(subject, 0, encoding);
1135
- } else if (type === 'number') {
1136
- for (var i = 0; i < this.length; i++) {
1137
- this[i] = 0;
1138
- }
1139
- }
1140
- }
1141
- }
1142
-
1143
- Buffer.prototype.get = function get(i) {
1144
- if (i < 0 || i >= this.length) throw new Error('oob');
1145
- return this[i];
1146
- };
1147
-
1148
- Buffer.prototype.set = function set(i, v) {
1149
- if (i < 0 || i >= this.length) throw new Error('oob');
1150
- return this[i] = v;
1151
- };
1152
-
1153
- Buffer.byteLength = function (str, encoding) {
1154
- switch (encoding || "utf8") {
1155
- case 'hex':
1156
- return str.length / 2;
1157
-
1158
- case 'utf8':
1159
- case 'utf-8':
1160
- return utf8ToBytes(str).length;
1161
-
1162
- case 'ascii':
1163
- case 'binary':
1164
- return str.length;
1165
-
1166
- case 'base64':
1167
- return base64ToBytes(str).length;
1168
-
1169
- default:
1170
- throw new Error('Unknown encoding');
1171
- }
1172
- };
1173
-
1174
- Buffer.prototype.utf8Write = function (string, offset, length) {
1175
- var bytes, pos;
1176
- return Buffer._charsWritten = blitBuffer(utf8ToBytes(string), this, offset, length);
1177
- };
1178
-
1179
- Buffer.prototype.asciiWrite = function (string, offset, length) {
1180
- var bytes, pos;
1181
- return Buffer._charsWritten = blitBuffer(asciiToBytes(string), this, offset, length);
1182
- };
1183
-
1184
- Buffer.prototype.binaryWrite = Buffer.prototype.asciiWrite;
1185
-
1186
- Buffer.prototype.base64Write = function (string, offset, length) {
1187
- var bytes, pos;
1188
- return Buffer._charsWritten = blitBuffer(base64ToBytes(string), this, offset, length);
1189
- };
1190
-
1191
- Buffer.prototype.base64Slice = function (start, end) {
1192
- var bytes = Array.prototype.slice.apply(this, arguments)
1193
- return require("base64-js").fromByteArray(bytes);
1194
- };
1195
-
1196
- Buffer.prototype.utf8Slice = function () {
1197
- var bytes = Array.prototype.slice.apply(this, arguments);
1198
- var res = "";
1199
- var tmp = "";
1200
- var i = 0;
1201
- while (i < bytes.length) {
1202
- if (bytes[i] <= 0x7F) {
1203
- res += decodeUtf8Char(tmp) + String.fromCharCode(bytes[i]);
1204
- tmp = "";
1205
- } else
1206
- tmp += "%" + bytes[i].toString(16);
1207
-
1208
- i++;
1209
- }
1210
-
1211
- return res + decodeUtf8Char(tmp);
1212
- }
1213
-
1214
- Buffer.prototype.asciiSlice = function () {
1215
- var bytes = Array.prototype.slice.apply(this, arguments);
1216
- var ret = "";
1217
- for (var i = 0; i < bytes.length; i++)
1218
- ret += String.fromCharCode(bytes[i]);
1219
- return ret;
1220
- }
1221
-
1222
- Buffer.prototype.binarySlice = Buffer.prototype.asciiSlice;
1223
-
1224
- Buffer.prototype.inspect = function() {
1225
- var out = [],
1226
- len = this.length;
1227
- for (var i = 0; i < len; i++) {
1228
- out[i] = toHex(this[i]);
1229
- if (i == exports.INSPECT_MAX_BYTES) {
1230
- out[i + 1] = '...';
1231
- break;
1232
- }
1233
- }
1234
- return '<Buffer ' + out.join(' ') + '>';
1235
- };
1236
-
1237
-
1238
- Buffer.prototype.hexSlice = function(start, end) {
1239
- var len = this.length;
1240
-
1241
- if (!start || start < 0) start = 0;
1242
- if (!end || end < 0 || end > len) end = len;
1243
-
1244
- var out = '';
1245
- for (var i = start; i < end; i++) {
1246
- out += toHex(this[i]);
1247
- }
1248
- return out;
1249
- };
1250
-
1251
-
1252
- Buffer.prototype.toString = function(encoding, start, end) {
1253
- encoding = String(encoding || 'utf8').toLowerCase();
1254
- start = +start || 0;
1255
- if (typeof end == 'undefined') end = this.length;
1256
-
1257
- // Fastpath empty strings
1258
- if (+end == start) {
1259
- return '';
1260
- }
1261
-
1262
- switch (encoding) {
1263
- case 'hex':
1264
- return this.hexSlice(start, end);
1265
-
1266
- case 'utf8':
1267
- case 'utf-8':
1268
- return this.utf8Slice(start, end);
1269
-
1270
- case 'ascii':
1271
- return this.asciiSlice(start, end);
1272
-
1273
- case 'binary':
1274
- return this.binarySlice(start, end);
1275
-
1276
- case 'base64':
1277
- return this.base64Slice(start, end);
1278
-
1279
- case 'ucs2':
1280
- case 'ucs-2':
1281
- return this.ucs2Slice(start, end);
1282
-
1283
- default:
1284
- throw new Error('Unknown encoding');
1285
- }
1286
- };
1287
-
1288
-
1289
- Buffer.prototype.hexWrite = function(string, offset, length) {
1290
- offset = +offset || 0;
1291
- var remaining = this.length - offset;
1292
- if (!length) {
1293
- length = remaining;
1294
- } else {
1295
- length = +length;
1296
- if (length > remaining) {
1297
- length = remaining;
1298
- }
1299
- }
1300
-
1301
- // must be an even number of digits
1302
- var strLen = string.length;
1303
- if (strLen % 2) {
1304
- throw new Error('Invalid hex string');
1305
- }
1306
- if (length > strLen / 2) {
1307
- length = strLen / 2;
1308
- }
1309
- for (var i = 0; i < length; i++) {
1310
- var byte = parseInt(string.substr(i * 2, 2), 16);
1311
- if (isNaN(byte)) throw new Error('Invalid hex string');
1312
- this[offset + i] = byte;
1313
- }
1314
- Buffer._charsWritten = i * 2;
1315
- return i;
1316
- };
1317
-
1318
-
1319
- Buffer.prototype.write = function(string, offset, length, encoding) {
1320
- // Support both (string, offset, length, encoding)
1321
- // and the legacy (string, encoding, offset, length)
1322
- if (isFinite(offset)) {
1323
- if (!isFinite(length)) {
1324
- encoding = length;
1325
- length = undefined;
1326
- }
1327
- } else { // legacy
1328
- var swap = encoding;
1329
- encoding = offset;
1330
- offset = length;
1331
- length = swap;
1332
- }
1333
-
1334
- offset = +offset || 0;
1335
- var remaining = this.length - offset;
1336
- if (!length) {
1337
- length = remaining;
1338
- } else {
1339
- length = +length;
1340
- if (length > remaining) {
1341
- length = remaining;
1342
- }
1343
- }
1344
- encoding = String(encoding || 'utf8').toLowerCase();
1345
-
1346
- switch (encoding) {
1347
- case 'hex':
1348
- return this.hexWrite(string, offset, length);
1349
-
1350
- case 'utf8':
1351
- case 'utf-8':
1352
- return this.utf8Write(string, offset, length);
1353
-
1354
- case 'ascii':
1355
- return this.asciiWrite(string, offset, length);
1356
-
1357
- case 'binary':
1358
- return this.binaryWrite(string, offset, length);
1359
-
1360
- case 'base64':
1361
- return this.base64Write(string, offset, length);
1362
-
1363
- case 'ucs2':
1364
- case 'ucs-2':
1365
- return this.ucs2Write(string, offset, length);
1366
-
1367
- default:
1368
- throw new Error('Unknown encoding');
1369
- }
1370
- };
1371
-
1372
- // slice(start, end)
1373
- function clamp(index, len, defaultValue) {
1374
- if (typeof index !== 'number') return defaultValue;
1375
- index = ~~index; // Coerce to integer.
1376
- if (index >= len) return len;
1377
- if (index >= 0) return index;
1378
- index += len;
1379
- if (index >= 0) return index;
1380
- return 0;
1381
- }
1382
-
1383
- Buffer.prototype.slice = function(start, end) {
1384
- var len = this.length;
1385
- start = clamp(start, len, 0);
1386
- end = clamp(end, len, len);
1387
- return new Buffer(this, end - start, +start);
1388
- };
1389
-
1390
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1391
- Buffer.prototype.copy = function(target, target_start, start, end) {
1392
- var source = this;
1393
- start || (start = 0);
1394
- if (end === undefined || isNaN(end)) {
1395
- end = this.length;
1396
- }
1397
- target_start || (target_start = 0);
1398
-
1399
- if (end < start) throw new Error('sourceEnd < sourceStart');
1400
-
1401
- // Copy 0 bytes; we're done
1402
- if (end === start) return 0;
1403
- if (target.length == 0 || source.length == 0) return 0;
1404
-
1405
- if (target_start < 0 || target_start >= target.length) {
1406
- throw new Error('targetStart out of bounds');
1407
- }
1408
-
1409
- if (start < 0 || start >= source.length) {
1410
- throw new Error('sourceStart out of bounds');
1411
- }
1412
-
1413
- if (end < 0 || end > source.length) {
1414
- throw new Error('sourceEnd out of bounds');
1415
- }
1416
-
1417
- // Are we oob?
1418
- if (end > this.length) {
1419
- end = this.length;
1420
- }
1421
-
1422
- if (target.length - target_start < end - start) {
1423
- end = target.length - target_start + start;
1424
- }
1425
-
1426
- var temp = [];
1427
- for (var i=start; i<end; i++) {
1428
- assert.ok(typeof this[i] !== 'undefined', "copying undefined buffer bytes!");
1429
- temp.push(this[i]);
1430
- }
1431
-
1432
- for (var i=target_start; i<target_start+temp.length; i++) {
1433
- target[i] = temp[i-target_start];
1434
- }
1435
- };
1436
-
1437
- // fill(value, start=0, end=buffer.length)
1438
- Buffer.prototype.fill = function fill(value, start, end) {
1439
- value || (value = 0);
1440
- start || (start = 0);
1441
- end || (end = this.length);
1442
-
1443
- if (typeof value === 'string') {
1444
- value = value.charCodeAt(0);
1445
- }
1446
- if (!(typeof value === 'number') || isNaN(value)) {
1447
- throw new Error('value is not a number');
1448
- }
1449
-
1450
- if (end < start) throw new Error('end < start');
1451
-
1452
- // Fill 0 bytes; we're done
1453
- if (end === start) return 0;
1454
- if (this.length == 0) return 0;
1455
-
1456
- if (start < 0 || start >= this.length) {
1457
- throw new Error('start out of bounds');
1458
- }
1459
-
1460
- if (end < 0 || end > this.length) {
1461
- throw new Error('end out of bounds');
1462
- }
1463
-
1464
- for (var i = start; i < end; i++) {
1465
- this[i] = value;
1466
- }
1467
- }
1468
-
1469
- // Static methods
1470
- Buffer.isBuffer = function isBuffer(b) {
1471
- return b instanceof Buffer || b instanceof Buffer;
1472
- };
1473
-
1474
- Buffer.concat = function (list, totalLength) {
1475
- if (!isArray(list)) {
1476
- throw new Error("Usage: Buffer.concat(list, [totalLength])\n \
1477
- list should be an Array.");
1478
- }
1479
-
1480
- if (list.length === 0) {
1481
- return new Buffer(0);
1482
- } else if (list.length === 1) {
1483
- return list[0];
1484
- }
1485
-
1486
- if (typeof totalLength !== 'number') {
1487
- totalLength = 0;
1488
- for (var i = 0; i < list.length; i++) {
1489
- var buf = list[i];
1490
- totalLength += buf.length;
1491
- }
1492
- }
1493
-
1494
- var buffer = new Buffer(totalLength);
1495
- var pos = 0;
1496
- for (var i = 0; i < list.length; i++) {
1497
- var buf = list[i];
1498
- buf.copy(buffer, pos);
1499
- pos += buf.length;
1500
- }
1501
- return buffer;
1502
- };
1503
-
1504
- Buffer.isEncoding = function(encoding) {
1505
- switch ((encoding + '').toLowerCase()) {
1506
- case 'hex':
1507
- case 'utf8':
1508
- case 'utf-8':
1509
- case 'ascii':
1510
- case 'binary':
1511
- case 'base64':
1512
- case 'ucs2':
1513
- case 'ucs-2':
1514
- case 'utf16le':
1515
- case 'utf-16le':
1516
- case 'raw':
1517
- return true;
1518
-
1519
- default:
1520
- return false;
1521
- }
1522
- };
1523
-
1524
- // helpers
1525
-
1526
- function coerce(length) {
1527
- // Coerce length to a number (possibly NaN), round up
1528
- // in case it's fractional (e.g. 123.456) then do a
1529
- // double negate to coerce a NaN to 0. Easy, right?
1530
- length = ~~Math.ceil(+length);
1531
- return length < 0 ? 0 : length;
1532
- }
1533
-
1534
- function isArray(subject) {
1535
- return (Array.isArray ||
1536
- function(subject){
1537
- return {}.toString.apply(subject) == '[object Array]'
1538
- })
1539
- (subject)
1540
- }
1541
-
1542
- function isArrayIsh(subject) {
1543
- return isArray(subject) || Buffer.isBuffer(subject) ||
1544
- subject && typeof subject === 'object' &&
1545
- typeof subject.length === 'number';
1546
- }
1547
-
1548
- function toHex(n) {
1549
- if (n < 16) return '0' + n.toString(16);
1550
- return n.toString(16);
1551
- }
1552
-
1553
- function utf8ToBytes(str) {
1554
- var byteArray = [];
1555
- for (var i = 0; i < str.length; i++)
1556
- if (str.charCodeAt(i) <= 0x7F)
1557
- byteArray.push(str.charCodeAt(i));
1558
- else {
1559
- var h = encodeURIComponent(str.charAt(i)).substr(1).split('%');
1560
- for (var j = 0; j < h.length; j++)
1561
- byteArray.push(parseInt(h[j], 16));
1562
- }
1563
-
1564
- return byteArray;
1565
- }
1566
-
1567
- function asciiToBytes(str) {
1568
- var byteArray = []
1569
- for (var i = 0; i < str.length; i++ )
1570
- // Node's code seems to be doing this and not & 0x7F..
1571
- byteArray.push( str.charCodeAt(i) & 0xFF );
1572
-
1573
- return byteArray;
1574
- }
1575
-
1576
- function base64ToBytes(str) {
1577
- return require("base64-js").toByteArray(str);
1578
- }
1579
-
1580
- function blitBuffer(src, dst, offset, length) {
1581
- var pos, i = 0;
1582
- while (i < length) {
1583
- if ((i+offset >= dst.length) || (i >= src.length))
1584
- break;
1585
-
1586
- dst[i + offset] = src[i];
1587
- i++;
1588
- }
1589
- return i;
1590
- }
1591
-
1592
- function decodeUtf8Char(str) {
1593
- try {
1594
- return decodeURIComponent(str);
1595
- } catch (err) {
1596
- return String.fromCharCode(0xFFFD); // UTF 8 invalid char
1597
- }
1598
- }
1599
-
1600
- // read/write bit-twiddling
1601
-
1602
- Buffer.prototype.readUInt8 = function(offset, noAssert) {
1603
- var buffer = this;
1604
-
1605
- if (!noAssert) {
1606
- assert.ok(offset !== undefined && offset !== null,
1607
- 'missing offset');
1608
-
1609
- assert.ok(offset < buffer.length,
1610
- 'Trying to read beyond buffer length');
1611
- }
1612
-
1613
- if (offset >= buffer.length) return;
1614
-
1615
- return buffer[offset];
1616
- };
1617
-
1618
- function readUInt16(buffer, offset, isBigEndian, noAssert) {
1619
- var val = 0;
1620
-
1621
-
1622
- if (!noAssert) {
1623
- assert.ok(typeof (isBigEndian) === 'boolean',
1624
- 'missing or invalid endian');
1625
-
1626
- assert.ok(offset !== undefined && offset !== null,
1627
- 'missing offset');
1628
-
1629
- assert.ok(offset + 1 < buffer.length,
1630
- 'Trying to read beyond buffer length');
1631
- }
1632
-
1633
- if (offset >= buffer.length) return 0;
1634
-
1635
- if (isBigEndian) {
1636
- val = buffer[offset] << 8;
1637
- if (offset + 1 < buffer.length) {
1638
- val |= buffer[offset + 1];
1639
- }
1640
- } else {
1641
- val = buffer[offset];
1642
- if (offset + 1 < buffer.length) {
1643
- val |= buffer[offset + 1] << 8;
1644
- }
1645
- }
1646
-
1647
- return val;
1648
- }
1649
-
1650
- Buffer.prototype.readUInt16LE = function(offset, noAssert) {
1651
- return readUInt16(this, offset, false, noAssert);
1652
- };
1653
-
1654
- Buffer.prototype.readUInt16BE = function(offset, noAssert) {
1655
- return readUInt16(this, offset, true, noAssert);
1656
- };
1657
-
1658
- function readUInt32(buffer, offset, isBigEndian, noAssert) {
1659
- var val = 0;
1660
-
1661
- if (!noAssert) {
1662
- assert.ok(typeof (isBigEndian) === 'boolean',
1663
- 'missing or invalid endian');
1664
-
1665
- assert.ok(offset !== undefined && offset !== null,
1666
- 'missing offset');
1667
-
1668
- assert.ok(offset + 3 < buffer.length,
1669
- 'Trying to read beyond buffer length');
1670
- }
1671
-
1672
- if (offset >= buffer.length) return 0;
1673
-
1674
- if (isBigEndian) {
1675
- if (offset + 1 < buffer.length)
1676
- val = buffer[offset + 1] << 16;
1677
- if (offset + 2 < buffer.length)
1678
- val |= buffer[offset + 2] << 8;
1679
- if (offset + 3 < buffer.length)
1680
- val |= buffer[offset + 3];
1681
- val = val + (buffer[offset] << 24 >>> 0);
1682
- } else {
1683
- if (offset + 2 < buffer.length)
1684
- val = buffer[offset + 2] << 16;
1685
- if (offset + 1 < buffer.length)
1686
- val |= buffer[offset + 1] << 8;
1687
- val |= buffer[offset];
1688
- if (offset + 3 < buffer.length)
1689
- val = val + (buffer[offset + 3] << 24 >>> 0);
1690
- }
1691
-
1692
- return val;
1693
- }
1694
-
1695
- Buffer.prototype.readUInt32LE = function(offset, noAssert) {
1696
- return readUInt32(this, offset, false, noAssert);
1697
- };
1698
-
1699
- Buffer.prototype.readUInt32BE = function(offset, noAssert) {
1700
- return readUInt32(this, offset, true, noAssert);
1701
- };
1702
-
1703
-
1704
- /*
1705
- * Signed integer types, yay team! A reminder on how two's complement actually
1706
- * works. The first bit is the signed bit, i.e. tells us whether or not the
1707
- * number should be positive or negative. If the two's complement value is
1708
- * positive, then we're done, as it's equivalent to the unsigned representation.
1709
- *
1710
- * Now if the number is positive, you're pretty much done, you can just leverage
1711
- * the unsigned translations and return those. Unfortunately, negative numbers
1712
- * aren't quite that straightforward.
1713
- *
1714
- * At first glance, one might be inclined to use the traditional formula to
1715
- * translate binary numbers between the positive and negative values in two's
1716
- * complement. (Though it doesn't quite work for the most negative value)
1717
- * Mainly:
1718
- * - invert all the bits
1719
- * - add one to the result
1720
- *
1721
- * Of course, this doesn't quite work in Javascript. Take for example the value
1722
- * of -128. This could be represented in 16 bits (big-endian) as 0xff80. But of
1723
- * course, Javascript will do the following:
1724
- *
1725
- * > ~0xff80
1726
- * -65409
1727
- *
1728
- * Whoh there, Javascript, that's not quite right. But wait, according to
1729
- * Javascript that's perfectly correct. When Javascript ends up seeing the
1730
- * constant 0xff80, it has no notion that it is actually a signed number. It
1731
- * assumes that we've input the unsigned value 0xff80. Thus, when it does the
1732
- * binary negation, it casts it into a signed value, (positive 0xff80). Then
1733
- * when you perform binary negation on that, it turns it into a negative number.
1734
- *
1735
- * Instead, we're going to have to use the following general formula, that works
1736
- * in a rather Javascript friendly way. I'm glad we don't support this kind of
1737
- * weird numbering scheme in the kernel.
1738
- *
1739
- * (BIT-MAX - (unsigned)val + 1) * -1
1740
- *
1741
- * The astute observer, may think that this doesn't make sense for 8-bit numbers
1742
- * (really it isn't necessary for them). However, when you get 16-bit numbers,
1743
- * you do. Let's go back to our prior example and see how this will look:
1744
- *
1745
- * (0xffff - 0xff80 + 1) * -1
1746
- * (0x007f + 1) * -1
1747
- * (0x0080) * -1
1748
- */
1749
- Buffer.prototype.readInt8 = function(offset, noAssert) {
1750
- var buffer = this;
1751
- var neg;
1752
-
1753
- if (!noAssert) {
1754
- assert.ok(offset !== undefined && offset !== null,
1755
- 'missing offset');
1756
-
1757
- assert.ok(offset < buffer.length,
1758
- 'Trying to read beyond buffer length');
1759
- }
1760
-
1761
- if (offset >= buffer.length) return;
1762
-
1763
- neg = buffer[offset] & 0x80;
1764
- if (!neg) {
1765
- return (buffer[offset]);
1766
- }
1767
-
1768
- return ((0xff - buffer[offset] + 1) * -1);
1769
- };
1770
-
1771
- function readInt16(buffer, offset, isBigEndian, noAssert) {
1772
- var neg, val;
1773
-
1774
- if (!noAssert) {
1775
- assert.ok(typeof (isBigEndian) === 'boolean',
1776
- 'missing or invalid endian');
1777
-
1778
- assert.ok(offset !== undefined && offset !== null,
1779
- 'missing offset');
1780
-
1781
- assert.ok(offset + 1 < buffer.length,
1782
- 'Trying to read beyond buffer length');
1783
- }
1784
-
1785
- val = readUInt16(buffer, offset, isBigEndian, noAssert);
1786
- neg = val & 0x8000;
1787
- if (!neg) {
1788
- return val;
1789
- }
1790
-
1791
- return (0xffff - val + 1) * -1;
1792
- }
1793
-
1794
- Buffer.prototype.readInt16LE = function(offset, noAssert) {
1795
- return readInt16(this, offset, false, noAssert);
1796
- };
1797
-
1798
- Buffer.prototype.readInt16BE = function(offset, noAssert) {
1799
- return readInt16(this, offset, true, noAssert);
1800
- };
1801
-
1802
- function readInt32(buffer, offset, isBigEndian, noAssert) {
1803
- var neg, val;
1804
-
1805
- if (!noAssert) {
1806
- assert.ok(typeof (isBigEndian) === 'boolean',
1807
- 'missing or invalid endian');
1808
-
1809
- assert.ok(offset !== undefined && offset !== null,
1810
- 'missing offset');
1811
-
1812
- assert.ok(offset + 3 < buffer.length,
1813
- 'Trying to read beyond buffer length');
1814
- }
1815
-
1816
- val = readUInt32(buffer, offset, isBigEndian, noAssert);
1817
- neg = val & 0x80000000;
1818
- if (!neg) {
1819
- return (val);
1820
- }
1821
-
1822
- return (0xffffffff - val + 1) * -1;
1823
- }
1824
-
1825
- Buffer.prototype.readInt32LE = function(offset, noAssert) {
1826
- return readInt32(this, offset, false, noAssert);
1827
- };
1828
-
1829
- Buffer.prototype.readInt32BE = function(offset, noAssert) {
1830
- return readInt32(this, offset, true, noAssert);
1831
- };
1832
-
1833
- function readFloat(buffer, offset, isBigEndian, noAssert) {
1834
- if (!noAssert) {
1835
- assert.ok(typeof (isBigEndian) === 'boolean',
1836
- 'missing or invalid endian');
1837
-
1838
- assert.ok(offset + 3 < buffer.length,
1839
- 'Trying to read beyond buffer length');
1840
- }
1841
-
1842
- return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian,
1843
- 23, 4);
1844
- }
1845
-
1846
- Buffer.prototype.readFloatLE = function(offset, noAssert) {
1847
- return readFloat(this, offset, false, noAssert);
1848
- };
1849
-
1850
- Buffer.prototype.readFloatBE = function(offset, noAssert) {
1851
- return readFloat(this, offset, true, noAssert);
1852
- };
1853
-
1854
- function readDouble(buffer, offset, isBigEndian, noAssert) {
1855
- if (!noAssert) {
1856
- assert.ok(typeof (isBigEndian) === 'boolean',
1857
- 'missing or invalid endian');
1858
-
1859
- assert.ok(offset + 7 < buffer.length,
1860
- 'Trying to read beyond buffer length');
1861
- }
1862
-
1863
- return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian,
1864
- 52, 8);
1865
- }
1866
-
1867
- Buffer.prototype.readDoubleLE = function(offset, noAssert) {
1868
- return readDouble(this, offset, false, noAssert);
1869
- };
1870
-
1871
- Buffer.prototype.readDoubleBE = function(offset, noAssert) {
1872
- return readDouble(this, offset, true, noAssert);
1873
- };
1874
-
1875
-
1876
- /*
1877
- * We have to make sure that the value is a valid integer. This means that it is
1878
- * non-negative. It has no fractional component and that it does not exceed the
1879
- * maximum allowed value.
1880
- *
1881
- * value The number to check for validity
1882
- *
1883
- * max The maximum value
1884
- */
1885
- function verifuint(value, max) {
1886
- assert.ok(typeof (value) == 'number',
1887
- 'cannot write a non-number as a number');
1888
-
1889
- assert.ok(value >= 0,
1890
- 'specified a negative value for writing an unsigned value');
1891
-
1892
- assert.ok(value <= max, 'value is larger than maximum value for type');
1893
-
1894
- assert.ok(Math.floor(value) === value, 'value has a fractional component');
1895
- }
1896
-
1897
- Buffer.prototype.writeUInt8 = function(value, offset, noAssert) {
1898
- var buffer = this;
1899
-
1900
- if (!noAssert) {
1901
- assert.ok(value !== undefined && value !== null,
1902
- 'missing value');
1903
-
1904
- assert.ok(offset !== undefined && offset !== null,
1905
- 'missing offset');
1906
-
1907
- assert.ok(offset < buffer.length,
1908
- 'trying to write beyond buffer length');
1909
-
1910
- verifuint(value, 0xff);
1911
- }
1912
-
1913
- if (offset < buffer.length) {
1914
- buffer[offset] = value;
1915
- }
1916
- };
1917
-
1918
- function writeUInt16(buffer, value, offset, isBigEndian, noAssert) {
1919
- if (!noAssert) {
1920
- assert.ok(value !== undefined && value !== null,
1921
- 'missing value');
1922
-
1923
- assert.ok(typeof (isBigEndian) === 'boolean',
1924
- 'missing or invalid endian');
1925
-
1926
- assert.ok(offset !== undefined && offset !== null,
1927
- 'missing offset');
1928
-
1929
- assert.ok(offset + 1 < buffer.length,
1930
- 'trying to write beyond buffer length');
1931
-
1932
- verifuint(value, 0xffff);
1933
- }
1934
-
1935
- for (var i = 0; i < Math.min(buffer.length - offset, 2); i++) {
1936
- buffer[offset + i] =
1937
- (value & (0xff << (8 * (isBigEndian ? 1 - i : i)))) >>>
1938
- (isBigEndian ? 1 - i : i) * 8;
1939
- }
1940
-
1941
- }
1942
-
1943
- Buffer.prototype.writeUInt16LE = function(value, offset, noAssert) {
1944
- writeUInt16(this, value, offset, false, noAssert);
1945
- };
1946
-
1947
- Buffer.prototype.writeUInt16BE = function(value, offset, noAssert) {
1948
- writeUInt16(this, value, offset, true, noAssert);
1949
- };
1950
-
1951
- function writeUInt32(buffer, value, offset, isBigEndian, noAssert) {
1952
- if (!noAssert) {
1953
- assert.ok(value !== undefined && value !== null,
1954
- 'missing value');
1955
-
1956
- assert.ok(typeof (isBigEndian) === 'boolean',
1957
- 'missing or invalid endian');
1958
-
1959
- assert.ok(offset !== undefined && offset !== null,
1960
- 'missing offset');
1961
-
1962
- assert.ok(offset + 3 < buffer.length,
1963
- 'trying to write beyond buffer length');
1964
-
1965
- verifuint(value, 0xffffffff);
1966
- }
1967
-
1968
- for (var i = 0; i < Math.min(buffer.length - offset, 4); i++) {
1969
- buffer[offset + i] =
1970
- (value >>> (isBigEndian ? 3 - i : i) * 8) & 0xff;
1971
- }
1972
- }
1973
-
1974
- Buffer.prototype.writeUInt32LE = function(value, offset, noAssert) {
1975
- writeUInt32(this, value, offset, false, noAssert);
1976
- };
1977
-
1978
- Buffer.prototype.writeUInt32BE = function(value, offset, noAssert) {
1979
- writeUInt32(this, value, offset, true, noAssert);
1980
- };
1981
-
1982
-
1983
- /*
1984
- * We now move onto our friends in the signed number category. Unlike unsigned
1985
- * numbers, we're going to have to worry a bit more about how we put values into
1986
- * arrays. Since we are only worrying about signed 32-bit values, we're in
1987
- * slightly better shape. Unfortunately, we really can't do our favorite binary
1988
- * & in this system. It really seems to do the wrong thing. For example:
1989
- *
1990
- * > -32 & 0xff
1991
- * 224
1992
- *
1993
- * What's happening above is really: 0xe0 & 0xff = 0xe0. However, the results of
1994
- * this aren't treated as a signed number. Ultimately a bad thing.
1995
- *
1996
- * What we're going to want to do is basically create the unsigned equivalent of
1997
- * our representation and pass that off to the wuint* functions. To do that
1998
- * we're going to do the following:
1999
- *
2000
- * - if the value is positive
2001
- * we can pass it directly off to the equivalent wuint
2002
- * - if the value is negative
2003
- * we do the following computation:
2004
- * mb + val + 1, where
2005
- * mb is the maximum unsigned value in that byte size
2006
- * val is the Javascript negative integer
2007
- *
2008
- *
2009
- * As a concrete value, take -128. In signed 16 bits this would be 0xff80. If
2010
- * you do out the computations:
2011
- *
2012
- * 0xffff - 128 + 1
2013
- * 0xffff - 127
2014
- * 0xff80
2015
- *
2016
- * You can then encode this value as the signed version. This is really rather
2017
- * hacky, but it should work and get the job done which is our goal here.
2018
- */
2019
-
2020
- /*
2021
- * A series of checks to make sure we actually have a signed 32-bit number
2022
- */
2023
- function verifsint(value, max, min) {
2024
- assert.ok(typeof (value) == 'number',
2025
- 'cannot write a non-number as a number');
2026
-
2027
- assert.ok(value <= max, 'value larger than maximum allowed value');
2028
-
2029
- assert.ok(value >= min, 'value smaller than minimum allowed value');
2030
-
2031
- assert.ok(Math.floor(value) === value, 'value has a fractional component');
2032
- }
2033
-
2034
- function verifIEEE754(value, max, min) {
2035
- assert.ok(typeof (value) == 'number',
2036
- 'cannot write a non-number as a number');
2037
-
2038
- assert.ok(value <= max, 'value larger than maximum allowed value');
2039
-
2040
- assert.ok(value >= min, 'value smaller than minimum allowed value');
2041
- }
2042
-
2043
- Buffer.prototype.writeInt8 = function(value, offset, noAssert) {
2044
- var buffer = this;
2045
-
2046
- if (!noAssert) {
2047
- assert.ok(value !== undefined && value !== null,
2048
- 'missing value');
2049
-
2050
- assert.ok(offset !== undefined && offset !== null,
2051
- 'missing offset');
2052
-
2053
- assert.ok(offset < buffer.length,
2054
- 'Trying to write beyond buffer length');
2055
-
2056
- verifsint(value, 0x7f, -0x80);
2057
- }
2058
-
2059
- if (value >= 0) {
2060
- buffer.writeUInt8(value, offset, noAssert);
2061
- } else {
2062
- buffer.writeUInt8(0xff + value + 1, offset, noAssert);
2063
- }
2064
- };
2065
-
2066
- function writeInt16(buffer, value, offset, isBigEndian, noAssert) {
2067
- if (!noAssert) {
2068
- assert.ok(value !== undefined && value !== null,
2069
- 'missing value');
2070
-
2071
- assert.ok(typeof (isBigEndian) === 'boolean',
2072
- 'missing or invalid endian');
2073
-
2074
- assert.ok(offset !== undefined && offset !== null,
2075
- 'missing offset');
2076
-
2077
- assert.ok(offset + 1 < buffer.length,
2078
- 'Trying to write beyond buffer length');
2079
-
2080
- verifsint(value, 0x7fff, -0x8000);
2081
- }
2082
-
2083
- if (value >= 0) {
2084
- writeUInt16(buffer, value, offset, isBigEndian, noAssert);
2085
- } else {
2086
- writeUInt16(buffer, 0xffff + value + 1, offset, isBigEndian, noAssert);
2087
- }
2088
- }
2089
-
2090
- Buffer.prototype.writeInt16LE = function(value, offset, noAssert) {
2091
- writeInt16(this, value, offset, false, noAssert);
2092
- };
2093
-
2094
- Buffer.prototype.writeInt16BE = function(value, offset, noAssert) {
2095
- writeInt16(this, value, offset, true, noAssert);
2096
- };
2097
-
2098
- function writeInt32(buffer, value, offset, isBigEndian, noAssert) {
2099
- if (!noAssert) {
2100
- assert.ok(value !== undefined && value !== null,
2101
- 'missing value');
2102
-
2103
- assert.ok(typeof (isBigEndian) === 'boolean',
2104
- 'missing or invalid endian');
2105
-
2106
- assert.ok(offset !== undefined && offset !== null,
2107
- 'missing offset');
2108
-
2109
- assert.ok(offset + 3 < buffer.length,
2110
- 'Trying to write beyond buffer length');
2111
-
2112
- verifsint(value, 0x7fffffff, -0x80000000);
2113
- }
2114
-
2115
- if (value >= 0) {
2116
- writeUInt32(buffer, value, offset, isBigEndian, noAssert);
2117
- } else {
2118
- writeUInt32(buffer, 0xffffffff + value + 1, offset, isBigEndian, noAssert);
2119
- }
2120
- }
2121
-
2122
- Buffer.prototype.writeInt32LE = function(value, offset, noAssert) {
2123
- writeInt32(this, value, offset, false, noAssert);
2124
- };
2125
-
2126
- Buffer.prototype.writeInt32BE = function(value, offset, noAssert) {
2127
- writeInt32(this, value, offset, true, noAssert);
2128
- };
2129
-
2130
- function writeFloat(buffer, value, offset, isBigEndian, noAssert) {
2131
- if (!noAssert) {
2132
- assert.ok(value !== undefined && value !== null,
2133
- 'missing value');
2134
-
2135
- assert.ok(typeof (isBigEndian) === 'boolean',
2136
- 'missing or invalid endian');
2137
-
2138
- assert.ok(offset !== undefined && offset !== null,
2139
- 'missing offset');
2140
-
2141
- assert.ok(offset + 3 < buffer.length,
2142
- 'Trying to write beyond buffer length');
2143
-
2144
- verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38);
2145
- }
2146
-
2147
- require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian,
2148
- 23, 4);
2149
- }
2150
-
2151
- Buffer.prototype.writeFloatLE = function(value, offset, noAssert) {
2152
- writeFloat(this, value, offset, false, noAssert);
2153
- };
2154
-
2155
- Buffer.prototype.writeFloatBE = function(value, offset, noAssert) {
2156
- writeFloat(this, value, offset, true, noAssert);
2157
- };
2158
-
2159
- function writeDouble(buffer, value, offset, isBigEndian, noAssert) {
2160
- if (!noAssert) {
2161
- assert.ok(value !== undefined && value !== null,
2162
- 'missing value');
2163
-
2164
- assert.ok(typeof (isBigEndian) === 'boolean',
2165
- 'missing or invalid endian');
2166
-
2167
- assert.ok(offset !== undefined && offset !== null,
2168
- 'missing offset');
2169
-
2170
- assert.ok(offset + 7 < buffer.length,
2171
- 'Trying to write beyond buffer length');
2172
-
2173
- verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308);
2174
- }
2175
-
2176
- require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian,
2177
- 52, 8);
2178
- }
2179
-
2180
- Buffer.prototype.writeDoubleLE = function(value, offset, noAssert) {
2181
- writeDouble(this, value, offset, false, noAssert);
2182
- };
2183
-
2184
- Buffer.prototype.writeDoubleBE = function(value, offset, noAssert) {
2185
- writeDouble(this, value, offset, true, noAssert);
2186
- };
2187
-
2188
- },{"./buffer_ieee754":1,"assert":6,"base64-js":4}],"buffer-browserify":[function(require,module,exports){
2189
- module.exports=require('q9TxCC');
2190
- },{}],4:[function(require,module,exports){
2191
- (function (exports) {
2192
- 'use strict';
2193
-
2194
- var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
2195
-
2196
- function b64ToByteArray(b64) {
2197
- var i, j, l, tmp, placeHolders, arr;
2198
-
2199
- if (b64.length % 4 > 0) {
2200
- throw 'Invalid string. Length must be a multiple of 4';
2201
- }
2202
-
2203
- // the number of equal signs (place holders)
2204
- // if there are two placeholders, than the two characters before it
2205
- // represent one byte
2206
- // if there is only one, then the three characters before it represent 2 bytes
2207
- // this is just a cheap hack to not do indexOf twice
2208
- placeHolders = b64.indexOf('=');
2209
- placeHolders = placeHolders > 0 ? b64.length - placeHolders : 0;
2210
-
2211
- // base64 is 4/3 + up to two characters of the original data
2212
- arr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders);
2213
-
2214
- // if there are placeholders, only get up to the last complete 4 chars
2215
- l = placeHolders > 0 ? b64.length - 4 : b64.length;
2216
-
2217
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
2218
- tmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]);
2219
- arr.push((tmp & 0xFF0000) >> 16);
2220
- arr.push((tmp & 0xFF00) >> 8);
2221
- arr.push(tmp & 0xFF);
2222
- }
2223
-
2224
- if (placeHolders === 2) {
2225
- tmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4);
2226
- arr.push(tmp & 0xFF);
2227
- } else if (placeHolders === 1) {
2228
- tmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2);
2229
- arr.push((tmp >> 8) & 0xFF);
2230
- arr.push(tmp & 0xFF);
2231
- }
2232
-
2233
- return arr;
2234
- }
2235
-
2236
- function uint8ToBase64(uint8) {
2237
- var i,
2238
- extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
2239
- output = "",
2240
- temp, length;
2241
-
2242
- function tripletToBase64 (num) {
2243
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];
2244
- };
2245
-
2246
- // go through the array every three bytes, we'll deal with trailing stuff later
2247
- for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
2248
- temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
2249
- output += tripletToBase64(temp);
2250
- }
2251
-
2252
- // pad the end with zeros, but make sure to not forget the extra bytes
2253
- switch (extraBytes) {
2254
- case 1:
2255
- temp = uint8[uint8.length - 1];
2256
- output += lookup[temp >> 2];
2257
- output += lookup[(temp << 4) & 0x3F];
2258
- output += '==';
2259
- break;
2260
- case 2:
2261
- temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);
2262
- output += lookup[temp >> 10];
2263
- output += lookup[(temp >> 4) & 0x3F];
2264
- output += lookup[(temp << 2) & 0x3F];
2265
- output += '=';
2266
- break;
2267
- }
2268
-
2269
- return output;
2270
- }
2271
-
2272
- module.exports.toByteArray = b64ToByteArray;
2273
- module.exports.fromByteArray = uint8ToBase64;
2274
- }());
2275
-
2276
- },{}],5:[function(require,module,exports){
2277
-
2278
-
2279
- //
2280
- // The shims in this file are not fully implemented shims for the ES5
2281
- // features, but do work for the particular usecases there is in
2282
- // the other modules.
2283
- //
2284
-
2285
- var toString = Object.prototype.toString;
2286
- var hasOwnProperty = Object.prototype.hasOwnProperty;
2287
-
2288
- // Array.isArray is supported in IE9
2289
- function isArray(xs) {
2290
- return toString.call(xs) === '[object Array]';
2291
- }
2292
- exports.isArray = typeof Array.isArray === 'function' ? Array.isArray : isArray;
2293
-
2294
- // Array.prototype.indexOf is supported in IE9
2295
- exports.indexOf = function indexOf(xs, x) {
2296
- if (xs.indexOf) return xs.indexOf(x);
2297
- for (var i = 0; i < xs.length; i++) {
2298
- if (x === xs[i]) return i;
2299
- }
2300
- return -1;
2301
- };
2302
-
2303
- // Array.prototype.filter is supported in IE9
2304
- exports.filter = function filter(xs, fn) {
2305
- if (xs.filter) return xs.filter(fn);
2306
- var res = [];
2307
- for (var i = 0; i < xs.length; i++) {
2308
- if (fn(xs[i], i, xs)) res.push(xs[i]);
2309
- }
2310
- return res;
2311
- };
2312
-
2313
- // Array.prototype.forEach is supported in IE9
2314
- exports.forEach = function forEach(xs, fn, self) {
2315
- if (xs.forEach) return xs.forEach(fn, self);
2316
- for (var i = 0; i < xs.length; i++) {
2317
- fn.call(self, xs[i], i, xs);
2318
- }
2319
- };
2320
-
2321
- // Array.prototype.map is supported in IE9
2322
- exports.map = function map(xs, fn) {
2323
- if (xs.map) return xs.map(fn);
2324
- var out = new Array(xs.length);
2325
- for (var i = 0; i < xs.length; i++) {
2326
- out[i] = fn(xs[i], i, xs);
2327
- }
2328
- return out;
2329
- };
2330
-
2331
- // Array.prototype.reduce is supported in IE9
2332
- exports.reduce = function reduce(array, callback, opt_initialValue) {
2333
- if (array.reduce) return array.reduce(callback, opt_initialValue);
2334
- var value, isValueSet = false;
2335
-
2336
- if (2 < arguments.length) {
2337
- value = opt_initialValue;
2338
- isValueSet = true;
2339
- }
2340
- for (var i = 0, l = array.length; l > i; ++i) {
2341
- if (array.hasOwnProperty(i)) {
2342
- if (isValueSet) {
2343
- value = callback(value, array[i], i, array);
2344
- }
2345
- else {
2346
- value = array[i];
2347
- isValueSet = true;
2348
- }
2349
- }
2350
- }
2351
-
2352
- return value;
2353
- };
2354
-
2355
- // String.prototype.substr - negative index don't work in IE8
2356
- if ('ab'.substr(-1) !== 'b') {
2357
- exports.substr = function (str, start, length) {
2358
- // did we get a negative start, calculate how much it is from the beginning of the string
2359
- if (start < 0) start = str.length + start;
2360
-
2361
- // call the original function
2362
- return str.substr(start, length);
2363
- };
2364
- } else {
2365
- exports.substr = function (str, start, length) {
2366
- return str.substr(start, length);
2367
- };
2368
- }
2369
-
2370
- // String.prototype.trim is supported in IE9
2371
- exports.trim = function (str) {
2372
- if (str.trim) return str.trim();
2373
- return str.replace(/^\s+|\s+$/g, '');
2374
- };
2375
-
2376
- // Function.prototype.bind is supported in IE9
2377
- exports.bind = function () {
2378
- var args = Array.prototype.slice.call(arguments);
2379
- var fn = args.shift();
2380
- if (fn.bind) return fn.bind.apply(fn, args);
2381
- var self = args.shift();
2382
- return function () {
2383
- fn.apply(self, args.concat([Array.prototype.slice.call(arguments)]));
2384
- };
2385
- };
2386
-
2387
- // Object.create is supported in IE9
2388
- function create(prototype, properties) {
2389
- var object;
2390
- if (prototype === null) {
2391
- object = { '__proto__' : null };
2392
- }
2393
- else {
2394
- if (typeof prototype !== 'object') {
2395
- throw new TypeError(
2396
- 'typeof prototype[' + (typeof prototype) + '] != \'object\''
2397
- );
2398
- }
2399
- var Type = function () {};
2400
- Type.prototype = prototype;
2401
- object = new Type();
2402
- object.__proto__ = prototype;
2403
- }
2404
- if (typeof properties !== 'undefined' && Object.defineProperties) {
2405
- Object.defineProperties(object, properties);
2406
- }
2407
- return object;
2408
- }
2409
- exports.create = typeof Object.create === 'function' ? Object.create : create;
2410
-
2411
- // Object.keys and Object.getOwnPropertyNames is supported in IE9 however
2412
- // they do show a description and number property on Error objects
2413
- function notObject(object) {
2414
- return ((typeof object != "object" && typeof object != "function") || object === null);
2415
- }
2416
-
2417
- function keysShim(object) {
2418
- if (notObject(object)) {
2419
- throw new TypeError("Object.keys called on a non-object");
2420
- }
2421
-
2422
- var result = [];
2423
- for (var name in object) {
2424
- if (hasOwnProperty.call(object, name)) {
2425
- result.push(name);
2426
- }
2427
- }
2428
- return result;
2429
- }
2430
-
2431
- // getOwnPropertyNames is almost the same as Object.keys one key feature
2432
- // is that it returns hidden properties, since that can't be implemented,
2433
- // this feature gets reduced so it just shows the length property on arrays
2434
- function propertyShim(object) {
2435
- if (notObject(object)) {
2436
- throw new TypeError("Object.getOwnPropertyNames called on a non-object");
2437
- }
2438
-
2439
- var result = keysShim(object);
2440
- if (exports.isArray(object) && exports.indexOf(object, 'length') === -1) {
2441
- result.push('length');
2442
- }
2443
- return result;
2444
- }
2445
-
2446
- var keys = typeof Object.keys === 'function' ? Object.keys : keysShim;
2447
- var getOwnPropertyNames = typeof Object.getOwnPropertyNames === 'function' ?
2448
- Object.getOwnPropertyNames : propertyShim;
2449
-
2450
- if (new Error().hasOwnProperty('description')) {
2451
- var ERROR_PROPERTY_FILTER = function (obj, array) {
2452
- if (toString.call(obj) === '[object Error]') {
2453
- array = exports.filter(array, function (name) {
2454
- return name !== 'description' && name !== 'number' && name !== 'message';
2455
- });
2456
- }
2457
- return array;
2458
- };
2459
-
2460
- exports.keys = function (object) {
2461
- return ERROR_PROPERTY_FILTER(object, keys(object));
2462
- };
2463
- exports.getOwnPropertyNames = function (object) {
2464
- return ERROR_PROPERTY_FILTER(object, getOwnPropertyNames(object));
2465
- };
2466
- } else {
2467
- exports.keys = keys;
2468
- exports.getOwnPropertyNames = getOwnPropertyNames;
2469
- }
2470
-
2471
- // Object.getOwnPropertyDescriptor - supported in IE8 but only on dom elements
2472
- function valueObject(value, key) {
2473
- return { value: value[key] };
2474
- }
2475
-
2476
- if (typeof Object.getOwnPropertyDescriptor === 'function') {
2477
- try {
2478
- Object.getOwnPropertyDescriptor({'a': 1}, 'a');
2479
- exports.getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2480
- } catch (e) {
2481
- // IE8 dom element issue - use a try catch and default to valueObject
2482
- exports.getOwnPropertyDescriptor = function (value, key) {
2483
- try {
2484
- return Object.getOwnPropertyDescriptor(value, key);
2485
- } catch (e) {
2486
- return valueObject(value, key);
2487
- }
2488
- };
2489
- }
2490
- } else {
2491
- exports.getOwnPropertyDescriptor = valueObject;
2492
- }
2493
-
2494
- },{}],6:[function(require,module,exports){
2495
- // Copyright Joyent, Inc. and other Node contributors.
2496
- //
2497
- // Permission is hereby granted, free of charge, to any person obtaining a
2498
- // copy of this software and associated documentation files (the
2499
- // "Software"), to deal in the Software without restriction, including
2500
- // without limitation the rights to use, copy, modify, merge, publish,
2501
- // distribute, sublicense, and/or sell copies of the Software, and to permit
2502
- // persons to whom the Software is furnished to do so, subject to the
2503
- // following conditions:
2504
- //
2505
- // The above copyright notice and this permission notice shall be included
2506
- // in all copies or substantial portions of the Software.
2507
- //
2508
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2509
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2510
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2511
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2512
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2513
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2514
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
2515
-
2516
- // UTILITY
2517
- var util = require('util');
2518
- var shims = require('_shims');
2519
- var pSlice = Array.prototype.slice;
2520
-
2521
- // 1. The assert module provides functions that throw
2522
- // AssertionError's when particular conditions are not met. The
2523
- // assert module must conform to the following interface.
2524
-
2525
- var assert = module.exports = ok;
2526
-
2527
- // 2. The AssertionError is defined in assert.
2528
- // new assert.AssertionError({ message: message,
2529
- // actual: actual,
2530
- // expected: expected })
2531
-
2532
- assert.AssertionError = function AssertionError(options) {
2533
- this.name = 'AssertionError';
2534
- this.actual = options.actual;
2535
- this.expected = options.expected;
2536
- this.operator = options.operator;
2537
- this.message = options.message || getMessage(this);
2538
- };
2539
-
2540
- // assert.AssertionError instanceof Error
2541
- util.inherits(assert.AssertionError, Error);
2542
-
2543
- function replacer(key, value) {
2544
- if (util.isUndefined(value)) {
2545
- return '' + value;
2546
- }
2547
- if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
2548
- return value.toString();
2549
- }
2550
- if (util.isFunction(value) || util.isRegExp(value)) {
2551
- return value.toString();
2552
- }
2553
- return value;
2554
- }
2555
-
2556
- function truncate(s, n) {
2557
- if (util.isString(s)) {
2558
- return s.length < n ? s : s.slice(0, n);
2559
- } else {
2560
- return s;
2561
- }
2562
- }
2563
-
2564
- function getMessage(self) {
2565
- return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
2566
- self.operator + ' ' +
2567
- truncate(JSON.stringify(self.expected, replacer), 128);
2568
- }
2569
-
2570
- // At present only the three keys mentioned above are used and
2571
- // understood by the spec. Implementations or sub modules can pass
2572
- // other keys to the AssertionError's constructor - they will be
2573
- // ignored.
2574
-
2575
- // 3. All of the following functions must throw an AssertionError
2576
- // when a corresponding condition is not met, with a message that
2577
- // may be undefined if not provided. All assertion methods provide
2578
- // both the actual and expected values to the assertion error for
2579
- // display purposes.
2580
-
2581
- function fail(actual, expected, message, operator, stackStartFunction) {
2582
- throw new assert.AssertionError({
2583
- message: message,
2584
- actual: actual,
2585
- expected: expected,
2586
- operator: operator,
2587
- stackStartFunction: stackStartFunction
2588
- });
2589
- }
2590
-
2591
- // EXTENSION! allows for well behaved errors defined elsewhere.
2592
- assert.fail = fail;
2593
-
2594
- // 4. Pure assertion tests whether a value is truthy, as determined
2595
- // by !!guard.
2596
- // assert.ok(guard, message_opt);
2597
- // This statement is equivalent to assert.equal(true, !!guard,
2598
- // message_opt);. To test strictly for the value true, use
2599
- // assert.strictEqual(true, guard, message_opt);.
2600
-
2601
- function ok(value, message) {
2602
- if (!value) fail(value, true, message, '==', assert.ok);
2603
- }
2604
- assert.ok = ok;
2605
-
2606
- // 5. The equality assertion tests shallow, coercive equality with
2607
- // ==.
2608
- // assert.equal(actual, expected, message_opt);
2609
-
2610
- assert.equal = function equal(actual, expected, message) {
2611
- if (actual != expected) fail(actual, expected, message, '==', assert.equal);
2612
- };
2613
-
2614
- // 6. The non-equality assertion tests for whether two objects are not equal
2615
- // with != assert.notEqual(actual, expected, message_opt);
2616
-
2617
- assert.notEqual = function notEqual(actual, expected, message) {
2618
- if (actual == expected) {
2619
- fail(actual, expected, message, '!=', assert.notEqual);
2620
- }
2621
- };
2622
-
2623
- // 7. The equivalence assertion tests a deep equality relation.
2624
- // assert.deepEqual(actual, expected, message_opt);
2625
-
2626
- assert.deepEqual = function deepEqual(actual, expected, message) {
2627
- if (!_deepEqual(actual, expected)) {
2628
- fail(actual, expected, message, 'deepEqual', assert.deepEqual);
2629
- }
2630
- };
2631
-
2632
- function _deepEqual(actual, expected) {
2633
- // 7.1. All identical values are equivalent, as determined by ===.
2634
- if (actual === expected) {
2635
- return true;
2636
-
2637
- } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
2638
- if (actual.length != expected.length) return false;
2639
-
2640
- for (var i = 0; i < actual.length; i++) {
2641
- if (actual[i] !== expected[i]) return false;
2642
- }
2643
-
2644
- return true;
2645
-
2646
- // 7.2. If the expected value is a Date object, the actual value is
2647
- // equivalent if it is also a Date object that refers to the same time.
2648
- } else if (util.isDate(actual) && util.isDate(expected)) {
2649
- return actual.getTime() === expected.getTime();
2650
-
2651
- // 7.3 If the expected value is a RegExp object, the actual value is
2652
- // equivalent if it is also a RegExp object with the same source and
2653
- // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
2654
- } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
2655
- return actual.source === expected.source &&
2656
- actual.global === expected.global &&
2657
- actual.multiline === expected.multiline &&
2658
- actual.lastIndex === expected.lastIndex &&
2659
- actual.ignoreCase === expected.ignoreCase;
2660
-
2661
- // 7.4. Other pairs that do not both pass typeof value == 'object',
2662
- // equivalence is determined by ==.
2663
- } else if (!util.isObject(actual) && !util.isObject(expected)) {
2664
- return actual == expected;
2665
-
2666
- // 7.5 For all other Object pairs, including Array objects, equivalence is
2667
- // determined by having the same number of owned properties (as verified
2668
- // with Object.prototype.hasOwnProperty.call), the same set of keys
2669
- // (although not necessarily the same order), equivalent values for every
2670
- // corresponding key, and an identical 'prototype' property. Note: this
2671
- // accounts for both named and indexed properties on Arrays.
2672
- } else {
2673
- return objEquiv(actual, expected);
2674
- }
2675
- }
2676
-
2677
- function isArguments(object) {
2678
- return Object.prototype.toString.call(object) == '[object Arguments]';
2679
- }
2680
-
2681
- function objEquiv(a, b) {
2682
- if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
2683
- return false;
2684
- // an identical 'prototype' property.
2685
- if (a.prototype !== b.prototype) return false;
2686
- //~~~I've managed to break Object.keys through screwy arguments passing.
2687
- // Converting to array solves the problem.
2688
- if (isArguments(a)) {
2689
- if (!isArguments(b)) {
2690
- return false;
2691
- }
2692
- a = pSlice.call(a);
2693
- b = pSlice.call(b);
2694
- return _deepEqual(a, b);
2695
- }
2696
- try {
2697
- var ka = shims.keys(a),
2698
- kb = shims.keys(b),
2699
- key, i;
2700
- } catch (e) {//happens when one is a string literal and the other isn't
2701
- return false;
2702
- }
2703
- // having the same number of owned properties (keys incorporates
2704
- // hasOwnProperty)
2705
- if (ka.length != kb.length)
2706
- return false;
2707
- //the same set of keys (although not necessarily the same order),
2708
- ka.sort();
2709
- kb.sort();
2710
- //~~~cheap key test
2711
- for (i = ka.length - 1; i >= 0; i--) {
2712
- if (ka[i] != kb[i])
2713
- return false;
2714
- }
2715
- //equivalent values for every corresponding key, and
2716
- //~~~possibly expensive deep test
2717
- for (i = ka.length - 1; i >= 0; i--) {
2718
- key = ka[i];
2719
- if (!_deepEqual(a[key], b[key])) return false;
2720
- }
2721
- return true;
2722
- }
2723
-
2724
- // 8. The non-equivalence assertion tests for any deep inequality.
2725
- // assert.notDeepEqual(actual, expected, message_opt);
2726
-
2727
- assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
2728
- if (_deepEqual(actual, expected)) {
2729
- fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
2730
- }
2731
- };
2732
-
2733
- // 9. The strict equality assertion tests strict equality, as determined by ===.
2734
- // assert.strictEqual(actual, expected, message_opt);
2735
-
2736
- assert.strictEqual = function strictEqual(actual, expected, message) {
2737
- if (actual !== expected) {
2738
- fail(actual, expected, message, '===', assert.strictEqual);
2739
- }
2740
- };
2741
-
2742
- // 10. The strict non-equality assertion tests for strict inequality, as
2743
- // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
2744
-
2745
- assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
2746
- if (actual === expected) {
2747
- fail(actual, expected, message, '!==', assert.notStrictEqual);
2748
- }
2749
- };
2750
-
2751
- function expectedException(actual, expected) {
2752
- if (!actual || !expected) {
2753
- return false;
2754
- }
2755
-
2756
- if (Object.prototype.toString.call(expected) == '[object RegExp]') {
2757
- return expected.test(actual);
2758
- } else if (actual instanceof expected) {
2759
- return true;
2760
- } else if (expected.call({}, actual) === true) {
2761
- return true;
2762
- }
2763
-
2764
- return false;
2765
- }
2766
-
2767
- function _throws(shouldThrow, block, expected, message) {
2768
- var actual;
2769
-
2770
- if (util.isString(expected)) {
2771
- message = expected;
2772
- expected = null;
2773
- }
2774
-
2775
- try {
2776
- block();
2777
- } catch (e) {
2778
- actual = e;
2779
- }
2780
-
2781
- message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
2782
- (message ? ' ' + message : '.');
2783
-
2784
- if (shouldThrow && !actual) {
2785
- fail(actual, expected, 'Missing expected exception' + message);
2786
- }
2787
-
2788
- if (!shouldThrow && expectedException(actual, expected)) {
2789
- fail(actual, expected, 'Got unwanted exception' + message);
2790
- }
2791
-
2792
- if ((shouldThrow && actual && expected &&
2793
- !expectedException(actual, expected)) || (!shouldThrow && actual)) {
2794
- throw actual;
2795
- }
2796
- }
2797
-
2798
- // 11. Expected to throw an error:
2799
- // assert.throws(block, Error_opt, message_opt);
2800
-
2801
- assert.throws = function(block, /*optional*/error, /*optional*/message) {
2802
- _throws.apply(this, [true].concat(pSlice.call(arguments)));
2803
- };
2804
-
2805
- // EXTENSION! This is annoying to write outside this module.
2806
- assert.doesNotThrow = function(block, /*optional*/message) {
2807
- _throws.apply(this, [false].concat(pSlice.call(arguments)));
2808
- };
2809
-
2810
- assert.ifError = function(err) { if (err) {throw err;}};
2811
- },{"_shims":5,"util":7}],7:[function(require,module,exports){
433
+ },{"__browserify_process":4,"_shims":1,"util":3}],3:[function(require,module,exports){
2812
434
  // Copyright Joyent, Inc. and other Node contributors.
2813
435
  //
2814
436
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -3275,7 +897,11 @@ function isPrimitive(arg) {
3275
897
  exports.isPrimitive = isPrimitive;
3276
898
 
3277
899
  function isBuffer(arg) {
3278
- return arg instanceof Buffer;
900
+ return arg && typeof arg === 'object'
901
+ && typeof arg.copy === 'function'
902
+ && typeof arg.fill === 'function'
903
+ && typeof arg.binarySlice === 'function'
904
+ ;
3279
905
  }
3280
906
  exports.isBuffer = isBuffer;
3281
907
 
@@ -3349,10 +975,7 @@ function hasOwnProperty(obj, prop) {
3349
975
  return Object.prototype.hasOwnProperty.call(obj, prop);
3350
976
  }
3351
977
 
3352
- },{"_shims":5}]},{},[])
3353
- ;;module.exports=require("buffer-browserify")
3354
-
3355
- },{}],5:[function(require,module,exports){
978
+ },{"_shims":1}],4:[function(require,module,exports){
3356
979
  // shim for using process in browser
3357
980
 
3358
981
  var process = module.exports = {};
@@ -3406,7 +1029,7 @@ process.chdir = function (dir) {
3406
1029
  throw new Error('process.chdir is not supported');
3407
1030
  };
3408
1031
 
3409
- },{}],6:[function(require,module,exports){
1032
+ },{}],5:[function(require,module,exports){
3410
1033
  /*
3411
1034
  Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
3412
1035
  Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
@@ -3454,6 +1077,7 @@ parseStatement: true, parseSourceElement: true, parseModuleBlock: true, parseCon
3454
1077
  advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
3455
1078
  scanXJSStringLiteral: true, scanXJSIdentifier: true,
3456
1079
  parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
1080
+ parseTypeAnnotation: true, parseTypeAnnotatableIdentifier: true,
3457
1081
  parseYieldExpression: true
3458
1082
  */
3459
1083
 
@@ -5096,61 +2720,63 @@ parseYieldExpression: true
5096
2720
  },
5097
2721
 
5098
2722
  createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
5099
- returnTypeAnnotation) {
2723
+ returnType) {
5100
2724
  return {
5101
2725
  type: Syntax.FunctionDeclaration,
5102
2726
  id: id,
5103
2727
  params: params,
5104
2728
  defaults: defaults,
5105
- returnType: returnTypeAnnotation,
5106
2729
  body: body,
5107
2730
  rest: rest,
5108
2731
  generator: generator,
5109
- expression: expression
2732
+ expression: expression,
2733
+ returnType: returnType
5110
2734
  };
5111
2735
  },
5112
2736
 
5113
2737
  createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
5114
- returnTypeAnnotation) {
2738
+ returnType) {
5115
2739
  return {
5116
2740
  type: Syntax.FunctionExpression,
5117
2741
  id: id,
5118
2742
  params: params,
5119
2743
  defaults: defaults,
5120
- returnType: returnTypeAnnotation,
5121
2744
  body: body,
5122
2745
  rest: rest,
5123
2746
  generator: generator,
5124
- expression: expression
2747
+ expression: expression,
2748
+ returnType: returnType
5125
2749
  };
5126
2750
  },
5127
2751
 
5128
2752
  createIdentifier: function (name) {
5129
2753
  return {
5130
2754
  type: Syntax.Identifier,
5131
- name: name
2755
+ name: name,
2756
+ // Only here to initialize the shape of the object to ensure
2757
+ // that the 'typeAnnotation' key is ordered before others that
2758
+ // are added later (like 'loc' and 'range'). This just helps
2759
+ // keep the shape of Identifier nodes consistent with everything
2760
+ // else.
2761
+ typeAnnotation: undefined
5132
2762
  };
5133
2763
  },
5134
2764
 
5135
- createTypeAnnotatedIdentifier: function (annotation, identifier) {
2765
+ createTypeAnnotation: function (typeIdentifier, paramTypes, returnType, isNullable) {
5136
2766
  return {
5137
- type: Syntax.TypeAnnotatedIdentifier,
5138
- annotation: annotation,
5139
- identifier: identifier
2767
+ type: Syntax.TypeAnnotation,
2768
+ id: typeIdentifier,
2769
+ paramTypes: paramTypes,
2770
+ returnType: returnType,
2771
+ isNullable: isNullable
5140
2772
  };
5141
2773
  },
5142
2774
 
5143
- createTypeAnnotation: function (annotatedType, templateTypes,
5144
- paramTypes, returnType, unionType,
5145
- nullable) {
2775
+ createTypeAnnotatedIdentifier: function (identifier, annotation) {
5146
2776
  return {
5147
- type: Syntax.TypeAnnotation,
5148
- annotatedType: annotatedType,
5149
- templateTypes: templateTypes,
5150
- paramTypes: paramTypes,
5151
- returnType: returnType,
5152
- unionType: unionType,
5153
- nullable: nullable
2777
+ type: Syntax.TypeAnnotatedIdentifier,
2778
+ id: identifier,
2779
+ annotation: annotation
5154
2780
  };
5155
2781
  },
5156
2782
 
@@ -5481,11 +3107,10 @@ parseYieldExpression: true
5481
3107
  };
5482
3108
  },
5483
3109
 
5484
- createExportDeclaration: function (def, declaration, specifiers, source) {
3110
+ createExportDeclaration: function (declaration, specifiers, source) {
5485
3111
  return {
5486
3112
  type: Syntax.ExportDeclaration,
5487
3113
  declaration: declaration,
5488
- default: def,
5489
3114
  specifiers: specifiers,
5490
3115
  source: source
5491
3116
  };
@@ -5879,7 +3504,7 @@ parseYieldExpression: true
5879
3504
  key = parseObjectPropertyKey();
5880
3505
  expect('(');
5881
3506
  token = lookahead;
5882
- param = [ parseVariableIdentifier() ];
3507
+ param = [ parseTypeAnnotatableIdentifier() ];
5883
3508
  expect(')');
5884
3509
  return delegate.createProperty('set', key, parsePropertyFunction({ params: param, generator: false, name: token }), false, false);
5885
3510
  }
@@ -6690,108 +4315,68 @@ parseYieldExpression: true
6690
4315
 
6691
4316
  // 12.2 Variable Statement
6692
4317
 
6693
- function parseVariableIdentifier() {
6694
- var token = lex();
4318
+ function parseTypeAnnotation(dontExpectColon) {
4319
+ var typeIdentifier = null, paramTypes = null, returnType = null,
4320
+ isNullable = false;
6695
4321
 
6696
- if (token.type !== Token.Identifier) {
6697
- throwUnexpected(token);
4322
+ if (!dontExpectColon) {
4323
+ expect(':');
6698
4324
  }
6699
4325
 
6700
- return delegate.createIdentifier(token.value);
6701
- }
6702
-
6703
- function parseTypeAnnotation() {
6704
- var isNullable = false, paramTypes = null, returnType = null,
6705
- templateTypes = null, type, unionType = null;
6706
-
6707
4326
  if (match('?')) {
6708
4327
  lex();
6709
4328
  isNullable = true;
6710
4329
  }
6711
4330
 
6712
- type = parseVariableIdentifier();
6713
-
6714
- if (match('<')) {
6715
- lex();
6716
- templateTypes = [];
6717
- while (lookahead.type === Token.Identifier || match('?')) {
6718
- templateTypes.push(parseTypeAnnotation());
6719
- if (!match('>')) {
6720
- expect(',');
6721
- }
6722
- }
6723
- expect('>');
4331
+ if (lookahead.type === Token.Identifier) {
4332
+ typeIdentifier = parseVariableIdentifier();
6724
4333
  }
6725
4334
 
6726
4335
  if (match('(')) {
6727
4336
  lex();
6728
4337
  paramTypes = [];
6729
4338
  while (lookahead.type === Token.Identifier || match('?')) {
6730
- paramTypes.push(parseTypeAnnotation());
4339
+ paramTypes.push(parseTypeAnnotation(true));
6731
4340
  if (!match(')')) {
6732
4341
  expect(',');
6733
4342
  }
6734
4343
  }
6735
4344
  expect(')');
4345
+ expect('=>');
6736
4346
 
6737
- if (match(':')) {
4347
+ if (matchKeyword('void')) {
6738
4348
  lex();
6739
- returnType = parseTypeAnnotation();
4349
+ } else {
4350
+ returnType = parseTypeAnnotation(true);
6740
4351
  }
6741
4352
  }
6742
4353
 
6743
- if (match('|')) {
6744
- lex();
6745
- unionType = parseTypeAnnotation();
6746
- }
6747
-
6748
4354
  return delegate.createTypeAnnotation(
6749
- type,
6750
- templateTypes,
4355
+ typeIdentifier,
6751
4356
  paramTypes,
6752
4357
  returnType,
6753
- unionType,
6754
4358
  isNullable
6755
4359
  );
6756
4360
  }
6757
4361
 
6758
- function parseAnnotatableIdentifier() {
6759
- var annotation, annotationLookahead, annotationPresent, identifier,
6760
- matchesNullableToken;
6761
-
6762
- matchesNullableToken = match('?');
6763
-
6764
- if (lookahead.type !== Token.Identifier && !matchesNullableToken) {
6765
- throwUnexpected(lookahead);
6766
- }
4362
+ function parseVariableIdentifier() {
4363
+ var token = lex();
6767
4364
 
6768
- if (!matchesNullableToken) {
6769
- annotationLookahead = lookahead2();
4365
+ if (token.type !== Token.Identifier) {
4366
+ throwUnexpected(token);
6770
4367
  }
6771
4368
 
6772
- annotationPresent =
6773
- matchesNullableToken
6774
-
6775
- // function (number numVal) {}
6776
- || annotationLookahead.type === Token.Identifier
4369
+ return delegate.createIdentifier(token.value);
4370
+ }
6777
4371
 
6778
- // function (fn(number)|array<number|string> param) {}
6779
- || (annotationLookahead.type === Token.Punctuator
6780
- && (annotationLookahead.value === '('
6781
- || annotationLookahead.value === '<'
6782
- || annotationLookahead.value === '|'));
4372
+ function parseTypeAnnotatableIdentifier() {
4373
+ var ident = parseVariableIdentifier();
6783
4374
 
6784
- if (!annotationPresent) {
6785
- return parseVariableIdentifier();
4375
+ if (match(':')) {
4376
+ return delegate.createTypeAnnotatedIdentifier(ident, parseTypeAnnotation());
6786
4377
  }
6787
4378
 
6788
- annotation = parseTypeAnnotation();
6789
- identifier = parseVariableIdentifier();
6790
-
6791
- return delegate.createTypeAnnotatedIdentifier(
6792
- annotation,
6793
- identifier
6794
- );
4379
+ return ident;
6795
4380
  }
6796
4381
 
6797
4382
  function parseVariableDeclaration(kind) {
@@ -6804,11 +4389,7 @@ parseYieldExpression: true
6804
4389
  id = parseArrayInitialiser();
6805
4390
  reinterpretAsAssignmentBindingPattern(id);
6806
4391
  } else {
6807
- if (state.allowDefault) {
6808
- id = matchKeyword('default') ? parseNonComputedProperty() : parseVariableIdentifier();
6809
- } else {
6810
- id = parseVariableIdentifier();
6811
- }
4392
+ id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
6812
4393
  // 12.2.1
6813
4394
  if (strict && isRestrictedWord(id.name)) {
6814
4395
  throwErrorTolerant({}, Messages.StrictVarName);
@@ -6926,36 +4507,10 @@ parseYieldExpression: true
6926
4507
  }
6927
4508
 
6928
4509
  function parseExportDeclaration() {
6929
- var previousAllowDefault, decl, def, src, specifiers;
4510
+ var previousAllowKeyword, decl, def, src, specifiers;
6930
4511
 
6931
4512
  expectKeyword('export');
6932
4513
 
6933
- if (matchKeyword('default')) {
6934
- lex();
6935
- if (match('=')) {
6936
- lex();
6937
- def = parseAssignmentExpression();
6938
- } else if (lookahead.type === Token.Keyword) {
6939
- switch (lookahead.value) {
6940
- case 'let':
6941
- case 'const':
6942
- case 'var':
6943
- case 'class':
6944
- def = parseSourceElement();
6945
- break;
6946
- case 'function':
6947
- def = parseFunctionExpression();
6948
- break;
6949
- default:
6950
- throwUnexpected(lex());
6951
- }
6952
- } else {
6953
- def = parseAssignmentExpression();
6954
- }
6955
- consumeSemicolon();
6956
- return delegate.createExportDeclaration(true, def, null, null);
6957
- }
6958
-
6959
4514
  if (lookahead.type === Token.Keyword) {
6960
4515
  switch (lookahead.value) {
6961
4516
  case 'let':
@@ -6963,13 +4518,16 @@ parseYieldExpression: true
6963
4518
  case 'var':
6964
4519
  case 'class':
6965
4520
  case 'function':
6966
- previousAllowDefault = state.allowDefault;
6967
- state.allowDefault = true;
6968
- decl = delegate.createExportDeclaration(false, parseSourceElement(), null, null);
6969
- state.allowDefault = previousAllowDefault;
6970
- return decl;
4521
+ return delegate.createExportDeclaration(parseSourceElement(), null, null);
6971
4522
  }
6972
- throwUnexpected(lex());
4523
+ }
4524
+
4525
+ if (isIdentifierName(lookahead)) {
4526
+ previousAllowKeyword = state.allowKeyword;
4527
+ state.allowKeyword = true;
4528
+ decl = parseVariableDeclarationList('let');
4529
+ state.allowKeyword = previousAllowKeyword;
4530
+ return delegate.createExportDeclaration(decl, null, null);
6973
4531
  }
6974
4532
 
6975
4533
  specifiers = [];
@@ -6995,7 +4553,7 @@ parseYieldExpression: true
6995
4553
 
6996
4554
  consumeSemicolon();
6997
4555
 
6998
- return delegate.createExportDeclaration(false, null, specifiers, src);
4556
+ return delegate.createExportDeclaration(null, specifiers, src);
6999
4557
  }
7000
4558
 
7001
4559
  function parseImportDeclaration() {
@@ -7733,12 +5291,10 @@ parseYieldExpression: true
7733
5291
  param = parseObjectInitialiser();
7734
5292
  reinterpretAsDestructuredParameter(options, param);
7735
5293
  } else {
7736
- // We don't currently support typed rest params because doing so is
7737
- // a bit awkward. We may come back to this, but for now we'll punt
7738
- // on it.
5294
+ // Typing rest params is awkward, so punting on that for now
7739
5295
  param = rest
7740
5296
  ? parseVariableIdentifier()
7741
- : parseAnnotatableIdentifier();
5297
+ : parseTypeAnnotatableIdentifier();
7742
5298
  validateParam(options, token, token.value);
7743
5299
  if (match('=')) {
7744
5300
  if (rest) {
@@ -7793,7 +5349,6 @@ parseYieldExpression: true
7793
5349
  }
7794
5350
 
7795
5351
  if (match(':')) {
7796
- lex();
7797
5352
  options.returnTypeAnnotation = parseTypeAnnotation();
7798
5353
  }
7799
5354
 
@@ -7813,11 +5368,8 @@ parseYieldExpression: true
7813
5368
 
7814
5369
  token = lookahead;
7815
5370
 
7816
- if (state.allowDefault) {
7817
- id = matchKeyword('default') ? parseNonComputedProperty() : parseVariableIdentifier();
7818
- } else {
7819
- id = parseVariableIdentifier();
7820
- }
5371
+ id = parseVariableIdentifier();
5372
+
7821
5373
  if (strict) {
7822
5374
  if (isRestrictedWord(token.value)) {
7823
5375
  throwErrorTolerant(token, Messages.StrictFunctionName);
@@ -8025,7 +5577,7 @@ parseYieldExpression: true
8025
5577
 
8026
5578
  expect('(');
8027
5579
  token = lookahead;
8028
- param = [ parseVariableIdentifier() ];
5580
+ param = [ parseTypeAnnotatableIdentifier() ];
8029
5581
  expect(')');
8030
5582
  return delegate.createMethodDefinition(
8031
5583
  propType,
@@ -8109,11 +5661,7 @@ parseYieldExpression: true
8109
5661
 
8110
5662
  expectKeyword('class');
8111
5663
 
8112
- if (state.allowDefault) {
8113
- id = matchKeyword('default') ? parseNonComputedProperty() : parseVariableIdentifier();
8114
- } else {
8115
- id = parseVariableIdentifier();
8116
- }
5664
+ id = parseVariableIdentifier();
8117
5665
 
8118
5666
  if (matchKeyword('extends')) {
8119
5667
  expectKeyword('extends');
@@ -9377,13 +6925,13 @@ parseYieldExpression: true
9377
6925
  extra.parseSpreadOrAssignmentExpression = parseSpreadOrAssignmentExpression;
9378
6926
  extra.parseTemplateElement = parseTemplateElement;
9379
6927
  extra.parseTemplateLiteral = parseTemplateLiteral;
6928
+ extra.parseTypeAnnotatableIdentifier = parseTypeAnnotatableIdentifier;
6929
+ extra.parseTypeAnnotation = parseTypeAnnotation;
9380
6930
  extra.parseStatement = parseStatement;
9381
6931
  extra.parseSwitchCase = parseSwitchCase;
9382
6932
  extra.parseUnaryExpression = parseUnaryExpression;
9383
6933
  extra.parseVariableDeclaration = parseVariableDeclaration;
9384
6934
  extra.parseVariableIdentifier = parseVariableIdentifier;
9385
- extra.parseAnnotatableIdentifier = parseAnnotatableIdentifier;
9386
- extra.parseTypeAnnotation = parseTypeAnnotation;
9387
6935
  extra.parseMethodDefinition = parseMethodDefinition;
9388
6936
  extra.parseClassDeclaration = parseClassDeclaration;
9389
6937
  extra.parseClassExpression = parseClassExpression;
@@ -9429,14 +6977,14 @@ parseYieldExpression: true
9429
6977
  parsePropertyFunction = wrapTracking(extra.parsePropertyFunction);
9430
6978
  parseTemplateElement = wrapTracking(extra.parseTemplateElement);
9431
6979
  parseTemplateLiteral = wrapTracking(extra.parseTemplateLiteral);
6980
+ parseTypeAnnotatableIdentifier = wrapTracking(extra.parseTypeAnnotatableIdentifier);
6981
+ parseTypeAnnotation = wrapTracking(extra.parseTypeAnnotation);
9432
6982
  parseSpreadOrAssignmentExpression = wrapTracking(extra.parseSpreadOrAssignmentExpression);
9433
6983
  parseStatement = wrapTracking(extra.parseStatement);
9434
6984
  parseSwitchCase = wrapTracking(extra.parseSwitchCase);
9435
6985
  parseUnaryExpression = wrapTracking(extra.parseUnaryExpression);
9436
6986
  parseVariableDeclaration = wrapTracking(extra.parseVariableDeclaration);
9437
6987
  parseVariableIdentifier = wrapTracking(extra.parseVariableIdentifier);
9438
- parseAnnotatableIdentifier = wrapTracking(extra.parseAnnotatableIdentifier);
9439
- parseTypeAnnotation = wrapTracking(extra.parseTypeAnnotation);
9440
6988
  parseMethodDefinition = wrapTracking(extra.parseMethodDefinition);
9441
6989
  parseClassDeclaration = wrapTracking(extra.parseClassDeclaration);
9442
6990
  parseClassExpression = wrapTracking(extra.parseClassExpression);
@@ -9499,14 +7047,14 @@ parseYieldExpression: true
9499
7047
  parsePropertyFunction = extra.parsePropertyFunction;
9500
7048
  parseTemplateElement = extra.parseTemplateElement;
9501
7049
  parseTemplateLiteral = extra.parseTemplateLiteral;
7050
+ parseTypeAnnotatableIdentifier = extra.parseTypeAnnotatableIdentifier;
7051
+ parseTypeAnnotation = extra.parseTypeAnnotation;
9502
7052
  parseSpreadOrAssignmentExpression = extra.parseSpreadOrAssignmentExpression;
9503
7053
  parseStatement = extra.parseStatement;
9504
7054
  parseSwitchCase = extra.parseSwitchCase;
9505
7055
  parseUnaryExpression = extra.parseUnaryExpression;
9506
7056
  parseVariableDeclaration = extra.parseVariableDeclaration;
9507
7057
  parseVariableIdentifier = extra.parseVariableIdentifier;
9508
- parseAnnotatableIdentifier = extra.parseAnnotatableIdentifier;
9509
- parseTypeAnnotation = extra.parseTypeAnnotation;
9510
7058
  parseMethodDefinition = extra.parseMethodDefinition;
9511
7059
  parseClassDeclaration = extra.parseClassDeclaration;
9512
7060
  parseClassExpression = extra.parseClassExpression;
@@ -9566,7 +7114,7 @@ parseYieldExpression: true
9566
7114
  length = source.length;
9567
7115
  lookahead = null;
9568
7116
  state = {
9569
- allowDefault: true,
7117
+ allowKeyword: true,
9570
7118
  allowIn: true,
9571
7119
  labelSet: {},
9572
7120
  inFunctionBody: false,
@@ -9667,7 +7215,7 @@ parseYieldExpression: true
9667
7215
  length = source.length;
9668
7216
  lookahead = null;
9669
7217
  state = {
9670
- allowDefault: false,
7218
+ allowKeyword: false,
9671
7219
  allowIn: true,
9672
7220
  labelSet: {},
9673
7221
  parenthesizedCount: 0,
@@ -9772,7 +7320,7 @@ parseYieldExpression: true
9772
7320
  }));
9773
7321
  /* vim: set sw=4 ts=4 et tw=80 : */
9774
7322
 
9775
- },{}],7:[function(require,module,exports){
7323
+ },{}],6:[function(require,module,exports){
9776
7324
  var Base62 = (function (my) {
9777
7325
  my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
9778
7326
 
@@ -9800,7 +7348,7 @@ var Base62 = (function (my) {
9800
7348
  }({}));
9801
7349
 
9802
7350
  module.exports = Base62
9803
- },{}],8:[function(require,module,exports){
7351
+ },{}],7:[function(require,module,exports){
9804
7352
  /*
9805
7353
  * Copyright 2009-2011 Mozilla Foundation and contributors
9806
7354
  * Licensed under the New BSD license. See LICENSE.txt or:
@@ -9810,7 +7358,7 @@ exports.SourceMapGenerator = require('./source-map/source-map-generator').Source
9810
7358
  exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
9811
7359
  exports.SourceNode = require('./source-map/source-node').SourceNode;
9812
7360
 
9813
- },{"./source-map/source-map-consumer":13,"./source-map/source-map-generator":14,"./source-map/source-node":15}],9:[function(require,module,exports){
7361
+ },{"./source-map/source-map-consumer":12,"./source-map/source-map-generator":13,"./source-map/source-node":14}],8:[function(require,module,exports){
9814
7362
  /* -*- Mode: js; js-indent-level: 2; -*- */
9815
7363
  /*
9816
7364
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9919,7 +7467,7 @@ define(function (require, exports, module) {
9919
7467
 
9920
7468
  });
9921
7469
 
9922
- },{"amdefine":17}],10:[function(require,module,exports){
7470
+ },{"amdefine":16}],9:[function(require,module,exports){
9923
7471
  /* -*- Mode: js; js-indent-level: 2; -*- */
9924
7472
  /*
9925
7473
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10065,7 +7613,7 @@ define(function (require, exports, module) {
10065
7613
 
10066
7614
  });
10067
7615
 
10068
- },{"./base64":11,"amdefine":17}],11:[function(require,module,exports){
7616
+ },{"./base64":10,"amdefine":16}],10:[function(require,module,exports){
10069
7617
  /* -*- Mode: js; js-indent-level: 2; -*- */
10070
7618
  /*
10071
7619
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10109,7 +7657,7 @@ define(function (require, exports, module) {
10109
7657
 
10110
7658
  });
10111
7659
 
10112
- },{"amdefine":17}],12:[function(require,module,exports){
7660
+ },{"amdefine":16}],11:[function(require,module,exports){
10113
7661
  /* -*- Mode: js; js-indent-level: 2; -*- */
10114
7662
  /*
10115
7663
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10192,7 +7740,7 @@ define(function (require, exports, module) {
10192
7740
 
10193
7741
  });
10194
7742
 
10195
- },{"amdefine":17}],13:[function(require,module,exports){
7743
+ },{"amdefine":16}],12:[function(require,module,exports){
10196
7744
  /* -*- Mode: js; js-indent-level: 2; -*- */
10197
7745
  /*
10198
7746
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10573,7 +8121,7 @@ define(function (require, exports, module) {
10573
8121
 
10574
8122
  });
10575
8123
 
10576
- },{"./array-set":9,"./base64-vlq":10,"./binary-search":12,"./util":16,"amdefine":17}],14:[function(require,module,exports){
8124
+ },{"./array-set":8,"./base64-vlq":9,"./binary-search":11,"./util":15,"amdefine":16}],13:[function(require,module,exports){
10577
8125
  /* -*- Mode: js; js-indent-level: 2; -*- */
10578
8126
  /*
10579
8127
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10777,7 +8325,7 @@ define(function (require, exports, module) {
10777
8325
 
10778
8326
  });
10779
8327
 
10780
- },{"./array-set":9,"./base64-vlq":10,"./util":16,"amdefine":17}],15:[function(require,module,exports){
8328
+ },{"./array-set":8,"./base64-vlq":9,"./util":15,"amdefine":16}],14:[function(require,module,exports){
10781
8329
  /* -*- Mode: js; js-indent-level: 2; -*- */
10782
8330
  /*
10783
8331
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10978,7 +8526,7 @@ define(function (require, exports, module) {
10978
8526
 
10979
8527
  });
10980
8528
 
10981
- },{"./source-map-generator":14,"amdefine":17}],16:[function(require,module,exports){
8529
+ },{"./source-map-generator":13,"amdefine":16}],15:[function(require,module,exports){
10982
8530
  /* -*- Mode: js; js-indent-level: 2; -*- */
10983
8531
  /*
10984
8532
  * Copyright 2011 Mozilla Foundation and contributors
@@ -11020,7 +8568,7 @@ define(function (require, exports, module) {
11020
8568
 
11021
8569
  });
11022
8570
 
11023
- },{"amdefine":17}],17:[function(require,module,exports){
8571
+ },{"amdefine":16}],16:[function(require,module,exports){
11024
8572
  var process=require("__browserify_process"),__filename="/../node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js";/** vim: et:ts=4:sw=4:sts=4
11025
8573
  * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
11026
8574
  * Available via the MIT or new BSD license.
@@ -11321,7 +8869,7 @@ function amdefine(module, requireFn) {
11321
8869
 
11322
8870
  module.exports = amdefine;
11323
8871
 
11324
- },{"__browserify_process":5,"path":2}],18:[function(require,module,exports){
8872
+ },{"__browserify_process":4,"path":2}],17:[function(require,module,exports){
11325
8873
  /**
11326
8874
  * Copyright 2013 Facebook, Inc.
11327
8875
  *
@@ -11409,7 +8957,7 @@ exports.extract = extract;
11409
8957
  exports.parse = parse;
11410
8958
  exports.parseAsObject = parseAsObject;
11411
8959
 
11412
- },{}],19:[function(require,module,exports){
8960
+ },{}],18:[function(require,module,exports){
11413
8961
  /**
11414
8962
  * Copyright 2013 Facebook, Inc.
11415
8963
  *
@@ -11658,7 +9206,7 @@ function transform(visitors, source, options) {
11658
9206
 
11659
9207
  exports.transform = transform;
11660
9208
 
11661
- },{"./utils":20,"esprima-fb":6,"source-map":8}],20:[function(require,module,exports){
9209
+ },{"./utils":19,"esprima-fb":5,"source-map":7}],19:[function(require,module,exports){
11662
9210
  /**
11663
9211
  * Copyright 2013 Facebook, Inc.
11664
9212
  *
@@ -12139,7 +9687,7 @@ exports.updateIndent = updateIndent;
12139
9687
  exports.updateState = updateState;
12140
9688
  exports.analyzeAndTraverse = analyzeAndTraverse;
12141
9689
 
12142
- },{"./docblock":18}],21:[function(require,module,exports){
9690
+ },{"./docblock":17}],20:[function(require,module,exports){
12143
9691
  /**
12144
9692
  * Copyright 2013 Facebook, Inc.
12145
9693
  *
@@ -12619,7 +10167,7 @@ exports.visitorList = [
12619
10167
  visitSuperMemberExpression
12620
10168
  ];
12621
10169
 
12622
- },{"../src/utils":20,"base62":7,"esprima-fb":6}],22:[function(require,module,exports){
10170
+ },{"../src/utils":19,"base62":6,"esprima-fb":5}],21:[function(require,module,exports){
12623
10171
  /**
12624
10172
  * Copyright 2013 Facebook, Inc.
12625
10173
  *
@@ -12665,7 +10213,7 @@ var run = exports.run = function(code) {
12665
10213
  var functionBody = jsx ? transform(code).code : code;
12666
10214
  var scriptEl = document.createElement('script');
12667
10215
 
12668
- scriptEl.innerHTML = functionBody;
10216
+ scriptEl.text = functionBody;
12669
10217
  headEl.appendChild(scriptEl);
12670
10218
  };
12671
10219
 
@@ -12697,11 +10245,15 @@ var load = exports.load = function(url, callback) {
12697
10245
 
12698
10246
  runScripts = function() {
12699
10247
  var scripts = document.getElementsByTagName('script');
12700
- scripts = Array.prototype.slice.call(scripts);
12701
- var jsxScripts = scripts.filter(function(script) {
12702
- return script.type === 'text/jsx';
12703
- });
12704
-
10248
+
10249
+ // Array.prototype.slice cannot be used on NodeList on IE8
10250
+ var jsxScripts = [];
10251
+ for (var i = 0; i < scripts.length; i++) {
10252
+ if (scripts.item(i).type === 'text/jsx') {
10253
+ jsxScripts.push(scripts.item(i));
10254
+ }
10255
+ }
10256
+
12705
10257
  console.warn("You are using the in-browser JSX transformer. Be sure to precompile your JSX for production - http://facebook.github.io/react/docs/tooling-integration.html#jsx");
12706
10258
 
12707
10259
  jsxScripts.forEach(function(script) {
@@ -12719,7 +10271,7 @@ if (window.addEventListener) {
12719
10271
  window.attachEvent('onload', runScripts);
12720
10272
  }
12721
10273
 
12722
- },{"./fbtransform/visitors":26,"jstransform":19,"jstransform/src/docblock":18}],23:[function(require,module,exports){
10274
+ },{"./fbtransform/visitors":25,"jstransform":18,"jstransform/src/docblock":17}],22:[function(require,module,exports){
12723
10275
  /**
12724
10276
  * Copyright 2013 Facebook, Inc.
12725
10277
  *
@@ -12739,12 +10291,7 @@ if (window.addEventListener) {
12739
10291
  "use strict";
12740
10292
 
12741
10293
  var Syntax = require('esprima-fb').Syntax;
12742
-
12743
- var catchup = require('jstransform/src/utils').catchup;
12744
- var catchupWhiteSpace = require('jstransform/src/utils').catchupWhiteSpace;
12745
- var append = require('jstransform/src/utils').append;
12746
- var move = require('jstransform/src/utils').move;
12747
- var getDocblock = require('jstransform/src/utils').getDocblock;
10294
+ var utils = require('jstransform/src/utils');
12748
10295
 
12749
10296
  var FALLBACK_TAGS = require('./xjs').knownTags;
12750
10297
  var renderXJSExpressionContainer =
@@ -12778,9 +10325,9 @@ var JSX_ATTRIBUTE_TRANSFORMS = {
12778
10325
  };
12779
10326
 
12780
10327
  function visitReactTag(traverse, object, path, state) {
12781
- var jsxObjIdent = getDocblock(state).jsx;
10328
+ var jsxObjIdent = utils.getDocblock(state).jsx;
12782
10329
 
12783
- catchup(object.openingElement.range[0], state);
10330
+ utils.catchup(object.openingElement.range[0], state);
12784
10331
 
12785
10332
  if (object.name.namespace) {
12786
10333
  throw new Error(
@@ -12788,12 +10335,12 @@ function visitReactTag(traverse, object, path, state) {
12788
10335
  }
12789
10336
 
12790
10337
  var isFallbackTag = FALLBACK_TAGS[object.name.name];
12791
- append(
10338
+ utils.append(
12792
10339
  (isFallbackTag ? jsxObjIdent + '.' : '') + (object.name.name) + '(',
12793
10340
  state
12794
10341
  );
12795
10342
 
12796
- move(object.name.range[1], state);
10343
+ utils.move(object.name.range[1], state);
12797
10344
 
12798
10345
  var childrenToRender = object.children.filter(function(child) {
12799
10346
  return !(child.type === Syntax.Literal && !child.value.match(/\S/));
@@ -12801,12 +10348,12 @@ function visitReactTag(traverse, object, path, state) {
12801
10348
 
12802
10349
  // if we don't have any attributes, pass in null
12803
10350
  if (object.attributes.length === 0) {
12804
- append('null', state);
10351
+ utils.append('null', state);
12805
10352
  }
12806
10353
 
12807
10354
  // write attributes
12808
10355
  object.attributes.forEach(function(attr, index) {
12809
- catchup(attr.range[0], state);
10356
+ utils.catchup(attr.range[0], state);
12810
10357
  if (attr.name.namespace) {
12811
10358
  throw new Error(
12812
10359
  'Namespace attributes are not supported. ReactJSX is not XML.');
@@ -12816,27 +10363,27 @@ function visitReactTag(traverse, object, path, state) {
12816
10363
  var isLast = index === object.attributes.length - 1;
12817
10364
 
12818
10365
  if (isFirst) {
12819
- append('{', state);
10366
+ utils.append('{', state);
12820
10367
  }
12821
10368
 
12822
- append(quoteAttrName(name), state);
12823
- append(':', state);
10369
+ utils.append(quoteAttrName(name), state);
10370
+ utils.append(':', state);
12824
10371
 
12825
10372
  if (!attr.value) {
12826
10373
  state.g.buffer += 'true';
12827
10374
  state.g.position = attr.name.range[1];
12828
10375
  if (!isLast) {
12829
- append(',', state);
10376
+ utils.append(',', state);
12830
10377
  }
12831
10378
  } else {
12832
- move(attr.name.range[1], state);
10379
+ utils.move(attr.name.range[1], state);
12833
10380
  // Use catchupWhiteSpace to skip over the '=' in the attribute
12834
- catchupWhiteSpace(attr.value.range[0], state);
10381
+ utils.catchupWhiteSpace(attr.value.range[0], state);
12835
10382
  if (JSX_ATTRIBUTE_TRANSFORMS[attr.name.name]) {
12836
- append(JSX_ATTRIBUTE_TRANSFORMS[attr.name.name](attr), state);
12837
- move(attr.value.range[1], state);
10383
+ utils.append(JSX_ATTRIBUTE_TRANSFORMS[attr.name.name](attr), state);
10384
+ utils.move(attr.value.range[1], state);
12838
10385
  if (!isLast) {
12839
- append(',', state);
10386
+ utils.append(',', state);
12840
10387
  }
12841
10388
  } else if (attr.value.type === Syntax.Literal) {
12842
10389
  renderXJSLiteral(attr.value, isLast, state);
@@ -12846,26 +10393,26 @@ function visitReactTag(traverse, object, path, state) {
12846
10393
  }
12847
10394
 
12848
10395
  if (isLast) {
12849
- append('}', state);
10396
+ utils.append('}', state);
12850
10397
  }
12851
10398
 
12852
- catchup(attr.range[1], state);
10399
+ utils.catchup(attr.range[1], state);
12853
10400
  });
12854
10401
 
12855
10402
  if (!object.selfClosing) {
12856
- catchup(object.openingElement.range[1] - 1, state);
12857
- move(object.openingElement.range[1], state);
10403
+ utils.catchup(object.openingElement.range[1] - 1, state);
10404
+ utils.move(object.openingElement.range[1], state);
12858
10405
  }
12859
10406
 
12860
10407
  // filter out whitespace
12861
10408
  if (childrenToRender.length > 0) {
12862
- append(', ', state);
10409
+ utils.append(', ', state);
12863
10410
 
12864
10411
  object.children.forEach(function(child) {
12865
10412
  if (child.type === Syntax.Literal && !child.value.match(/\S/)) {
12866
10413
  return;
12867
10414
  }
12868
- catchup(child.range[0], state);
10415
+ utils.catchup(child.range[0], state);
12869
10416
 
12870
10417
  var isLast = child === childrenToRender[childrenToRender.length - 1];
12871
10418
 
@@ -12876,38 +10423,38 @@ function visitReactTag(traverse, object, path, state) {
12876
10423
  } else {
12877
10424
  traverse(child, path, state);
12878
10425
  if (!isLast) {
12879
- append(',', state);
10426
+ utils.append(',', state);
12880
10427
  state.g.buffer = state.g.buffer.replace(/(\s*),$/, ',$1');
12881
10428
  }
12882
10429
  }
12883
10430
 
12884
- catchup(child.range[1], state);
10431
+ utils.catchup(child.range[1], state);
12885
10432
  });
12886
10433
  }
12887
10434
 
12888
10435
  if (object.selfClosing) {
12889
10436
  // everything up to />
12890
- catchup(object.openingElement.range[1] - 2, state);
12891
- move(object.openingElement.range[1], state);
10437
+ utils.catchup(object.openingElement.range[1] - 2, state);
10438
+ utils.move(object.openingElement.range[1], state);
12892
10439
  } else {
12893
10440
  // everything up to </ sdflksjfd>
12894
- catchup(object.closingElement.range[0], state);
12895
- move(object.closingElement.range[1], state);
10441
+ utils.catchup(object.closingElement.range[0], state);
10442
+ utils.move(object.closingElement.range[1], state);
12896
10443
  }
12897
10444
 
12898
- append(')', state);
10445
+ utils.append(')', state);
12899
10446
  return false;
12900
10447
  }
12901
10448
 
12902
10449
  visitReactTag.test = function(object, path, state) {
12903
10450
  // only run react when react @jsx namespace is specified in docblock
12904
- var jsx = getDocblock(state).jsx;
10451
+ var jsx = utils.getDocblock(state).jsx;
12905
10452
  return object.type === Syntax.XJSElement && jsx && jsx.length;
12906
10453
  };
12907
10454
 
12908
10455
  exports.visitReactTag = visitReactTag;
12909
10456
 
12910
- },{"./xjs":25,"esprima-fb":6,"jstransform/src/utils":20}],24:[function(require,module,exports){
10457
+ },{"./xjs":24,"esprima-fb":5,"jstransform/src/utils":19}],23:[function(require,module,exports){
12911
10458
  /**
12912
10459
  * Copyright 2013 Facebook, Inc.
12913
10460
  *
@@ -12927,9 +10474,7 @@ exports.visitReactTag = visitReactTag;
12927
10474
  "use strict";
12928
10475
 
12929
10476
  var Syntax = require('esprima-fb').Syntax;
12930
- var catchup = require('jstransform/src/utils').catchup;
12931
- var append = require('jstransform/src/utils').append;
12932
- var getDocblock = require('jstransform/src/utils').getDocblock;
10477
+ var utils = require('jstransform/src/utils');
12933
10478
 
12934
10479
  /**
12935
10480
  * Transforms the following:
@@ -12958,8 +10503,8 @@ function visitReactDisplayName(traverse, object, path, state) {
12958
10503
  object.init['arguments'][0].type === Syntax.ObjectExpression) {
12959
10504
 
12960
10505
  var displayName = object.id.name;
12961
- catchup(object.init['arguments'][0].range[0] + 1, state);
12962
- append("displayName: '" + displayName + "',", state);
10506
+ utils.catchup(object.init['arguments'][0].range[0] + 1, state);
10507
+ utils.append("displayName: '" + displayName + "',", state);
12963
10508
  }
12964
10509
  }
12965
10510
 
@@ -12967,12 +10512,12 @@ function visitReactDisplayName(traverse, object, path, state) {
12967
10512
  * Will only run on @jsx files for now.
12968
10513
  */
12969
10514
  visitReactDisplayName.test = function(object, path, state) {
12970
- return object.type === Syntax.VariableDeclarator && !!getDocblock(state).jsx;
10515
+ return object.type === Syntax.VariableDeclarator && !!utils.getDocblock(state).jsx;
12971
10516
  };
12972
10517
 
12973
10518
  exports.visitReactDisplayName = visitReactDisplayName;
12974
10519
 
12975
- },{"esprima-fb":6,"jstransform/src/utils":20}],25:[function(require,module,exports){
10520
+ },{"esprima-fb":5,"jstransform/src/utils":19}],24:[function(require,module,exports){
12976
10521
  /**
12977
10522
  * Copyright 2013 Facebook, Inc.
12978
10523
  *
@@ -13266,7 +10811,7 @@ exports.renderXJSExpressionContainer = renderXJSExpressionContainer;
13266
10811
  exports.renderXJSLiteral = renderXJSLiteral;
13267
10812
  exports.quoteAttrName = quoteAttrName;
13268
10813
 
13269
- },{"esprima-fb":6,"jstransform/src/utils":20}],26:[function(require,module,exports){
10814
+ },{"esprima-fb":5,"jstransform/src/utils":19}],25:[function(require,module,exports){
13270
10815
  /*global exports:true*/
13271
10816
  var es6Classes = require('jstransform/visitors/es6-class-visitors').visitorList;
13272
10817
  var react = require('./transforms/react');
@@ -13311,7 +10856,7 @@ function getVisitorsList(excludes) {
13311
10856
  exports.getVisitorsList = getVisitorsList;
13312
10857
  exports.transformVisitors = transformVisitors;
13313
10858
 
13314
- },{"./transforms/react":23,"./transforms/reactDisplayName":24,"jstransform/visitors/es6-class-visitors":21}]},{},[22])
13315
- (22)
10859
+ },{"./transforms/react":22,"./transforms/reactDisplayName":23,"jstransform/visitors/es6-class-visitors":20}]},{},[21])
10860
+ (21)
13316
10861
  });
13317
10862
  ;