lib/resource-linker.js
function groupIncludes(includes, body) {
    var root = rootName(body);
    var requestsByType = {};

    _.each(includes, function(include) {
      var type = ((body.links && body.links[root + "." + include]) || {}).type,
        split = include.split(".");

      if (_.isUndefined(body.links) || _.isUndefined(body.links[root + "." + split[0]])) {
        return;
      }

      if (type && body.linked[type] && body.linked[type] !== "external") {
        // The type exists but is not an external reference exit.
        return;
      }

      var ancestorType = body.links[root + "." + split[0]].type;
      var ids = linkedIds(body[root], split[0]);
      if (ids.length) {
        var requestData = requestsByType[ancestorType] || {ids: [], includes: []};
        requestData.ids = requestData.ids.concat(ids);
        requestData.includes.push(split);
        requestsByType[ancestorType] = requestData;
      }
    });

    return requestsByType;
  }
function groupIncludes(includes, body) {
    var root = rootName(body);
    var requestsByType = {};

    _.each(includes, function(include) {
      var type = ((body.links && body.links[root + "." + include]) || {}).type,
        split = include.split(".");

      if (_.isUndefined(body.links) || _.isUndefined(body.links[root + "." + split[0]])) {
        return;
      }

      if (type && body.linked[type] && body.linked[type] !== "external") {
        // The type exists but is not an external reference exit.
        return;
      }

      var ancestorType = body.links[root + "." + split[0]].type;
      var ids = linkedIds(body[root], split[0]);
      if (ids.length) {
        var requestData = requestsByType[ancestorType] || {ids: [], includes: []};
        requestData.ids = requestData.ids.concat(ids);
        requestData.includes.push(split);
        requestsByType[ancestorType] = requestData;
      }
    });

    return requestsByType;
  }
function groupIncludes ( includes , body ) { var root = rootName ( body ) ; var requestsByType = { } ; _ . each ( includes , function ( include ) { var type = ( ( body . links && body . links [ root + "." + include ] ) || { } ) . type , split = include . split ( "." ) ; if ( _ . isUndefined ( body . links ) || _ . isUndefined ( body . links [ root + "." + split [ 0 ] ] ) ) { return ; } if ( type && body . linked [ type ] && body . linked [ type ] !== "external" ) { // The type exists but is not an external reference exit. return ; } var ancestorType = body . links [ root + "." + split [ 0 ] ] . type ; var ids = linkedIds ( body [ root ] , split [ 0 ] ) ; if ( ids . length ) { var requestData = requestsByType [ ancestorType ] || { ids : [ ] , includes : [ ] } ; requestData . ids = requestData . ids . concat ( ids ) ; requestData . includes . push ( split ) ; requestsByType [ ancestorType ] = requestData ; } } ) ; return requestsByType ; }
Batches together the includes by type, as to avoid multiple requests.

@param {Object} The resource body.
@api private
Batches together the includes by type as to avoid multiple requests .