@mittwald/react-ghostmaker 1.0.4 → 1.1.0
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/dist/esm/queries.js +9 -6
- package/package.json +1 -1
package/dist/esm/queries.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import is from "@sindresorhus/is";
|
|
2
2
|
import { modelIdentifiers } from "./modelIdentifier";
|
|
3
3
|
import { hashObject } from "./hash";
|
|
4
|
-
const
|
|
5
|
-
if (is.primitive(something)) {
|
|
6
|
-
return String(something);
|
|
7
|
-
}
|
|
4
|
+
const getObjectName = (something) => {
|
|
8
5
|
const isObject = is.object(something);
|
|
9
6
|
const isClass = is.class(something);
|
|
10
7
|
const isFunction = is.function(something);
|
|
11
|
-
|
|
8
|
+
return isFunction
|
|
12
9
|
? something.name
|
|
13
10
|
: isClass || isObject
|
|
14
11
|
? something.constructor.name
|
|
15
12
|
: "unknown";
|
|
13
|
+
};
|
|
14
|
+
const getTargetQueryKey = (something) => {
|
|
15
|
+
if (is.primitive(something)) {
|
|
16
|
+
return String(something);
|
|
17
|
+
}
|
|
18
|
+
const objectName = getObjectName(something);
|
|
16
19
|
const thisModelIdentifiers = modelIdentifiers
|
|
17
20
|
.map((fn) => fn(something))
|
|
18
21
|
.filter(is.string)
|
|
@@ -26,7 +29,7 @@ const getArgKey = (arg) => {
|
|
|
26
29
|
if (is.primitive(arg)) {
|
|
27
30
|
return String(arg);
|
|
28
31
|
}
|
|
29
|
-
return
|
|
32
|
+
return `${getObjectName(arg)}(hash:${hashObject(arg)})`;
|
|
30
33
|
};
|
|
31
34
|
export const queries = {
|
|
32
35
|
ghostmaker: () => ["react-ghostmaker"],
|