denwa-web-shared 1.0.49 → 1.0.50

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.
@@ -429,16 +429,23 @@ const uuidToStringId = (uuid2, length = 18) => {
429
429
  return cleanUuid.slice(-length);
430
430
  };
431
431
  const uuidToNumericId = (uuid2, maxDigits = 18) => {
432
- const hex = uuid2.replace(/-/g, "");
433
- const safeHex = hex.slice(-14);
434
- const num = parseInt(safeHex, 16);
435
- let numStr = num.toString();
436
- if (numStr.length < maxDigits) {
437
- numStr = numStr.padStart(maxDigits, "0");
438
- } else if (numStr.length > maxDigits) {
439
- numStr = numStr.slice(-maxDigits);
432
+ const cleanUuid = uuid2.replace(/-/g, "");
433
+ let hash = 0;
434
+ for (let i = 0; i < cleanUuid.length; i++) {
435
+ const char = cleanUuid.charCodeAt(i);
436
+ hash = (hash << 5) - hash + char;
437
+ hash = hash & hash;
438
+ }
439
+ let result = Math.abs(hash).toString();
440
+ if (result.length < maxDigits) {
441
+ const segments = cleanUuid.match(/.{1,4}/g) || [];
442
+ for (const segment of segments) {
443
+ const segmentNum = parseInt(segment, 16);
444
+ result += Math.abs(segmentNum).toString();
445
+ if (result.length >= maxDigits) break;
446
+ }
440
447
  }
441
- return numStr;
448
+ return result.slice(0, maxDigits);
442
449
  };
443
450
  const escapeXml = (str) => {
444
451
  if (!str) return "";
@@ -427,16 +427,23 @@ const uuidToStringId = (uuid2, length = 18) => {
427
427
  return cleanUuid.slice(-length);
428
428
  };
429
429
  const uuidToNumericId = (uuid2, maxDigits = 18) => {
430
- const hex = uuid2.replace(/-/g, "");
431
- const safeHex = hex.slice(-14);
432
- const num = parseInt(safeHex, 16);
433
- let numStr = num.toString();
434
- if (numStr.length < maxDigits) {
435
- numStr = numStr.padStart(maxDigits, "0");
436
- } else if (numStr.length > maxDigits) {
437
- numStr = numStr.slice(-maxDigits);
430
+ const cleanUuid = uuid2.replace(/-/g, "");
431
+ let hash = 0;
432
+ for (let i = 0; i < cleanUuid.length; i++) {
433
+ const char = cleanUuid.charCodeAt(i);
434
+ hash = (hash << 5) - hash + char;
435
+ hash = hash & hash;
436
+ }
437
+ let result = Math.abs(hash).toString();
438
+ if (result.length < maxDigits) {
439
+ const segments = cleanUuid.match(/.{1,4}/g) || [];
440
+ for (const segment of segments) {
441
+ const segmentNum = parseInt(segment, 16);
442
+ result += Math.abs(segmentNum).toString();
443
+ if (result.length >= maxDigits) break;
444
+ }
438
445
  }
439
- return numStr;
446
+ return result.slice(0, maxDigits);
440
447
  };
441
448
  const escapeXml = (str) => {
442
449
  if (!str) return "";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "denwa-web-shared",
3
3
  "private": false,
4
- "version": "1.0.49",
4
+ "version": "1.0.50",
5
5
  "type": "module",
6
6
  "author": "Denwa",
7
7
  "main": "dist/denwa-web-shared.cjs.js",