@avalanche-io/c4 1.0.18 → 1.0.19
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/dist/index.js +1 -1
- package/dist/naturalsort.d.ts.map +1 -1
- package/dist/naturalsort.js +24 -24
- package/dist/naturalsort.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// C4 Universal Content Identification — TypeScript Implementation
|
|
2
|
-
// @avalanche-io/c4 v1.0.
|
|
2
|
+
// @avalanche-io/c4 v1.0.19
|
|
3
3
|
// Core ID
|
|
4
4
|
export { C4ID, identify, identifyBytes, parse } from './id.js';
|
|
5
5
|
export { identifyContent, tryCanonicalizeC4m } from './identify-content.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naturalsort.d.ts","sourceRoot":"","sources":["../src/naturalsort.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"naturalsort.d.ts","sourceRoot":"","sources":["../src/naturalsort.ts"],"names":[],"mappings":"AAuEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CA6BzD"}
|
package/dist/naturalsort.js
CHANGED
|
@@ -19,12 +19,7 @@ function segmentString(s) {
|
|
|
19
19
|
}
|
|
20
20
|
else if (isDigit !== isNumeric) {
|
|
21
21
|
// Transition between text and numeric
|
|
22
|
-
|
|
23
|
-
text: current,
|
|
24
|
-
isNumeric,
|
|
25
|
-
numValue: isNumeric ? parseNumber(current) : 0,
|
|
26
|
-
};
|
|
27
|
-
segments.push(seg);
|
|
22
|
+
segments.push({ text: current, isNumeric });
|
|
28
23
|
current = ch;
|
|
29
24
|
isNumeric = isDigit;
|
|
30
25
|
}
|
|
@@ -34,21 +29,29 @@ function segmentString(s) {
|
|
|
34
29
|
}
|
|
35
30
|
// Add final segment
|
|
36
31
|
if (current.length > 0) {
|
|
37
|
-
segments.push({
|
|
38
|
-
text: current,
|
|
39
|
-
isNumeric,
|
|
40
|
-
numValue: isNumeric ? parseNumber(current) : 0,
|
|
41
|
-
});
|
|
32
|
+
segments.push({ text: current, isNumeric });
|
|
42
33
|
}
|
|
43
34
|
return segments;
|
|
44
35
|
}
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
// compareDigitRuns orders two runs of ASCII digits as integers of any
|
|
37
|
+
// length, with no numeric parse (a double keeps 15-16 digits; a 17-digit
|
|
38
|
+
// run would lose its last digit and two runs could compare equal):
|
|
39
|
+
// leading zeros are dropped, a shorter remainder is the smaller value,
|
|
40
|
+
// equal lengths compare digit by digit, and equal values put the shorter
|
|
41
|
+
// spelling first ("1" < "01"). Returns -1, 0 or 1.
|
|
42
|
+
function compareDigitRuns(a, b) {
|
|
43
|
+
const ta = a.replace(/^0+/, "");
|
|
44
|
+
const tb = b.replace(/^0+/, "");
|
|
45
|
+
if (ta.length !== tb.length) {
|
|
46
|
+
return ta.length < tb.length ? -1 : 1;
|
|
47
|
+
}
|
|
48
|
+
if (ta !== tb) {
|
|
49
|
+
return ta < tb ? -1 : 1;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
if (a.length !== b.length) {
|
|
52
|
+
return a.length < b.length ? -1 : 1;
|
|
53
|
+
}
|
|
54
|
+
return 0;
|
|
52
55
|
}
|
|
53
56
|
// naturalLess compares two strings using natural sorting.
|
|
54
57
|
// Natural sorting handles numeric sequences intelligently:
|
|
@@ -62,13 +65,10 @@ export function naturalLess(a, b) {
|
|
|
62
65
|
const segA = segsA[i];
|
|
63
66
|
const segB = segsB[i];
|
|
64
67
|
if (segA.isNumeric && segB.isNumeric) {
|
|
65
|
-
// Both numeric: compare as integers
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Equal values: shorter representation first
|
|
70
|
-
if (segA.text.length !== segB.text.length) {
|
|
71
|
-
return segA.text.length < segB.text.length;
|
|
68
|
+
// Both numeric: compare as integers of any length
|
|
69
|
+
const c = compareDigitRuns(segA.text, segB.text);
|
|
70
|
+
if (c !== 0) {
|
|
71
|
+
return c < 0;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
else if (segA.isNumeric !== segB.isNumeric) {
|
package/dist/naturalsort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naturalsort.js","sourceRoot":"","sources":["../src/naturalsort.ts"],"names":[],"mappings":"AAAA,4CAA4C;
|
|
1
|
+
{"version":3,"file":"naturalsort.js","sourceRoot":"","sources":["../src/naturalsort.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAO5C,wEAAwE;AACxE,4EAA4E;AAC5E,sCAAsC;AACtC,SAAS,aAAa,CAAC,CAAS;IAC9B,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,QAAQ,GAAc,EAAE,CAAA;IAC9B,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,IAAI,KAAK,GAAG,IAAI,CAAA;IAEhB,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,CAAA;QAEtC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,GAAG,KAAK,CAAA;YACb,SAAS,GAAG,OAAO,CAAA;YACnB,OAAO,GAAG,EAAE,CAAA;QACd,CAAC;aAAM,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACjC,sCAAsC;YACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;YAE3C,OAAO,GAAG,EAAE,CAAA;YACZ,SAAS,GAAG,OAAO,CAAA;QACrB,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,EAAE,CAAA;QACf,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