Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/fourtyone11/origin-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js')
-rw-r--r--assets/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/assets/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js b/assets/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js
new file mode 100644
index 0000000..5802683
--- /dev/null
+++ b/assets/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js
@@ -0,0 +1,74 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = removeTypeDuplicates;
+
+var _generated = require("../../validators/generated");
+
+function removeTypeDuplicates(nodes) {
+ const generics = {};
+ const bases = {};
+ const typeGroups = [];
+ const types = [];
+
+ for (let i = 0; i < nodes.length; i++) {
+ const node = nodes[i];
+ if (!node) continue;
+
+ if (types.indexOf(node) >= 0) {
+ continue;
+ }
+
+ if ((0, _generated.isAnyTypeAnnotation)(node)) {
+ return [node];
+ }
+
+ if ((0, _generated.isFlowBaseAnnotation)(node)) {
+ bases[node.type] = node;
+ continue;
+ }
+
+ if ((0, _generated.isUnionTypeAnnotation)(node)) {
+ if (typeGroups.indexOf(node.types) < 0) {
+ nodes = nodes.concat(node.types);
+ typeGroups.push(node.types);
+ }
+
+ continue;
+ }
+
+ if ((0, _generated.isGenericTypeAnnotation)(node)) {
+ const name = node.id.name;
+
+ if (generics[name]) {
+ let existing = generics[name];
+
+ if (existing.typeParameters) {
+ if (node.typeParameters) {
+ existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
+ }
+ } else {
+ existing = node.typeParameters;
+ }
+ } else {
+ generics[name] = node;
+ }
+
+ continue;
+ }
+
+ types.push(node);
+ }
+
+ for (const type of Object.keys(bases)) {
+ types.push(bases[type]);
+ }
+
+ for (const name of Object.keys(generics)) {
+ types.push(generics[name]);
+ }
+
+ return types;
+} \ No newline at end of file