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

feat: handle stream and file inputs #28

Merged
merged 3 commits into from
Oct 25, 2024
Merged

Conversation

DoneDeal0
Copy link
Owner

@DoneDeal0 DoneDeal0 commented Oct 17, 2024

FEATURE

streamListDiff now supports array, stream, and file inputs for maximum performance, polyvalence, and optimal memory usage.


Import

// If you are in a server environment
import { streamListDiff } from "@donedeal0/superdiff/server";
// If you are in a browser environment
import { streamListDiff } from "@donedeal0/superdiff/client";

Input

You can send streams, file paths, or arrays as input:

If you are in a server environment

    // for a simple array
    const stream = [{ id: 1, name: "hello" }]
    // for a large array 
    const stream = Readable.from(list, { objectMode: true });
    // for a local file
    const stream = path.resolve(__dirname, "./list.json");
   

If you are in a browser environment

    // for a simple array 
    const stream = [{ id: 1, name: "hello" }]
    // for a large array 
    const stream = new ReadableStream({
      start(controller) {
        list.forEach((value) => controller.enqueue(value));
        controller.close();
      },
    }); 
    // for a local file
    const stream = new File([JSON.stringify(file)], "file.json", { type: "application/json" }); 
    // for a file input
    const stream = e.target.files[0]; 

See the documentation for more details.

@DoneDeal0 DoneDeal0 self-assigned this Oct 17, 2024
@DoneDeal0 DoneDeal0 changed the title [DRAFT] feat: handle huge stream inputs [DRAFT] feat: handle stream and file inputs Oct 20, 2024
@DoneDeal0 DoneDeal0 added the enhancement New feature or request label Oct 20, 2024
@DoneDeal0 DoneDeal0 force-pushed the support-stream-input branch 3 times, most recently from c83b2d5 to 5ec6440 Compare October 21, 2024 19:11
@DoneDeal0 DoneDeal0 changed the title [DRAFT] feat: handle stream and file inputs feat: handle stream and file inputs Oct 21, 2024
@DoneDeal0 DoneDeal0 marked this pull request as ready for review October 24, 2024 13:23
BREAKING CHANGE: streamListDiff is now imported from @donedeal0/superdiff/client or @donedeal/superdiff/server depending on your environment
@DoneDeal0 DoneDeal0 merged commit 4d22c68 into master Oct 25, 2024
1 check passed
@DoneDeal0 DoneDeal0 deleted the support-stream-input branch October 25, 2024 15:33
Copy link

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant