Front end of the Slack clone application.

index.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.ScopeManager = exports.Scope = exports.Variable = exports.Reference = exports.version = undefined;
  6. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; /*
  7. Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  8. Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
  9. Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions are met:
  12. * Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  21. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. /**
  29. * Escope (<a href="http://github.com/estools/escope">escope</a>) is an <a
  30. * href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a>
  31. * scope analyzer extracted from the <a
  32. * href="http://github.com/estools/esmangle">esmangle project</a/>.
  33. * <p>
  34. * <em>escope</em> finds lexical scopes in a source program, i.e. areas of that
  35. * program where different occurrences of the same identifier refer to the same
  36. * variable. With each scope the contained variables are collected, and each
  37. * identifier reference in code is linked to its corresponding variable (if
  38. * possible).
  39. * <p>
  40. * <em>escope</em> works on a syntax tree of the parsed source code which has
  41. * to adhere to the <a
  42. * href="https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API">
  43. * Mozilla Parser API</a>. E.g. <a href="http://esprima.org">esprima</a> is a parser
  44. * that produces such syntax trees.
  45. * <p>
  46. * The main interface is the {@link analyze} function.
  47. * @module escope
  48. */
  49. /*jslint bitwise:true */
  50. exports.analyze = analyze;
  51. var _assert = require('assert');
  52. var _assert2 = _interopRequireDefault(_assert);
  53. var _scopeManager = require('./scope-manager');
  54. var _scopeManager2 = _interopRequireDefault(_scopeManager);
  55. var _referencer = require('./referencer');
  56. var _referencer2 = _interopRequireDefault(_referencer);
  57. var _reference = require('./reference');
  58. var _reference2 = _interopRequireDefault(_reference);
  59. var _variable = require('./variable');
  60. var _variable2 = _interopRequireDefault(_variable);
  61. var _scope = require('./scope');
  62. var _scope2 = _interopRequireDefault(_scope);
  63. var _package = require('../package.json');
  64. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  65. function defaultOptions() {
  66. return {
  67. optimistic: false,
  68. directive: false,
  69. nodejsScope: false,
  70. impliedStrict: false,
  71. sourceType: 'script', // one of ['script', 'module']
  72. ecmaVersion: 5,
  73. childVisitorKeys: null,
  74. fallback: 'iteration'
  75. };
  76. }
  77. function updateDeeply(target, override) {
  78. var key, val;
  79. function isHashObject(target) {
  80. return (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target instanceof Object && !(target instanceof Array) && !(target instanceof RegExp);
  81. }
  82. for (key in override) {
  83. if (override.hasOwnProperty(key)) {
  84. val = override[key];
  85. if (isHashObject(val)) {
  86. if (isHashObject(target[key])) {
  87. updateDeeply(target[key], val);
  88. } else {
  89. target[key] = updateDeeply({}, val);
  90. }
  91. } else {
  92. target[key] = val;
  93. }
  94. }
  95. }
  96. return target;
  97. }
  98. /**
  99. * Main interface function. Takes an Esprima syntax tree and returns the
  100. * analyzed scopes.
  101. * @function analyze
  102. * @param {esprima.Tree} tree
  103. * @param {Object} providedOptions - Options that tailor the scope analysis
  104. * @param {boolean} [providedOptions.optimistic=false] - the optimistic flag
  105. * @param {boolean} [providedOptions.directive=false]- the directive flag
  106. * @param {boolean} [providedOptions.ignoreEval=false]- whether to check 'eval()' calls
  107. * @param {boolean} [providedOptions.nodejsScope=false]- whether the whole
  108. * script is executed under node.js environment. When enabled, escope adds
  109. * a function scope immediately following the global scope.
  110. * @param {boolean} [providedOptions.impliedStrict=false]- implied strict mode
  111. * (if ecmaVersion >= 5).
  112. * @param {string} [providedOptions.sourceType='script']- the source type of the script. one of 'script' and 'module'
  113. * @param {number} [providedOptions.ecmaVersion=5]- which ECMAScript version is considered
  114. * @param {Object} [providedOptions.childVisitorKeys=null] - Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
  115. * @param {string} [providedOptions.fallback='iteration'] - A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
  116. * @return {ScopeManager}
  117. */
  118. function analyze(tree, providedOptions) {
  119. var scopeManager, referencer, options;
  120. options = updateDeeply(defaultOptions(), providedOptions);
  121. scopeManager = new _scopeManager2.default(options);
  122. referencer = new _referencer2.default(options, scopeManager);
  123. referencer.visit(tree);
  124. (0, _assert2.default)(scopeManager.__currentScope === null, 'currentScope should be null.');
  125. return scopeManager;
  126. }
  127. exports.
  128. /** @name module:escope.version */
  129. version = _package.version;
  130. exports.
  131. /** @name module:escope.Reference */
  132. Reference = _reference2.default;
  133. exports.
  134. /** @name module:escope.Variable */
  135. Variable = _variable2.default;
  136. exports.
  137. /** @name module:escope.Scope */
  138. Scope = _scope2.default;
  139. exports.
  140. /** @name module:escope.ScopeManager */
  141. ScopeManager = _scopeManager2.default;
  142. /* vim: set sw=4 ts=4 et tw=80 : */
  143. //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztRQW9IZ0I7O0FBbEVoQjs7OztBQUVBOzs7O0FBQ0E7Ozs7QUFDQTs7OztBQUNBOzs7O0FBQ0E7Ozs7QUFDQTs7OztBQUVBLFNBQVMsY0FBVCxHQUEwQjtBQUN0QixXQUFPO0FBQ0gsb0JBQVksS0FBWjtBQUNBLG1CQUFXLEtBQVg7QUFDQSxxQkFBYSxLQUFiO0FBQ0EsdUJBQWUsS0FBZjtBQUNBLG9CQUFZLFFBQVo7QUFDQSxxQkFBYSxDQUFiO0FBQ0EsMEJBQWtCLElBQWxCO0FBQ0Esa0JBQVUsV0FBVjtLQVJKLENBRHNCO0NBQTFCOztBQWFBLFNBQVMsWUFBVCxDQUFzQixNQUF0QixFQUE4QixRQUE5QixFQUF3QztBQUNwQyxRQUFJLEdBQUosRUFBUyxHQUFULENBRG9DOztBQUdwQyxhQUFTLFlBQVQsQ0FBc0IsTUFBdEIsRUFBOEI7QUFDMUIsZUFBTyxRQUFPL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