Skip to content

Refactor array submodules#39

Merged
cs01 merged 3 commits intomainfrom
refactor-array-submodules
Feb 23, 2026
Merged

Refactor array submodules#39
cs01 merged 3 commits intomainfrom
refactor-array-submodules

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Feb 23, 2026

Refactor array codegen into submodules

Break down the monolithic array.ts (3500+ lines) into focused submodule files under array/, matching the pattern already used by string/ submodules.

What changed

  • array.ts — reduced from ~3500 lines to a thin facade (~210 lines) that delegates to submodules
  • array/search-predicate.ts (new) — find, some, every, includes with their string-array variants
  • array/iteration.ts (new) — filter, forEach, reduce, map with their string-array variants
  • array/combine.ts (new) — join, slice, concat, spread literals with their string-array variants
  • array/context.ts — added shared loadArrayMeta and detectArrayType helpers, unified on IGeneratorContext
  • array/literal.ts, array/mutators.ts — minor cleanup to use unified IGeneratorContext

Design

  • All submodule functions take IGeneratorContext directly (same pattern as string submodules)
  • findIndex and sort keep predicate/comparator resolution in the facade since they need pre-resolved values before delegating
  • Shared helpers (loadArrayMeta, detectArrayType) live in context.ts to avoid name collisions across submodule files
  • .claude/rules.md updated to document the new submodule structure

Test plan

  • All 29 array test fixtures pass with native compiler
  • Full 3-stage self-hosting passes (Stage 0 → Stage 1 → Stage 2)
  • TypeScript compiles cleanly

@cs01 cs01 force-pushed the refactor-array-submodules branch from d25bf90 to 6183a46 Compare February 23, 2026 04:05
@cs01 cs01 force-pushed the refactor-array-submodules branch from 6183a46 to 20c84fb Compare February 23, 2026 04:07
@cs01 cs01 merged commit 9fcb0da into main Feb 23, 2026
14 checks passed
@cs01 cs01 deleted the refactor-array-submodules branch February 23, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant