js2flowchart
Version:
> Why? While I've been working on [Under-the-hood-ReactJS](https://github.com/Bogdan-Lyashenko/Under-the-hood-ReactJS) I spent enormous amount of time on creating schemes. Each change in code or flowchart affects all entire scheme instantly, forcing you t
37 lines • 2.9 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
import { TOKEN_TYPES } from 'shared/constants';
import { DefinitionsList } from './entryDefinitionsMap';
import { getFunctionDependenciesLevel } from './abstraction-levels/functionDependencies';
import { getFunctionsLevel } from './abstraction-levels/functions';
export var ABSTRACTION_LEVELS = {
FUNCTION: getFunctionsLevel(),
FUNCTION_DEPENDENCIES: getFunctionDependenciesLevel(),
CLASS: [TOKEN_TYPES.CLASS_DECLARATION],
IMPORT: [TOKEN_TYPES.IMPORT_DECLARATION, TOKEN_TYPES.IMPORT_SPECIFIER, TOKEN_TYPES.IMPORT_DEFAULT_SPECIFIER],
EXPORT: [TOKEN_TYPES.EXPORT_NAMED_DECLARATION, TOKEN_TYPES.EXPORT_DEFAULT_DECLARATION]
};
export var rebuildConfigForAbstractionLevel = function rebuildConfigForAbstractionLevel(level) {
var definedLevels = [TOKEN_TYPES.PROGRAM],
customLevels = [];
[].concat(level).forEach(function (item) {
if (typeof item === 'string') {
return definedLevels.push(item);
}
if (Array.isArray(item)) {
return definedLevels = definedLevels.concat(_toConsumableArray(item));
}
if (_typeof(item) === 'object') {
definedLevels = definedLevels.concat(_toConsumableArray(item.defined || []));
customLevels = customLevels.concat(_toConsumableArray(item.custom || []));
}
});
return DefinitionsList.filter(function (item) {
return definedLevels.indexOf(item.type) !== -1;
}).concat(customLevels);
};