Comparing version 0.2.0 to 0.2.1
@@ -179,20 +179,7 @@ var extend = require('deap/shallow'), | ||
if(!tags) return undefined; | ||
if(tags instanceof Array) return tags; | ||
if(typeof tags == 'string') return [tags]; | ||
tags = (tags instanceof Array) ? tags : [tags]; | ||
var rTags = []; | ||
for(var key in tags) { | ||
rTags.push([key, tags[key]].join(':')); | ||
} | ||
return Array.prototype.concat.apply( | ||
[], | ||
Object.keys(tags).map(function(name) { | ||
var values = (tags[name] instanceof Array) ? tags[name] : [tags[name]]; | ||
return values.map(function(value) { | ||
return [name, value].join(':'); | ||
}); | ||
}) | ||
); | ||
return tags | ||
.map(function(tag) { return typeof tag === 'string' ? tag : undefined; }) | ||
.filter(function(tag) { return tag !== undefined; }); | ||
} | ||
@@ -199,0 +186,0 @@ |
@@ -104,3 +104,3 @@ | ||
return value && value.data; | ||
return value && value.data && JSON.parse(value.data); | ||
} | ||
@@ -121,3 +121,3 @@ | ||
expire: expire, | ||
data: value | ||
data: JSON.stringify(value) | ||
}; | ||
@@ -124,0 +124,0 @@ } |
{ | ||
"name": "cashbox", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "javascript cache library with configurable storage", | ||
@@ -38,2 +38,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"async": "~0.2.9", | ||
"mocha": "~1.9.0", | ||
@@ -40,0 +41,0 @@ "chai": "~1.6.0" |
@@ -123,3 +123,3 @@ var assert = require('chai').assert, | ||
load: function(key, cb) { | ||
cb(null, value, { test : 1 }); | ||
cb(null, value, 'test=1'); | ||
}, | ||
@@ -131,3 +131,3 @@ done: function(err, v) { | ||
setTimeout(function() { | ||
cache.getKeys({ test : 1 }, function(err, keys) { | ||
cache.getKeys('test=1', function(err, keys) { | ||
assert.equal(keys[0], key); | ||
@@ -308,3 +308,3 @@ done(); | ||
it('should accept an object with tagging capabilities (as an object)', function(done) { | ||
it('should accept an object with tagging capabilities (as an array)', function(done) { | ||
var cache = new Cache(); | ||
@@ -319,3 +319,3 @@ | ||
[value1, value2], | ||
[{ test : 1 }, { test : 2 }] | ||
['test=1', 'test=2'] | ||
); | ||
@@ -330,3 +330,3 @@ }, | ||
setTimeout(function() { | ||
cache.getKeys({ test : 2 }, function(err, keys) { | ||
cache.getKeys('test=2', function(err, keys) { | ||
assert.equal(keys[0], key2); | ||
@@ -333,0 +333,0 @@ done(); |
25876
9
873
3