lib/resource-linker.js
function mergeLinked(source, target, pathArr, ancestorType) {
    var linked, type, res;

    if (pathArr.length) {
      // the external is referenced by the ancestor
      if (source.links && source.linked && source.links[ancestorType + "." + pathArr.join(".")]) {
        type = source.links[ancestorType + "." + pathArr.join(".")].type;
        linked = source.linked[type];
      }
    } else {
      // ancestor is the sought external
      type = ancestorType;
      linked = source[ancestorType] || [];
    }

    target.linked[type] = _.isArray(res = target.linked[type]) ? _.uniq(res.concat(linked), function(i){ return i.id}) : linked;
  }
function mergeLinked(source, target, pathArr, ancestorType) {
    var linked, type, res;

    if (pathArr.length) {
      // the external is referenced by the ancestor
      if (source.links && source.linked && source.links[ancestorType + "." + pathArr.join(".")]) {
        type = source.links[ancestorType + "." + pathArr.join(".")].type;
        linked = source.linked[type];
      }
    } else {
      // ancestor is the sought external
      type = ancestorType;
      linked = source[ancestorType] || [];
    }

    target.linked[type] = _.isArray(res = target.linked[type]) ? _.uniq(res.concat(linked), function(i){ return i.id}) : linked;
  }
function mergeLinked ( source , target , pathArr , ancestorType ) { var linked , type , res ; if ( pathArr . length ) { // the external is referenced by the ancestor if ( source . links && source . linked && source . links [ ancestorType + "." + pathArr . join ( "." ) ] ) { type = source . links [ ancestorType + "." + pathArr . join ( "." ) ] . type ; linked = source . linked [ type ] ; } } else { // ancestor is the sought external type = ancestorType ; linked = source [ ancestorType ] || [ ] ; } target . linked [ type ] = _ . isArray ( res = target . linked [ type ] ) ? _ . uniq ( res . concat ( linked ) , function ( i ) { return i . id } ) : linked ; }
Replaces the target linked property with the external data.

@param {Object} The source from the external lookup.
@param {Object} The target resource.
@param {Object} The include properties.
@param {Object} The lookup resource type.
@api private
Replaces the target linked property with the external data .