function deserialize()

in lib/redis.js [59:80]


function deserialize(string) {
  switch(string.charAt(0)) {
    case '+': { // Simple String
      // Read line content until end of line
      return string.substring(1, string.indexOf("\r\n"));
    }
    case ':': { // Integer
      // Read line content until end of line, and cast as int
      return parseInt(string.substring(1, string.indexOf("\r\n")));
    }
    case '-': { // Error
      // Read line content until end of line, and cast as error
      return new Error(string.substring(1, string.indexOf("\r\n")));
    }
    case '$': { // Bulk String
      return new Error("Unsupported Redis response type: Bulk String in response: " + string);
    }
    case '*': { // Array
      return new Error("Unsupported Redis response type: Array in response: " + string);
    }
  }
}