tasks/rdfstore/index.js
function(
   subjects, input, frame, embeds, autoembed, parent, parentKey, options)
{
   var rval = null;
   
   // prepare output, set limit, get array of frames
   var limit = -1;
   var frames;
   if(frame.constructor === Array)
   {
      rval = [];
      frames = frame;
      if(frames.length === 0)
      {
         frames.push({});
      }
   }
   else
   {
      frames = [frame];
      limit = 1;
   }
   
   // iterate over frames adding input matches to list
   var values = [];
   for(var i = 0; i < frames.length && limit !== 0; ++i)
   {
      // get next frame
      frame = frames[i];
      if(frame.constructor !== Object)
      {
         throw {
            message: 'Invalid JSON-LD frame. ' +
               'Frame must be an object or an array.',
            frame: frame
         };
      }
      
      // create array of values for each frame
      values[i] = [];
      for(var n = 0; n < input.length && limit !== 0; ++n)
      {
         // add input to list if it matches frame specific type or duck-type
         var next = input[n];
         if(_isType(next, frame) || _isDuckType(next, frame))
         {
            values[i].push(next);
            --limit;
         }
      }
   }
   
   // for each matching value, add it to the output
   for(var i1 in values)
   {
      for(var i2 in values[i1])
      {
         frame = frames[i1];
         var value = values[i1][i2];
         
         // if value is a subject, do subframing
         if(_isSubject(value))
         {
            value = _subframe(
               subjects, value, frame, embeds, autoembed,
               parent, parentKey, options);
         }
         
         // add value to output
         if(rval === null)
         {
            rval = value;
         }
         else
         {
            // determine if value is a reference to an embed
            var isRef = (_isReference(value) && value['@id'] in embeds);
            
            // push any value that isn't a parentless reference
            if(!(parent === null && isRef))
            {
               rval.push(value);
            }
         }
      }
   }
   
   return rval;
}
function(
   subjects, input, frame, embeds, autoembed, parent, parentKey, options)
{
   var rval = null;
   
   // prepare output, set limit, get array of frames
   var limit = -1;
   var frames;
   if(frame.constructor === Array)
   {
      rval = [];
      frames = frame;
      if(frames.length === 0)
      {
         frames.push({});
      }
   }
   else
   {
      frames = [frame];
      limit = 1;
   }
   
   // iterate over frames adding input matches to list
   var values = [];
   for(var i = 0; i < frames.length && limit !== 0; ++i)
   {
      // get next frame
      frame = frames[i];
      if(frame.constructor !== Object)
      {
         throw {
            message: 'Invalid JSON-LD frame. ' +
               'Frame must be an object or an array.',
            frame: frame
         };
      }
      
      // create array of values for each frame
      values[i] = [];
      for(var n = 0; n < input.length && limit !== 0; ++n)
      {
         // add input to list if it matches frame specific type or duck-type
         var next = input[n];
         if(_isType(next, frame) || _isDuckType(next, frame))
         {
            values[i].push(next);
            --limit;
         }
      }
   }
   
   // for each matching value, add it to the output
   for(var i1 in values)
   {
      for(var i2 in values[i1])
      {
         frame = frames[i1];
         var value = values[i1][i2];
         
         // if value is a subject, do subframing
         if(_isSubject(value))
         {
            value = _subframe(
               subjects, value, frame, embeds, autoembed,
               parent, parentKey, options);
         }
         
         // add value to output
         if(rval === null)
         {
            rval = value;
         }
         else
         {
            // determine if value is a reference to an embed
            var isRef = (_isReference(value) && value['@id'] in embeds);
            
            // push any value that isn't a parentless reference
            if(!(parent === null && isRef))
            {
               rval.push(value);
            }
         }
      }
   }
   
   return rval;
}
function ( subjects , input , frame , embeds , autoembed , parent , parentKey , options ) { var rval = null ; // prepare output, set limit, get array of frames var limit = - 1 ; var frames ; if ( frame . constructor === Array ) { rval = [ ] ; frames = frame ; if ( frames . length === 0 ) { frames . push ( { } ) ; } } else { frames = [ frame ] ; limit = 1 ; } // iterate over frames adding input matches to list var values = [ ] ; for ( var i = 0 ; i < frames . length && limit !== 0 ; ++ i ) { // get next frame frame = frames [ i ] ; if ( frame . constructor !== Object ) { throw { message : 'Invalid JSON-LD frame. ' + 'Frame must be an object or an array.' , frame : frame } ; } // create array of values for each frame values [ i ] = [ ] ; for ( var n = 0 ; n < input . length && limit !== 0 ; ++ n ) { // add input to list if it matches frame specific type or duck-type var next = input [ n ] ; if ( _isType ( next , frame ) || _isDuckType ( next , frame ) ) { values [ i ] . push ( next ) ; -- limit ; } } } // for each matching value, add it to the output for ( var i1 in values ) { for ( var i2 in values [ i1 ] ) { frame = frames [ i1 ] ; var value = values [ i1 ] [ i2 ] ; // if value is a subject, do subframing if ( _isSubject ( value ) ) { value = _subframe ( subjects , value , frame , embeds , autoembed , parent , parentKey , options ) ; } // add value to output if ( rval === null ) { rval = value ; } else { // determine if value is a reference to an embed var isRef = ( _isReference ( value ) && value [ '@id' ] in embeds ) ; // push any value that isn't a parentless reference if ( ! ( parent === null && isRef ) ) { rval . push ( value ) ; } } } } return rval ; }
Recursively frames the given input according to the given frame.

@param subjects a map of subjects in the graph.
@param input the input to frame.
@param frame the frame to use.
@param embeds a map of previously embedded subjects, used to prevent cycles.
@param autoembed true if auto-embed is on, false if not.
@param parent the parent object (for subframing), null for none.
@param parentKey the parent key (for subframing), null for none.
@param options the framing options.

@return the framed input.
Recursively frames the given input according to the given frame .