@blujosi/rivetkit-svelte 2.3.9 → 2.3.11
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.
|
@@ -33,7 +33,7 @@ export interface CrudTransformOptions<T> {
|
|
|
33
33
|
* Property name (or accessor) used to uniquely identify items.
|
|
34
34
|
* Defaults to `"id"`.
|
|
35
35
|
*/
|
|
36
|
-
key?: keyof T | ((item: T) =>
|
|
36
|
+
key?: keyof T | ((item: T) => string) | string | number;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Transform for a **create** event.
|
|
@@ -19,7 +19,15 @@
|
|
|
19
19
|
// Helpers
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
function getKey(item, key) {
|
|
22
|
-
|
|
22
|
+
if (typeof key === "function") {
|
|
23
|
+
return key(item);
|
|
24
|
+
}
|
|
25
|
+
else if (typeof key === "string" || typeof key === "number") {
|
|
26
|
+
return item[key];
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return item[key];
|
|
30
|
+
}
|
|
23
31
|
}
|
|
24
32
|
// ---------------------------------------------------------------------------
|
|
25
33
|
// Individual transforms
|