ewenig/node-mpdsocket — pull request #1 by sgentle (2011-10-30 16:16:55+00:00)
Title: A different direction for callbacks and return values

Hi there,

I've been using mpdsocket to power the backend for a restful API I'm writing on top of mpd. I made a couple changes in my branch that I thought you might find relevant.

1. Everything behaves a little strangely if there is data split over multiple packets, so I made that data accumulate better

2. I altered the callback behaviour to be ```(err, response)``` instead of just ```(response)```, this is in line with nodejs's callback error handling but, more importantly, removes the need to have special _whatnot values.

3. I removed _ordered_list and made it just return an array.

4. I added support for non key-value string return values, in case mpd adds any.

All in all, return values now look like:

"I am a string"

{"key": "value", "key2": "value2"}

[{"key": "value"}, {"key": "value"}]

["I am a string", "I am another string"]

Not sure if that's useful to you, but it made my code a lot cleaner.