src/index.js
function _getPropFromPosterity(objToStartWith, prop, unique) {
  let values = []
  function loadValues(obj) {
    if (obj[prop]) {
      const propsToAdd = _arrayify(obj[prop])
      _each(propsToAdd, propToAdd => {
        if (!unique || !_contains(values, propToAdd)) {
          values.push(propToAdd)
        }
      })
    }
    _each(obj, (oProp, oPropName) => {
      if (oPropName !== prop && !_isPrimitive(oProp)) {
        values = values.concat(loadValues(oProp))
      }
    })
  }
  loadValues(objToStartWith)
  return values
}
function _getPropFromPosterity(objToStartWith, prop, unique) {
  let values = []
  function loadValues(obj) {
    if (obj[prop]) {
      const propsToAdd = _arrayify(obj[prop])
      _each(propsToAdd, propToAdd => {
        if (!unique || !_contains(values, propToAdd)) {
          values.push(propToAdd)
        }
      })
    }
    _each(obj, (oProp, oPropName) => {
      if (oPropName !== prop && !_isPrimitive(oProp)) {
        values = values.concat(loadValues(oProp))
      }
    })
  }
  loadValues(objToStartWith)
  return values
}
function _getPropFromPosterity ( objToStartWith , prop , unique ) { let values = [ ] function loadValues ( obj ) { if ( obj [ prop ] ) { const propsToAdd = _arrayify ( obj [ prop ] ) _each ( propsToAdd , propToAdd => { if ( ! unique || ! _contains ( values , propToAdd ) ) { values . push ( propToAdd ) } } ) } _each ( obj , ( oProp , oPropName ) => { if ( oPropName !== prop && ! _isPrimitive ( oProp ) ) { values = values . concat ( loadValues ( oProp ) ) } } ) } loadValues ( objToStartWith ) return values }
Iterates through all child properties of the given object
and if it has the given property, it will add that property
to the array that's returned at the end.
@param {*} objToStartWith
@param {string} prop
@param {boolean} [unique=false]
@returns {Array.<object>}
@private
@examples
_getPropFromPosterity({a: {p: 1, b: {p: 2}}}, 'p') // => [1,2]
Iterates through all child properties of the given object and if it has the given property it will add that property to the array that s returned at the end .