Comparing version 0.2.8 to 0.2.9
@@ -411,3 +411,3 @@ // Generated by CoffeeScript 1.6.3 | ||
props: function(o, p) { | ||
var f, r, _ref; | ||
var f, r; | ||
if (o == null) { | ||
@@ -419,3 +419,6 @@ return; | ||
} | ||
_ref = p.split('.'), f = _ref[0], r = 2 <= _ref.length ? __slice.call(_ref, 1) : []; | ||
if (h.type(p) !== 'array') { | ||
p = p.split('.'); | ||
} | ||
f = p[0], r = 2 <= p.length ? __slice.call(p, 1) : []; | ||
if (!r.length) { | ||
@@ -563,2 +566,10 @@ return o[f]; | ||
}, | ||
subset: function(small, big) { | ||
var isSubset; | ||
isSubset = true; | ||
h.walk(small, function(v, k, c) { | ||
return isSubset = v === h.props(big, c); | ||
}); | ||
return isSubset; | ||
}, | ||
truth: function(v) { | ||
@@ -565,0 +576,0 @@ if (h.type(v, 'undefined') || h.type(v, 'null')) { |
@@ -42,3 +42,3 @@ { | ||
}, | ||
"version" : "0.2.8" | ||
"version" : "0.2.9" | ||
} |
@@ -743,3 +743,3 @@ // Generated by CoffeeScript 1.6.3 | ||
}); | ||
return it('should return undefined if object is not passed', function() { | ||
it('should return undefined if object is not passed', function() { | ||
var v; | ||
@@ -749,2 +749,17 @@ v = h.props(); | ||
}); | ||
return it('should take arrays as valid properties', function() { | ||
var obj, v, v1; | ||
obj = { | ||
a: { | ||
b: { | ||
c: { | ||
d: 1 | ||
} | ||
} | ||
} | ||
}; | ||
v = h.props(obj, 'a.b.c.d'); | ||
v1 = h.props(obj, ['a', 'b', 'c', 'd']); | ||
return assert.equal(v, v1); | ||
}); | ||
}); | ||
@@ -1116,2 +1131,42 @@ | ||
describe('#subset()', function() { | ||
it('returns true if small object is subset of big', function() { | ||
var big, small; | ||
small = { | ||
a: 1, | ||
b: 2 | ||
}; | ||
big = { | ||
a: 1, | ||
b: 2, | ||
c: 3 | ||
}; | ||
return assert.ok(dahelpers.subset(small, big)); | ||
}); | ||
it('returns false if small object has keys not in big one', function() { | ||
var big, small; | ||
small = { | ||
a: 1, | ||
b: 2, | ||
x: 'wrong!' | ||
}; | ||
big = { | ||
a: 1, | ||
b: 2, | ||
c: 3 | ||
}; | ||
return assert.notOk(dahelpers.subset(small, big)); | ||
}); | ||
return it('returns true if small object is empty', function() { | ||
var big, small; | ||
small = {}; | ||
big = { | ||
a: 1, | ||
b: 2, | ||
c: 3 | ||
}; | ||
return assert.ok(dahelpers.subset(small, big)); | ||
}); | ||
}); | ||
describe('#truth()', function() { | ||
@@ -1118,0 +1173,0 @@ it('should return true for values that we consider true', function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
377324
10310
919