telos-autocors 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/apintUtils.js +0 -114
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telos-autocors",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "IO Library Featuring Automatic CORS Proxy Routing for HTTP Requests",
5
5
  "main": "autoCORS.js",
6
6
  "dependencies": {
package/apintUtils.js DELETED
@@ -1,114 +0,0 @@
1
- var apintUtils = {
2
- buildAPInt: (apint, path) => {
3
-
4
- apint = JSON.parse(JSON.stringify(apint));
5
- path = path != null ? path : [];
6
-
7
- if(apint.packages == null)
8
- return apint;
9
-
10
- Object.keys(apint.packages).forEach(key => {
11
-
12
- if(typeof apint.packages[key] == "string") {
13
-
14
- if(path.includes(apint.packages[key]))
15
- return;
16
-
17
- apint.packages[key] = apintUtils.buildAPInt(
18
- use(apint.packages[key]),
19
- path.concat(apint.packages[key])
20
- );
21
- }
22
-
23
- else {
24
-
25
- apint.packages[key] = apintUtils.buildAPInt(
26
- apint.packages[key], path
27
- );
28
- }
29
- })
30
-
31
- return apint;
32
- },
33
- queryUtilities: (apint, path, properties, inheritance) => {
34
-
35
- path = path != null ? path : [];
36
-
37
- if(typeof path == "string")
38
- path = path.split(".").map(item => item.toLowerCase());
39
-
40
- inheritance = inheritance != null ?
41
- JSON.parse(JSON.stringify(inheritance)) : { };
42
-
43
- properties = properties != null ? properties : { };
44
-
45
- if(apint.properties != null)
46
- Object.assign(inheritance, apint.properties);
47
-
48
- let utilities = [];
49
-
50
- if(path.length <= 1 && apint.utilities != null) {
51
-
52
- Object.keys(apint.utilities).forEach(key => {
53
-
54
- let utility = JSON.parse(JSON.stringify(apint.utilities[key]));
55
-
56
- utility.properties = Object.assign(
57
- Object.assign({ }, inheritance),
58
- utility.properties != null ? utility.properties : { }
59
- );
60
-
61
- let match = true;
62
-
63
- Object.keys(properties).forEach((item) => {
64
-
65
- if(JSON.stringify(properties[item]) !=
66
- JSON.stringify(utility.properties[item])) {
67
-
68
- match = false;
69
- }
70
- });
71
-
72
- if(match)
73
- utilities.push(utility);
74
- });
75
- }
76
-
77
- if(apint.packages != null) {
78
-
79
- Object.keys(apint.packages).forEach(key => {
80
-
81
- if(typeof apint.packages[key] == "string")
82
- return;
83
-
84
- if(path.length > 0) {
85
-
86
- if(key.toLowerCase() == path[0])
87
- path = path.slice(1);
88
- }
89
-
90
- utilities = utilities.concat(
91
- apintUtils.queryUtilities(
92
- apint.packages[key], path, properties, inheritance
93
- )
94
- );
95
- });
96
- }
97
-
98
- return utilities;
99
- },
100
- loadUtility: (apint, query) => {
101
-
102
- let utility = apintUtils.queryUtilities(apint, query)[0];
103
-
104
- if(utility == null)
105
- return null;
106
-
107
- return use(
108
- Array.isArray(utility.source) ? utility.source[0] : utility.source
109
- );
110
- }
111
- };
112
-
113
- if(typeof module == "object")
114
- module.exports = apintUtils;