@sqlrooms/utils 0.6.0 → 0.7.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/README.md ADDED
@@ -0,0 +1,98 @@
1
+ A collection of utility functions and helpers for SQLRooms applications. This package provides common utilities for string manipulation, file handling, color management, formatting, and more.
2
+
3
+ ## Features
4
+
5
+ - 🔠 **String Utilities**: Functions for string manipulation and formatting
6
+ - 📁 **File Path Handling**: Tools for working with file paths and extensions
7
+ - 🎨 **Color Utilities**: Color conversion and manipulation functions
8
+ - 📊 **Formatting**: Data formatting for display purposes
9
+ - 🔄 **XHR Helpers**: Utilities for working with XMLHttpRequests
10
+ - 🧰 **General Helpers**: Common helper functions for everyday tasks
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @sqlrooms/utils
16
+ # or
17
+ yarn add @sqlrooms/utils
18
+ ```
19
+
20
+ ## Basic Usage
21
+
22
+ ### String Utilities
23
+
24
+ ```tsx
25
+ import {truncate, capitalize, slugify} from '@sqlrooms/utils';
26
+
27
+ // Truncate long text
28
+ const shortText = truncate(
29
+ 'This is a very long text that needs to be shortened',
30
+ 20,
31
+ );
32
+ console.log(shortText); // 'This is a very long...'
33
+
34
+ // Capitalize text
35
+ const capitalized = capitalize('hello world');
36
+ console.log(capitalized); // 'Hello world'
37
+
38
+ // Create a URL-friendly slug
39
+ const slug = slugify('Hello World! This is a test');
40
+ console.log(slug); // 'hello-world-this-is-a-test'
41
+ ```
42
+
43
+ ### File Path Utilities
44
+
45
+ ```tsx
46
+ import {getFileExtension, joinPaths, normalizePath} from '@sqlrooms/utils';
47
+
48
+ // Get file extension
49
+ const ext = getFileExtension('document.pdf');
50
+ console.log(ext); // 'pdf'
51
+
52
+ // Join path segments
53
+ const fullPath = joinPaths('/base/path', 'subfolder', 'file.txt');
54
+ console.log(fullPath); // '/base/path/subfolder/file.txt'
55
+
56
+ // Normalize a path
57
+ const normalized = normalizePath('/path//to/../folder/./file.txt');
58
+ console.log(normalized); // '/path/folder/file.txt'
59
+ ```
60
+
61
+ ### JSON Utilities
62
+
63
+ ```tsx
64
+ import {safeJsonParse} from '@sqlrooms/utils';
65
+
66
+ // Safely parse JSON without throwing exceptions
67
+ const result = safeJsonParse('{"name": "John", "age": 30}');
68
+ console.log(result); // { name: 'John', age: 30 }
69
+
70
+ // Handle invalid JSON gracefully
71
+ const invalid = safeJsonParse('{"name": "John", age: 30}');
72
+ console.log(invalid); // null
73
+ ```
74
+
75
+ ### Formatting Utilities
76
+
77
+ ```tsx
78
+ import {formatBytes, formatNumber, formatDate} from '@sqlrooms/utils';
79
+
80
+ // Format file size
81
+ console.log(formatBytes(1024)); // '1 KB'
82
+ console.log(formatBytes(1048576)); // '1 MB'
83
+
84
+ // Format numbers
85
+ console.log(formatNumber(1234567.89)); // '1,234,567.89'
86
+
87
+ // Format dates
88
+ console.log(formatDate(new Date(), 'yyyy-MM-dd')); // '2023-04-15'
89
+ ```
90
+
91
+ ## Advanced Features
92
+
93
+ - **Type Safety**: All utilities are fully typed with TypeScript
94
+ - **Browser Compatibility**: Works in all modern browsers
95
+ - **Tree-Shakable**: Import only what you need to minimize bundle size
96
+ - **No Dependencies**: Zero external runtime dependencies
97
+
98
+ For more information, visit the SQLRooms documentation.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * {@include ../README.md}
3
+ * @packageDocumentation
4
+ */
1
5
  export * from './color';
2
6
  export * from './format';
3
7
  export * from './helpers';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * {@include ../README.md}
3
+ * @packageDocumentation
4
+ */
1
5
  export * from './color';
2
6
  export * from './format';
3
7
  export * from './helpers';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC","sourcesContent":["export * from './color';\nexport * from './format';\nexport * from './helpers';\nexport * from './random';\nexport * from './str';\nexport * from './xhr';\nexport * from './filepaths';\nexport {safeJsonParse} from './json';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport * from './color';\nexport * from './format';\nexport * from './helpers';\nexport * from './random';\nexport * from './str';\nexport * from './xhr';\nexport * from './filepaths';\nexport {safeJsonParse} from './json';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/utils",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -41,5 +41,5 @@
41
41
  "react": "^19.0.0",
42
42
  "usehooks-ts": "^3.1.1"
43
43
  },
44
- "gitHead": "f46dfe6b5d135e1a039b49b3ba71cda7150eab0f"
44
+ "gitHead": "8be65f051c588d3a963f721322429657913b6c63"
45
45
  }