@kubb/ast 5.0.0-alpha.43 → 5.0.0-alpha.45

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 CHANGED
@@ -638,18 +638,22 @@ function combineExports(exports) {
638
638
  const result = [];
639
639
  const namedByPath = /* @__PURE__ */ new Map();
640
640
  const seen = /* @__PURE__ */ new Set();
641
- for (const curr of [...exports].sort((a, b) => {
642
- const ka = sortKey(a);
643
- const kb = sortKey(b);
644
- return ka < kb ? -1 : ka > kb ? 1 : 0;
645
- })) {
641
+ const keyed = exports.map((node) => ({
642
+ node,
643
+ key: sortKey(node)
644
+ }));
645
+ keyed.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
646
+ for (const { node: curr } of keyed) {
646
647
  const { name, path, isTypeOnly, asAlias } = curr;
647
648
  if (Array.isArray(name)) {
648
649
  if (!name.length) continue;
649
650
  const key = pathTypeKey(path, isTypeOnly);
650
651
  const existing = namedByPath.get(key);
651
- if (existing && Array.isArray(existing.name)) existing.name = [...new Set([...existing.name, ...name])];
652
- else {
652
+ if (existing && Array.isArray(existing.name)) {
653
+ const merged = new Set(existing.name);
654
+ for (const n of name) merged.add(n);
655
+ existing.name = [...merged];
656
+ } else {
653
657
  const newItem = {
654
658
  ...curr,
655
659
  name: [...new Set(name)]
@@ -678,11 +682,12 @@ function combineImports(imports, exports, source) {
678
682
  const result = [];
679
683
  const namedByPath = /* @__PURE__ */ new Map();
680
684
  const seen = /* @__PURE__ */ new Set();
681
- for (const curr of [...imports].sort((a, b) => {
682
- const ka = sortKey(a);
683
- const kb = sortKey(b);
684
- return ka < kb ? -1 : ka > kb ? 1 : 0;
685
- })) {
685
+ const keyed = imports.map((node) => ({
686
+ node,
687
+ key: sortKey(node)
688
+ }));
689
+ keyed.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
690
+ for (const { node: curr } of keyed) {
686
691
  if (curr.path === curr.root) continue;
687
692
  const { path, isTypeOnly } = curr;
688
693
  let { name } = curr;
@@ -691,8 +696,11 @@ function combineImports(imports, exports, source) {
691
696
  if (!name.length) continue;
692
697
  const key = pathTypeKey(path, isTypeOnly);
693
698
  const existing = namedByPath.get(key);
694
- if (existing && Array.isArray(existing.name)) existing.name = [...new Set([...existing.name, ...name])];
695
- else {
699
+ if (existing && Array.isArray(existing.name)) {
700
+ const merged = new Set(existing.name);
701
+ for (const n of name) merged.add(n);
702
+ existing.name = [...merged];
703
+ } else {
696
704
  const newItem = {
697
705
  ...curr,
698
706
  name