@appartmint/mint 1.2.9 → 1.2.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.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Forward all exports from the util directory
3
3
  */
4
+ export * from './async';
4
5
  export * from './display';
5
6
  export * from './event';
6
7
  export * from './icon';
@@ -204,5 +204,31 @@ export abstract class MintObject {
204
204
  static getKeyByValue(object: any, value: any): string | undefined {
205
205
  return Object.keys(object).find((key) => object[key] === value);
206
206
  }
207
+
208
+ /**
209
+ * Create a deep copy of an object
210
+ * @recursive
211
+ */
212
+ static deepClone(object: any): any {
213
+
214
+ // Clone every property
215
+ const clone: any = {};
216
+ for (const key in object) {
217
+
218
+ // Functions
219
+ if (typeof object[key] === 'function') {
220
+ clone[key] = object[key].bind(clone);
221
+
222
+ // Objects
223
+ } else if (object[key] && typeof object[key] === 'object') {
224
+ clone[key] = this.deepClone(object[key]);
225
+
226
+ // Primitives
227
+ } else {
228
+ clone[key] = object[key];
229
+ }
230
+ }
231
+ return clone;
232
+ }
207
233
  };
208
234
  export default MintObject;
@@ -18,6 +18,15 @@ export abstract class MintText {
18
18
  .replace(/^\/+|\/+$/g, '') ?? '';
19
19
  }
20
20
 
21
+ /**
22
+ * Generate a title from a slug
23
+ * @param slug - The slug to generate a title from
24
+ * @returns The title
25
+ */
26
+ static unslug (slug: string): string {
27
+ return this.titleCase(slug.replace(/[-/]+/g, ' '));
28
+ }
29
+
21
30
  /**
22
31
  * Format a phone number
23
32
  * @param phone - The phone number to format