dist/underscore-contrib.js
function(obj, fun, ks, defaultValue) {
      if (!isAssociative(obj)) throw new TypeError("Attempted to update a non-associative object.");
      if (!existy(ks)) return fun(obj);

      var deepness = _.isArray(ks);
      var keys     = deepness ? ks : [ks];
      var ret      = deepness ? _.snapshot(obj) : _.clone(obj);
      var lastKey  = _.last(keys);
      var target   = ret;

      _.each(_.initial(keys), function(key) {
        if (defaultValue && !_.has(target, key)) {
          target[key] = _.clone(defaultValue);
        }
        target = target[key];
      });

      target[lastKey] = fun(target[lastKey]);
      return ret;
    }
function(obj, fun, ks, defaultValue) {
      if (!isAssociative(obj)) throw new TypeError("Attempted to update a non-associative object.");
      if (!existy(ks)) return fun(obj);

      var deepness = _.isArray(ks);
      var keys     = deepness ? ks : [ks];
      var ret      = deepness ? _.snapshot(obj) : _.clone(obj);
      var lastKey  = _.last(keys);
      var target   = ret;

      _.each(_.initial(keys), function(key) {
        if (defaultValue && !_.has(target, key)) {
          target[key] = _.clone(defaultValue);
        }
        target = target[key];
      });

      target[lastKey] = fun(target[lastKey]);
      return ret;
    }
function ( obj , fun , ks , defaultValue ) { if ( ! isAssociative ( obj ) ) throw new TypeError ( "Attempted to update a non-associative object." ) ; if ( ! existy ( ks ) ) return fun ( obj ) ; var deepness = _ . isArray ( ks ) ; var keys = deepness ? ks : [ ks ] ; var ret = deepness ? _ . snapshot ( obj ) : _ . clone ( obj ) ; var lastKey = _ . last ( keys ) ; var target = ret ; _ . each ( _ . initial ( keys ) , function ( key ) { if ( defaultValue && ! _ . has ( target , key ) ) { target [ key ] = _ . clone ( defaultValue ) ; } target = target [ key ] ; } ) ; target [ lastKey ] = fun ( target [ lastKey ] ) ; return ret ; }
Updates the value at any depth in a nested object based on the path described by the keys given.  The function provided is supplied the current value and is expected to return a value for use as the new value.  If no keys are provided, then the object itself is presented to the given function.
Updates the value at any depth in a nested object based on the path described by the keys given . The function provided is supplied the current value and is expected to return a value for use as the new value . If no keys are provided then the object itself is presented to the given function .