fix(util): make objectOfArraysAsArrayOfObjects work with native array methods#610
Merged
Merged
Conversation
Coverage Report
File CoverageNo changed files found. |
… methods The proxy backs onto an empty `[]`, so `HasProperty` for a numeric index returned false. Native array methods that probe presence (`slice`, `concat`, `at`, `flat`, ...) therefore treated every row as an absent hole and silently dropped the data — e.g. `proxy.slice(0, 2)` returned a sparse array whose spread became `[undefined, undefined]`. Add a `has` trap that reports in-range indices (and `length`) as present, and implement `slice` explicitly to mirror the existing materializing methods. Regression cases (slice, the `in` operator, at/concat) added to the existing proxy suite in @workglow/test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BNNJyBunCkJhiUhdM9ys7V
ba333e7 to
e84daf2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
objectOfArraysAsArrayOfObjectsproxy backs onto an empty[], soHasPropertyfor a numeric index returnedfalse. Native array methods that probe presence (slice,concat,at,flat, …) therefore treated every row as an absent hole and silently dropped the data:This surfaced downstream in
@workglow/sec, whereStoreSubmissionFilingsTasksliced the proxy to batch filings and then spread the result into a bulk insert — every filing became anundefinedrow and the insert crashed, storing zero filings. (That caller has its own fix; this is the root cause.)Fix
hastrap that reports in-range numeric indices (andlength) as present, so native methods that rely onHasPropertysee real rows.sliceexplicitly, mirroring the file's other materializing methods (map/filter/forEach/…) and guarding the exact method that regressed.Test
Regression cases (slice returns dense rows, the
inoperator,at/concat) added to the existing proxy suite in the dedicated@workglow/testpackage (packages/test/src/test/util/arrayAsObjectProxy.test.ts) — 14 pass against a freshly built@workglow/util.🤖 Generated with Claude Code
https://claude.ai/code/session_01BNNJyBunCkJhiUhdM9ys7V