@budibase/shared-core 3.9.3 → 3.9.4

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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Duplicates a name with respect to a collection of existing names
3
+ * e.g.
4
+ * name all names result
5
+ * ------ ----------- --------
6
+ * ("foo") ["foo"] "foo 1"
7
+ * ("foo") ["foo", "foo 1"] "foo 2"
8
+ * ("foo 1") ["foo", "foo 1"] "foo 2"
9
+ * ("foo") ["foo", "foo 2"] "foo 1"
10
+ *
11
+ * Repl
12
+ */
13
+ export declare const duplicateName: (name: string, allNames: string[]) => string;
14
+ /**
15
+ * More flexible alternative to the above function, which handles getting the
16
+ * next sequential name from an array of existing items while accounting for
17
+ * any type of prefix, and being able to deeply retrieve that name from the
18
+ * existing item array.
19
+ *
20
+ * Examples with a prefix of "foo":
21
+ * [] => "foo"
22
+ * ["foo"] => "foo2"
23
+ * ["foo", "foo6"] => "foo7"
24
+ *
25
+ * Examples with a prefix of "foo " (space at the end):
26
+ * [] => "foo"
27
+ * ["foo"] => "foo 2"
28
+ * ["foo", "foo 6"] => "foo 7"
29
+ *
30
+ * @param items the array of existing items
31
+ * @param prefix the string prefix of each name, including any spaces desired
32
+ * @param getName optional function to extract the name for an item, if not a
33
+ * flat array of strings
34
+ */
35
+ export declare const getSequentialName: <T extends unknown>(items: T[] | null, prefix: string | null, { getName, numberFirstItem, separator, }?: {
36
+ getName?: (item: T) => string;
37
+ numberFirstItem?: boolean;
38
+ separator?: string;
39
+ }) => string;
@@ -7,3 +7,4 @@ export * as schema from "./schema";
7
7
  export * as views from "./views";
8
8
  export * as roles from "./roles";
9
9
  export * as lists from "./lists";
10
+ export * from "./duplicate";
@@ -0,0 +1 @@
1
+ export {};