var Q = require("Q")

var redisQ = function(defer) {
	return function(err, res) {
		if(err) {
			return defer.reject(err)
		}

		return defer.resolve(res)
	}
}

module.exports = function(redis) {
	
	this.brpop = function(list, timeout) {
		var defer = Q.defer()

		redis.brpop(list, timeout, redisQ(defer))

		return defer.promise
	}

	this.hmset = function(key, vals) {
		var defer = Q.defer()

		redis.hmset(key, vals, redisQ(defer))

		return defer.promise
	}

	this.hgetall = function(key) {
		var defer = Q.defer()

		redis.hgetall(key, redisQ(defer))

		return defer.promise
	}

	this.sadd = function(key, items) {
		var defer = Q.defer()

		redis.sadd(key, items, redisQ(defer))

		return defer.promise
	}

	this.sdiff = function(a, b) {
		var defer = Q.defer()

		redis.sdiff(a, b, redisQ(defer))

		return defer.promise
	}

	this.smembers = function(set) {
		var defer = Q.defer()

		redis.smembers(set, redisQ(defer))

		return defer.promise
	}

	this.sget = function(set) {
		var defer = Q.defer()

		redis.sget(set, redisQ(defer))

		return defer.promise
	}

	return this
}

var Q = require("Q")

var redisQ = function(defer) {
	return function(err, res) {
		if(err) {
			return defer.reject(err)
		}

		return defer.resolve(res)
	}
}

module.exports = function(redis) {
	
	this.brpop = function(list, timeout) {
		var defer = Q.defer()

		redis.brpop(list, timeout, redisQ(defer))

		return defer.promise
	}

	this.hmset = function(key, vals) {
		var defer = Q.defer()

		redis.hmset(key, vals, redisQ(defer))

		return defer.promise
	}

	this.hgetall = function(key) {
		var defer = Q.defer()

		redis.hgetall(key, redisQ(defer))

		return defer.promise
	}

	this.sadd = function(key, items) {
		var defer = Q.defer()

		redis.sadd(key, items, redisQ(defer))

		return defer.promise
	}

	this.sdiff = function(a, b) {
		var defer = Q.defer()

		redis.sdiff(a, b, redisQ(defer))

		return defer.promise
	}

	this.smembers = function(set) {
		var defer = Q.defer()

		redis.smembers(set, redisQ(defer))

		return defer.promise
	}

	this.sget = function(set) {
		var defer = Q.defer()

		redis.sget(set, redisQ(defer))

		return defer.promise
	}

	this.expire = function(key, time) {
		var defer = Q.defer()

		redis.expire(key, time, redisQ(defer))

		return defer.promise
	}

	this.set = function(key, val) {
		var defer = Q.defer()

		redis.set(key, val, redisQ(defer))

		return defer.promise
	}

	this.get = function(key) {
		var defer = Q.defer()

		redis.get(key, redisQ(defer))

		return defer.promise
	}

	this.del = function(key) {
		var defer = Q.defer()

		redis.del(key, redisQ(defer))

		return defer.promise
	}

	return this
}

Add more redis functions