funkophile 0.2.2 → 0.2.3
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.
- package/funkophileHelpers.ts +17 -11
- package/index.ts +9 -0
- package/package.json +1 -1
package/funkophileHelpers.ts
CHANGED
|
@@ -2,39 +2,45 @@ import { createSelector } from "reselect";
|
|
|
2
2
|
|
|
3
3
|
export const contentsOfFiles = (selector) => {
|
|
4
4
|
return createSelector([selector], (selected) => {
|
|
5
|
-
|
|
5
|
+
if (!selected) return "";
|
|
6
|
+
return Object.keys(selected).reduce((mm, k) => mm + (selected[k] || ""), "");
|
|
6
7
|
});
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export const contentOfFile = (selector) => {
|
|
10
11
|
return createSelector([selector], (selected) => {
|
|
11
|
-
try{
|
|
12
|
-
|
|
12
|
+
try {
|
|
13
|
+
if (!selected) return "";
|
|
14
|
+
const keys = Object.keys(selected);
|
|
15
|
+
if (keys.length === 0) return "";
|
|
16
|
+
return selected[keys[0]] || "";
|
|
13
17
|
} catch (e) {
|
|
14
|
-
console.error("error", e)
|
|
15
|
-
console.error("selected", selected)
|
|
16
|
-
console.error("selector", selector)
|
|
17
|
-
process.exit(-1)
|
|
18
|
+
console.error("error", e);
|
|
19
|
+
console.error("selected", selected);
|
|
20
|
+
console.error("selector", selector);
|
|
21
|
+
process.exit(-1);
|
|
18
22
|
}
|
|
19
|
-
})
|
|
20
|
-
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
21
25
|
|
|
22
26
|
export const srcAndContentOfFile = (selector, key: string) => {
|
|
23
27
|
return createSelector([selector], (selected) => {
|
|
28
|
+
if (!selected) return { src: key, content: "" };
|
|
24
29
|
return {
|
|
25
30
|
src: key,
|
|
26
|
-
content: selected[key],
|
|
31
|
+
content: selected[key] || "",
|
|
27
32
|
};
|
|
28
33
|
});
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
export const srcAndContentOfFiles = (selector) => {
|
|
32
37
|
return createSelector([selector], (selected) => {
|
|
38
|
+
if (!selected) return [];
|
|
33
39
|
const keys = Object.keys(selected);
|
|
34
40
|
return keys.map((key) => {
|
|
35
41
|
return {
|
|
36
42
|
src: key,
|
|
37
|
-
content: selected[key],
|
|
43
|
+
content: selected[key] || "",
|
|
38
44
|
};
|
|
39
45
|
});
|
|
40
46
|
});
|
package/index.ts
CHANGED
|
@@ -123,6 +123,15 @@ export default (funkophileConfig: {
|
|
|
123
123
|
},
|
|
124
124
|
action,
|
|
125
125
|
) => {
|
|
126
|
+
// Ensure state is always an object
|
|
127
|
+
if (!state) {
|
|
128
|
+
throw new Error("State is undefined");
|
|
129
|
+
// state = {
|
|
130
|
+
// initialLoad: true,
|
|
131
|
+
// ...funkophileConfig.initialState,
|
|
132
|
+
// timestamp: Date.now(),
|
|
133
|
+
// };
|
|
134
|
+
}
|
|
126
135
|
// console.log("\u001b[7m\u001b[35m ||| Redux recieved action \u001b[0m", action.type)
|
|
127
136
|
if (!action.type.includes("@@redux")) {
|
|
128
137
|
if (action.type === INITIALIZE) {
|