@kubb/ast 5.0.0-beta.89 → 5.0.0-beta.91

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
@@ -1085,41 +1085,6 @@ const VISITOR_KEYS = Object.fromEntries(nodeDefs.flatMap((def) => def.children ?
1085
1085
  * definition's `visitorKey`.
1086
1086
  */
1087
1087
  const VISITOR_KEY_BY_KIND = Object.fromEntries(nodeDefs.flatMap((def) => def.visitorKey ? [[def.kind, def.visitorKey]] : []));
1088
- /**
1089
- * Creates a small async concurrency limiter.
1090
- *
1091
- * At most `concurrency` tasks are in flight at once. Extra tasks are queued.
1092
- *
1093
- * @example
1094
- * ```ts
1095
- * const limit = createLimit(2)
1096
- * for (const task of [taskA, taskB, taskC]) {
1097
- * await limit(() => task())
1098
- * }
1099
- * // only 2 tasks run at the same time
1100
- * ```
1101
- */
1102
- function createLimit(concurrency) {
1103
- let active = 0;
1104
- const queue = [];
1105
- function next() {
1106
- if (active < concurrency && queue.length > 0) {
1107
- active++;
1108
- queue.shift()();
1109
- }
1110
- }
1111
- return function limit(fn) {
1112
- return new Promise((resolve, reject) => {
1113
- queue.push(() => {
1114
- Promise.resolve(fn()).then(resolve, reject).finally(() => {
1115
- active--;
1116
- next();
1117
- });
1118
- });
1119
- next();
1120
- });
1121
- };
1122
- }
1123
1088
  const visitorKeysByKind = VISITOR_KEYS;
1124
1089
  /**
1125
1090
  * Returns `true` when `value` is an AST node (an object carrying a `kind`).
@@ -1155,9 +1120,9 @@ function* getChildren(node, recurse) {
1155
1120
  * context. The result is a replacement node, a collected value, or `undefined`
1156
1121
  * when no callback is registered for the kind.
1157
1122
  *
1158
- * Shared by `walk`, `transform`, and `collectLazy` so node-kind dispatch lives
1159
- * in one place. `TResult` is the caller's expected return: the same node type
1160
- * for `transform`, the collected value type for `collectLazy`, ignored for `walk`.
1123
+ * Shared by `transform` and `collectLazy` so node-kind dispatch lives in one place.
1124
+ * `TResult` is the caller's expected return: the same node type for `transform`,
1125
+ * the collected value type for `collectLazy`.
1161
1126
  */
1162
1127
  function applyVisitor(node, visitor, parent) {
1163
1128
  const key = VISITOR_KEY_BY_KIND[node.kind];
@@ -1165,37 +1130,6 @@ function applyVisitor(node, visitor, parent) {
1165
1130
  const fn = visitor[key];
1166
1131
  return fn?.(node, { parent });
1167
1132
  }
1168
- /**
1169
- * Async depth-first traversal for side effects. Visitor return values are
1170
- * ignored. Use `transform` when you want to rewrite nodes.
1171
- *
1172
- * Sibling nodes at each depth run concurrently up to `options.concurrency`
1173
- * (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor
1174
- * work. Lower values reduce memory pressure.
1175
- *
1176
- * @example Log every operation
1177
- * ```ts
1178
- * await walk(root, {
1179
- * operation(node) {
1180
- * console.log(node.operationId)
1181
- * },
1182
- * })
1183
- * ```
1184
- *
1185
- * @example Only visit the root node
1186
- * ```ts
1187
- * await walk(root, { depth: 'shallow', input: () => {} })
1188
- * ```
1189
- */
1190
- async function walk(node, options) {
1191
- return _walk(node, options, (options.depth ?? visitorDepths.deep) === visitorDepths.deep, createLimit(options.concurrency ?? 30), void 0);
1192
- }
1193
- async function _walk(node, visitor, recurse, limit, parent) {
1194
- await limit(() => applyVisitor(node, visitor, parent));
1195
- let pending;
1196
- for (const child of getChildren(node, recurse)) (pending ??= []).push(_walk(child, visitor, recurse, limit, node));
1197
- if (pending) await Promise.all(pending);
1198
- }
1199
1133
  function transform(node, options) {
1200
1134
  const { depth, parent, ...visitor } = options;
1201
1135
  return transformNode(node, visitor, (depth ?? visitorDepths.deep) === visitorDepths.deep, parent);
@@ -1978,8 +1912,7 @@ var exports_exports = /* @__PURE__ */ __exportAll({
1978
1912
  syncSchemaRef: () => syncSchemaRef,
1979
1913
  textDef: () => textDef,
1980
1914
  transform: () => transform,
1981
- typeDef: () => typeDef,
1982
- walk: () => walk
1915
+ typeDef: () => typeDef
1983
1916
  });
1984
1917
  //#endregion
1985
1918
  exports.applyMacros = applyMacros;
@@ -2046,6 +1979,5 @@ exports.syncSchemaRef = syncSchemaRef;
2046
1979
  exports.textDef = textDef;
2047
1980
  exports.transform = transform;
2048
1981
  exports.typeDef = typeDef;
2049
- exports.walk = walk;
2050
1982
 
2051
1983
  //# sourceMappingURL=index.cjs.map