@cocreate/utils 1.40.1 → 1.41.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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.41.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.40.1...v1.41.0) (2025-11-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add uid function to generate UUIDs with customizable length ([7103971](https://github.com/CoCreate-app/CoCreate-utils/commit/71039712fe19d37bacdd5cd23db3366dd6b16ccb))
|
|
7
|
+
|
|
1
8
|
## [1.40.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.40.0...v1.40.1) (2025-10-10)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -114,6 +114,21 @@
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
function uid(length = 36) {
|
|
118
|
+
let pattern = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
119
|
+
if (length > 36) {
|
|
120
|
+
length = 36; // If requested length is more than 36, set it to 36.
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let uuid = pattern.replace(/[xy]/g, function (c) {
|
|
124
|
+
var r = (Math.random() * 16) | 0;
|
|
125
|
+
var v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
126
|
+
return v.toString(16);
|
|
127
|
+
}).substring(0, length); // Truncate to the requested length.
|
|
128
|
+
|
|
129
|
+
return uuid;
|
|
130
|
+
}
|
|
131
|
+
|
|
117
132
|
function checkValue(value) {
|
|
118
133
|
if (/{{\s*([\w\W]+)\s*}}/g.test(value)) return false;
|
|
119
134
|
else return true;
|
|
@@ -1286,6 +1301,7 @@
|
|
|
1286
1301
|
return {
|
|
1287
1302
|
getRelativePath,
|
|
1288
1303
|
ObjectId,
|
|
1304
|
+
uid,
|
|
1289
1305
|
checkValue,
|
|
1290
1306
|
isValidDate,
|
|
1291
1307
|
dotNotationToObject,
|