tasks/jsonld/js/jsonld.js
function _removeEmbed(state, id) {
  // get existing embed
  var embeds = state.embeds;
  var embed = embeds[id];
  var parent = embed.parent;
  var property = embed.property;

  // create reference to replace embed
  var subject = {'@id': id};

  // remove existing embed
  if(_isArray(parent)) {
    // replace subject with reference
    for(var i = 0; i < parent.length; ++i) {
      if(jsonld.compareValues(parent[i], subject)) {
        parent[i] = subject;
        break;
      }
    }
  }
  else {
    // replace subject with reference
    var useArray = _isArray(parent[property]);
    jsonld.removeValue(parent, property, subject, {propertyIsArray: useArray});
    jsonld.addValue(parent, property, subject, {propertyIsArray: useArray});
  }

  // recursively remove dependent dangling embeds
  var removeDependents = function(id) {
    // get embed keys as a separate array to enable deleting keys in map
    var ids = Object.keys(embeds);
    for(var i = 0; i < ids.length; ++i) {
      var next = ids[i];
      if(next in embeds && _isObject(embeds[next].parent) &&
        embeds[next].parent['@id'] === id) {
        delete embeds[next];
        removeDependents(next);
      }
    }
  };
  removeDependents(id);
}
function _removeEmbed(state, id) {
  // get existing embed
  var embeds = state.embeds;
  var embed = embeds[id];
  var parent = embed.parent;
  var property = embed.property;

  // create reference to replace embed
  var subject = {'@id': id};

  // remove existing embed
  if(_isArray(parent)) {
    // replace subject with reference
    for(var i = 0; i < parent.length; ++i) {
      if(jsonld.compareValues(parent[i], subject)) {
        parent[i] = subject;
        break;
      }
    }
  }
  else {
    // replace subject with reference
    var useArray = _isArray(parent[property]);
    jsonld.removeValue(parent, property, subject, {propertyIsArray: useArray});
    jsonld.addValue(parent, property, subject, {propertyIsArray: useArray});
  }

  // recursively remove dependent dangling embeds
  var removeDependents = function(id) {
    // get embed keys as a separate array to enable deleting keys in map
    var ids = Object.keys(embeds);
    for(var i = 0; i < ids.length; ++i) {
      var next = ids[i];
      if(next in embeds && _isObject(embeds[next].parent) &&
        embeds[next].parent['@id'] === id) {
        delete embeds[next];
        removeDependents(next);
      }
    }
  };
  removeDependents(id);
}
function _removeEmbed ( state , id ) { // get existing embed var embeds = state . embeds ; var embed = embeds [ id ] ; var parent = embed . parent ; var property = embed . property ; // create reference to replace embed var subject = { '@id' : id } ; // remove existing embed if ( _isArray ( parent ) ) { // replace subject with reference for ( var i = 0 ; i < parent . length ; ++ i ) { if ( jsonld . compareValues ( parent [ i ] , subject ) ) { parent [ i ] = subject ; break ; } } } else { // replace subject with reference var useArray = _isArray ( parent [ property ] ) ; jsonld . removeValue ( parent , property , subject , { propertyIsArray : useArray } ) ; jsonld . addValue ( parent , property , subject , { propertyIsArray : useArray } ) ; } // recursively remove dependent dangling embeds var removeDependents = function ( id ) { // get embed keys as a separate array to enable deleting keys in map var ids = Object . keys ( embeds ) ; for ( var i = 0 ; i < ids . length ; ++ i ) { var next = ids [ i ] ; if ( next in embeds && _isObject ( embeds [ next ] . parent ) && embeds [ next ] . parent [ '@id' ] === id ) { delete embeds [ next ] ; removeDependents ( next ) ; } } } ; removeDependents ( id ) ; }
Removes an existing embed.

@param state the current framing state.
@param id the @id of the embed to remove.
Removes an existing embed .