GithubHelp home page GithubHelp logo

Comments (6)

tomas avatar tomas commented on June 20, 2024

Haha, not overwhelmed in the least. Always happy to work with a motivated and talented coder.

Initially, needle didn't set the body as resp.body, so the only way to get the body was by using the third argument. Then I started storing the contents in resp.body an simply linking the third argument to that variable, and updated (some?) of the examples in the README to reflect this.

I'm not so sure, though, about the community "having settled" on the 2-argument callback, because of the uncountable and different scenarios for each and every app or library out there. I was actually thinking of having a way to retrieve the original, raw response besides the parsed/decoded one, although haven't really wrapped my mind around this.

Anyway, does it really hurt to have a third argument? Are there any libraries that complain about this? If so, sure, let's implement some kind of detection -- just remember to keep it lean! :)

from needle.

solatis avatar solatis commented on June 20, 2024

See my line comment in the pull request -- it illustrates the problem a bit.

As far as I'm aware, people call this

asyncFunction(function cb(err, obj) { ... });

Node.JS callback style. It's the style used in the core libraries and style generally approved of -- consider for example the visionmedia/node-thunkify library which converts "regular node functions into a function which returns a thunk", s "regular node function" being one which accepts a two-argument callback.

Having said that, I have to admit I'm really really new to Node.JS, so I could be mistaken. But generally this is an area where I know what I'm doing. :) The patch will be a few lines at most, but I feel pretty strongly about that a library such as this should behave in a standards-compliant way. Doing this correctly opens up the possibility to integrate with all kinds of libraries. I'm probably going to code a few more examples tomorrow that illustrate the flexibility this brings.

from needle.

solatis avatar solatis commented on June 20, 2024

Also, i will look into returning the raw streams. Now that we've refactored that part, all we need to do is come up with an elegant way to provide access to the 'pipeline' variable. I'll see if I can come up with something that doesn't introduce any dependencies -- but with an optional dependency, I think there are elegant ways to do this!

from needle.

tomas avatar tomas commented on June 20, 2024

Sure, go ahead. I guess something like resp.original_body or resp.raw_body would work (assuming callback mode).

I'll take a second look and merge your PR in a while.

from needle.

solatis avatar solatis commented on June 20, 2024

Nah I have something better in mind, giving access to all streams in the
pipeline without additional function calls (but staying compatible with the
current interface).

I'll come up with something tomorrow.

On Tuesday, March 25, 2014, TomΓ‘s Pollak [email protected] wrote:

Sure, go ahead. I guess something like resp.original_body or resp.raw_body
would work (assuming callback mode).

I'll take a second look and merge your PR in a while.

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-38627400
.

Sent from my iPhone

from needle.

solatis avatar solatis commented on June 20, 2024

By the way, with regards to the "original_body", it is going to look like this:

var rawStream = needle.get(...).raw ();

Notice the .raw() behind it -- elegant way to provide access. You can get access to the whole pipeline like this:

var pipeline = needle.get(...).pipeline()

But I'm not sure about that last one, might be a bit too much feature-creep.

from needle.

Related Issues (20)

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.