Permalink
Browse files

New defaults function

  • Loading branch information...
koenbok committed Oct 15, 2013
1 parent b629549 commit 6c102c2bc16e7c433e3d4ea565d47d218a2173c9
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/utils.coffee
@@ -67,6 +67,17 @@ exports.round = (value, decimals) ->
######################################################
# HANDY FUNCTIONS
exports.defaults = (obj, defaults) ->
result = _.extend obj
for k, v of defaults
if result[k] in [null, undefined]
result[k] = defaults[k]
result
exports.randomColor = (alpha = 1.0) ->
c = -> parseInt(Math.random() * 255)
"rgba(#{c()}, #{c()}, #{c()}, #{alpha})"

0 comments on commit 6c102c2

Please sign in to comment.