UNPKG

jsdav-ext

Version:

jsDAV allows you to easily add WebDAV support to a NodeJS application. jsDAV is meant to cover the entire standard, and attempts to allow integration using an easy to understand API.

38 lines (30 loc) 1.02 kB
/* * @package jsDAV * @subpackage shared * @copyright Copyright(c) 2013 Mike de Boer. <info AT mikedeboer DOT nl> * @author Mike de Boer <info AT mikedeboer DOT nl> * @license http://github.com/mikedeboer/jsDAV/blob/master/LICENSE MIT License */ exports.fromMultiBulk = function(data) { if (!data) return []; if (!Array.isArray(data)) return [data.toString()]; return data.map(function(buffer) { if (!buffer) return ""; else if (Array.isArray(buffer)) return exports.fromMultiBulk(buffer); else return buffer.toString(); }); }; exports.getConnection = function(options, callback) { options = options || {}; var client = require("redis").createClient(options.port, options.host, options); if (options.password) client.auth(options.password); if (typeof options.index == "number") client.select(options.index); callback(null, client); };