Git Product home page Git Product logo

Comments (4)

isaacs avatar isaacs commented on July 23, 2024

Hm... I do actually (in npm) have some use cases where I want to fetch something, and know the exact size ahead of time, so anything larger or smaller than that size is an error.

It doesn't look like size is in the WhatWG fetch() spec, so both node-fetch and minipass-fetch are sort of forging their own path here.

Would you be happy if minipass-fetch provided a maxSize option to set a maximum, and left size to be "it must be this exact size"?

from minipass-fetch.

Pizzacus avatar Pizzacus commented on July 23, 2024

Hmm... Not sure if that would be the best, because node-fetch uses size as the max size, and this package is meant to be a reimplementation of node-fetch.

Maybe it would be better if the current "exact size" option was moved to another option. Or maybe a new option could let the user decide how it should behave. (A .strictSize boolean?) 🤔

from minipass-fetch.

isaacs avatar isaacs commented on July 23, 2024

Well, this is a reimplementation/fork of node-fetch, but I think in terms of intended API, they're both aiming to be an implementation of the WhatWG fetch() spec for Node.js. And WhatWG fetch() doesn't have a size option at all, so this is an extension of the spec either way. We're not strictly committed to matching node-fetch in every point. For example, minipass-fetch supports a trailers promise, which was dropped from the spec due to a lack of browser commitment, and never made it into node-fetch. (I might opt to drop it from minipass-fetch, since it's pretty niche anyway, but for now it's not hurting anyone.)

But you do make a good point, it would be simpler to switch back and forth between them if the options that do exist in both had the same semantics. And node-fetch came first. Ok, I'm convinced. In the use case where I'm passing size, it also passes size to cacache (where it does mean "exact size") so any errors on that will get caught, just in a different spot.

from minipass-fetch.

jadbox avatar jadbox commented on July 23, 2024

I also just hit the same issue as I was expecting that size would limit the maximum size allowed to be returned.

from minipass-fetch.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.