Clean up message arguments #80

Merged
merged 1 commit into from Dec 31, 2012

Projects

None yet

2 participants

@gjohnson
Collaborator

Since we actually handle the arrays in Socket.prototype.pack we can just pass it right along.

See inline comments.

Closes #79.

@gjohnson gjohnson commented on the diff Dec 30, 2012
lib/sockets/req.js
@@ -78,15 +79,9 @@ ReqSocket.prototype.send = function(msg){
var socks = this.socks
, len = socks.length
, sock = socks[this.n++ % len]
- , args = [];
-
- if (Array.isArray(msg)) {
- args = msg;
- } else {
- for (var i = 0; i < arguments.length; ++i) {
- args[i] = arguments[i];
- }
- }
gjohnson
gjohnson Dec 30, 2012 Collaborator

We still need to make sure we actually have an array here because of the pushing/unshift to grab the callback.

@gjohnson gjohnson commented on the diff Dec 30, 2012
lib/utils.js
@@ -0,0 +1,19 @@
+
+/**
+ * Slice helper.
+ *
+ * @api private
+ * @param {Arguments} args
+ * @return {Array}
+ */
+
gjohnson
gjohnson Dec 30, 2012 Collaborator

Not really a true slice() without the offset, but whatever.... can change the name if we need to.

Owner
tj commented Dec 31, 2012

LGTM! thanks man

@tj tj merged commit 8f47de7 into tj:master Dec 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment