Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ts-migration): migrates ndjsonstream to typescript #2053

Merged

Conversation

seaerchin
Copy link
Contributor

Part 2 of extracting admin downloads

Problem

ndjsonstream was previously written in javascript, which lacked type-safety. this meant that consumers did not know the concrete types which makes it hard to reliably use the stream and to troubleshoot.

Solution

  1. refactored the file to use typescript rather than javascript for type-safety
  2. rewrote the code so that the underlying intention is clear.

Notes

  1. the original authors utilize a try/catch block for ndjsonstream so that enqueue does not fail. however, enqueue only throws on TypeError, where the controller is not a ReadableDefaultStream. i'm currently unsure if this would ever happen (for once, the mozilla docs are unclear about where this controller originates from) but i left it in because it's additional safety

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible

@seaerchin seaerchin force-pushed the refactor/migrate-ndjsonstream branch from 3ad5c64 to a3c6885 Compare June 2, 2021 05:09
@seaerchin seaerchin requested a review from mantariksh June 4, 2021 04:12
@seaerchin seaerchin requested a review from karrui June 7, 2021 10:26
@seaerchin seaerchin changed the base branch from refactor/process-decrypted-content to refactor/extract-admin-submissions June 8, 2021 03:05
@seaerchin seaerchin changed the base branch from refactor/extract-admin-submissions to refactor/process-decrypted-content June 8, 2021 03:06
@seaerchin seaerchin requested a review from karrui June 8, 2021 03:07
Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@karrui karrui merged this pull request into refactor/process-decrypted-content Jun 9, 2021
@karrui karrui deleted the refactor/migrate-ndjsonstream branch June 9, 2021 02:52
@karrui karrui restored the refactor/migrate-ndjsonstream branch June 9, 2021 02:53
@karrui
Copy link
Contributor

karrui commented Jun 9, 2021

Will be reopening into develop branch since this is standalone

seaerchin added a commit that referenced this pull request Jun 9, 2021
* feat(ndjsonstream): refactored ndjsonstream and removed old js version

* refactor(submissions.client.factory): updated callsite to use new version of ndjsonstream

* revert(ndjsonstream): adds data_buf back to prevent regression

* fix(ndjsonstream): fixed errorneous initial conditional

* fix(ndjsontream): fixed insidious bug causing occasional off by 1

* revert(ndjsonstream): reverts slice/map to for loops

* revert(ndjsonstream): reverts single line return
@karrui karrui deleted the refactor/migrate-ndjsonstream branch June 9, 2021 03:16
seaerchin added a commit that referenced this pull request Jun 9, 2021
…2111)

* refactor(process-decrypted-content): ported over process-decrypted-content to typescript

* refactor(public/modules/forms/admin): changed callsites for process-decrypted-content

* refactor(process-decrypted-content): updated type predicate

* refactor(process-decrypted-content): inlined typeguard for neatness

* refactor(ts-migration): migrates ndjsonstream to typescript (#2053)

* feat(ndjsonstream): refactored ndjsonstream and removed old js version

* refactor(submissions.client.factory): updated callsite to use new version of ndjsonstream

* revert(ndjsonstream): adds data_buf back to prevent regression

* fix(ndjsonstream): fixed errorneous initial conditional

* fix(ndjsontream): fixed insidious bug causing occasional off by 1

* revert(ndjsonstream): reverts slice/map to for loops

* revert(ndjsonstream): reverts single line return
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.

3 participants