Skip to content

Share one set of operations between the main thread and the worker - #75

Merged
lazarusA merged 1 commit into
mainfrom
operation-sharing
Nov 2, 2026
Merged

lazarusA merged 1 commit into
mainfrom
operation-sharing

Conversation

@Karinon

@Karinon Karinon commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Every read method on NetCDF4 was implemented twice: once for the main thread and once for the Web Worker used by fromBlobLazy and fromUrl. The two copies could drift apart, and the worker's copy was untested.

All operations are now defined once, in the new src/operations.ts. Both paths run the same code, and each public method is a single call.

Because the tests run these operations on the main thread, they now also cover what the worker executes. Only the message passing and file mounting inside the worker still need a browser to test.

Small behavior changes

  • On the worker path, getDimIDs() and getVarIDs() now return an Int32Array, as the main thread already did.
  • Open and close errors are worded the same on both paths.
  • Calling a method before the dataset is initialized now gives a clear error instead of a TypeError.

@lazarusA
lazarusA merged commit 68d0961 into main Nov 2, 2026
2 checks passed
@Karinon
Karinon deleted the operation-sharing branch November 2, 2026 08:56
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.

2 participants