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

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.cjs CHANGED
@@ -661,18 +661,22 @@ function combineExports(exports) {
661
661
  const result = [];
662
662
  const namedByPath = /* @__PURE__ */ new Map();
663
663
  const seen = /* @__PURE__ */ new Set();
664
- for (const curr of [...exports].sort((a, b) => {
665
- const ka = sortKey(a);
666
- const kb = sortKey(b);
667
- return ka < kb ? -1 : ka > kb ? 1 : 0;
668
- })) {
664
+ const keyed = exports.map((node) => ({
665
+ node,
666
+ key: sortKey(node)
667
+ }));
668
+ keyed.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
669
+ for (const { node: curr } of keyed) {
669
670
  const { name, path, isTypeOnly, asAlias } = curr;
670
671
  if (Array.isArray(name)) {
671
672
  if (!name.length) continue;
672
673
  const key = pathTypeKey(path, isTypeOnly);
673
674
  const existing = namedByPath.get(key);
674
- if (existing && Array.isArray(existing.name)) existing.name = [...new Set([...existing.name, ...name])];
675
- else {
675
+ if (existing && Array.isArray(existing.name)) {
676
+ const merged = new Set(existing.name);
677
+ for (const n of name) merged.add(n);
678
+ existing.name = [...merged];
679
+ } else {
676
680
  const newItem = {
677
681
  ...curr,
678
682
  name: [...new Set(name)]
@@ -701,11 +705,12 @@ function combineImports(imports, exports, source) {
701
705
  const result = [];
702
706
  const namedByPath = /* @__PURE__ */ new Map();
703
707
  const seen = /* @__PURE__ */ new Set();
704
- for (const curr of [...imports].sort((a, b) => {
705
- const ka = sortKey(a);
706
- const kb = sortKey(b);
707
- return ka < kb ? -1 : ka > kb ? 1 : 0;
708
- })) {
708
+ const keyed = imports.map((node) => ({
709
+ node,
710
+ key: sortKey(node)
711
+ }));
712
+ keyed.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
713
+ for (const { node: curr } of keyed) {
709
714
  if (curr.path === curr.root) continue;
710
715
  const { path, isTypeOnly } = curr;
711
716
  let { name } = curr;
@@ -714,8 +719,11 @@ function combineImports(imports, exports, source) {
714
719
  if (!name.length) continue;
715
720
  const key = pathTypeKey(path, isTypeOnly);
716
721
  const existing = namedByPath.get(key);
717
- if (existing && Array.isArray(existing.name)) existing.name = [...new Set([...existing.name, ...name])];
718
- else {
722
+ if (existing && Array.isArray(existing.name)) {
723
+ const merged = new Set(existing.name);
724
+ for (const n of name) merged.add(n);
725
+ existing.name = [...merged];
726
+ } else {
719
727
  const newItem = {
720
728
  ...curr,
721
729
  name