Skip to content

Commit

Permalink
allow others to use convertMultiBulkRepliesToUTF8
Browse files Browse the repository at this point in the history
  • Loading branch information
fictorial committed Apr 9, 2010
1 parent 1589d5d commit 331c7dd
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 58 deletions.
17 changes: 17 additions & 0 deletions lib/redis-client.js
Expand Up @@ -721,3 +721,20 @@ Client.prototype.unsubscribeFrom = function (nameOrPattern) {
this[method](nameOrPattern);
};

// Multi-bulk replies return an array of other replies. Perhaps all you care
// about is the representation of such buffers as UTF-8 encoded strings? Use
// this to convert each such Buffer to a (UTF-8 encoded) String in-place.

exports.convertMultiBulkBuffersToUTF8Strings = function (o) {
if (o instanceof Array) {
for (var i=0; i<o.length; ++i)
if (o[i] instanceof Buffer)
o[i] = o[i].utf8Slice(0, o[i].length);
} else if (o instanceof Object) {
var props = Object.getOwnPropertyNames(o);
for (var i=0; i<props.length; ++i)
if (o[props[i]] instanceof Buffer)
o[props[i]] = o[props[i]].utf8Slice(0, o[props[i]].length);
}
};

2 changes: 1 addition & 1 deletion seed.yml
Expand Up @@ -2,5 +2,5 @@
name: redis-client
description: A Redis client
tags: redis
version: 0.2.0
version: 0.2.2

0 comments on commit 331c7dd

Please sign in to comment.