clarity
Advanced tools
Comparing version 0.1.1 to 0.1.2
34
index.js
@@ -20,7 +20,14 @@ var data = {}, | ||
clarity.decode = function(input) { | ||
var matchUser, matchVariable, output, parts; | ||
// if the input is an object, then walk through the object and clone | ||
if (typeof input == 'object' && (! (input instanceof String))) { | ||
return clarity.deepDecode(input); | ||
} | ||
// run some regex checks against the input string | ||
var matchUser = reObfuscatedUser.exec(input), | ||
matchVariable = reObfuscatedVariable.exec(input), | ||
output = input, | ||
parts = []; | ||
matchUser = reObfuscatedUser.exec(input); | ||
matchVariable = reObfuscatedVariable.exec(input); | ||
output = input; | ||
parts = []; | ||
@@ -49,2 +56,21 @@ // if we are dealing with a variable, then decode appropriately | ||
clarity.deepDecode = function(input) { | ||
var clone = {}; | ||
// if we have a string, then short circuit | ||
if (typeof input == 'string' || (input instanceof String)) { | ||
return clarity.decode(input); | ||
} | ||
// iterate through the keys within the object | ||
// and return the decoded value | ||
Object.keys(input).forEach(function(key) { | ||
if (input.hasOwnProperty(key)) { | ||
clone[key] = clarity.deepDecode(input[key]); | ||
} | ||
}); | ||
return clone; | ||
} | ||
clarity.use = function() { | ||
@@ -51,0 +77,0 @@ function extend() { |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"engines": { | ||
@@ -13,0 +13,0 @@ "node": ">= 0.6.x < 0.9.0" |
8990
9
178