lib/methods/flatten.js
function (filter) {
    var obj = {}
    var val = this.__input

    this.each(function (property, key) {
      obj[key] = property.flatten ? property.flatten(filter) : property
    }, wrapFilter(filter))

    if (val !== void 0) {
      if (val instanceof Base) {
        val = {
          reference: val.path
        }
      }
      obj.val = val
    }

    // refactoring non standard keys
    var flattened = flatten(obj)
    for (var key in flattened) {
      if (key.indexOf('.val') > 0) {
        var newKey = key.split('.val')[0]
        flattened[newKey] = flattened[key]
        delete flattened[key]
      }
    }
    return flattened
  }
function (filter) {
    var obj = {}
    var val = this.__input

    this.each(function (property, key) {
      obj[key] = property.flatten ? property.flatten(filter) : property
    }, wrapFilter(filter))

    if (val !== void 0) {
      if (val instanceof Base) {
        val = {
          reference: val.path
        }
      }
      obj.val = val
    }

    // refactoring non standard keys
    var flattened = flatten(obj)
    for (var key in flattened) {
      if (key.indexOf('.val') > 0) {
        var newKey = key.split('.val')[0]
        flattened[newKey] = flattened[key]
        delete flattened[key]
      }
    }
    return flattened
  }
function ( filter ) { var obj = { } var val = this . __input this . each ( function ( property , key ) { obj [ key ] = property . flatten ? property . flatten ( filter ) : property } , wrapFilter ( filter ) ) if ( val !== void 0 ) { if ( val instanceof Base ) { val = { reference : val . path } } obj . val = val } // refactoring non standard keys var flattened = flatten ( obj ) for ( var key in flattened ) { if ( key . indexOf ( '.val' ) > 0 ) { var newKey = key . split ( '.val' ) [ 0 ] flattened [ newKey ] = flattened [ key ] delete flattened [ key ] } } return flattened }
Flatten a `Base` object
@memberOf Base#
@return {object}
Flatten a Base object