tasks/jsonld/js/jsonld.js
function createArray() {
    var normalized = [];

    /* Note: At this point all bnodes in the set of RDF quads have been
     assigned canonical names, which have been stored in the 'namer' object.
     Here each quad is updated by assigning each of its bnodes its new name
     via the 'namer' object. */

    // update bnode names in each quad and serialize
    for(var i = 0; i < quads.length; ++i) {
      var quad = quads[i];
      var attrs = ['subject', 'object', 'name'];
      for(var ai = 0; ai < attrs.length; ++ai) {
        var attr = attrs[ai];
        if(quad[attr] && quad[attr].type === 'blank node' &&
          quad[attr].value.indexOf('_:c14n') !== 0) {
          quad[attr].value = namer.getName(quad[attr].value);
        }
      }
      normalized.push(_toNQuad(quad, quad.name ? quad.name.value : null));
    }

    // sort normalized output
    normalized.sort();

    // handle output format
    if(options.format) {
      if(options.format === 'application/nquads') {
        return callback(null, normalized.join(''));
      }
      return callback(new JsonLdError(
        'Unknown output format.',
        'jsonld.UnknownFormat', {format: options.format}));
    }

    // output RDF dataset
    callback(null, _parseNQuads(normalized.join('')));
  }
function createArray() {
    var normalized = [];

    /* Note: At this point all bnodes in the set of RDF quads have been
     assigned canonical names, which have been stored in the 'namer' object.
     Here each quad is updated by assigning each of its bnodes its new name
     via the 'namer' object. */

    // update bnode names in each quad and serialize
    for(var i = 0; i < quads.length; ++i) {
      var quad = quads[i];
      var attrs = ['subject', 'object', 'name'];
      for(var ai = 0; ai < attrs.length; ++ai) {
        var attr = attrs[ai];
        if(quad[attr] && quad[attr].type === 'blank node' &&
          quad[attr].value.indexOf('_:c14n') !== 0) {
          quad[attr].value = namer.getName(quad[attr].value);
        }
      }
      normalized.push(_toNQuad(quad, quad.name ? quad.name.value : null));
    }

    // sort normalized output
    normalized.sort();

    // handle output format
    if(options.format) {
      if(options.format === 'application/nquads') {
        return callback(null, normalized.join(''));
      }
      return callback(new JsonLdError(
        'Unknown output format.',
        'jsonld.UnknownFormat', {format: options.format}));
    }

    // output RDF dataset
    callback(null, _parseNQuads(normalized.join('')));
  }
function createArray ( ) { var normalized = [ ] ; /* Note: At this point all bnodes in the set of RDF quads have been
     assigned canonical names, which have been stored in the 'namer' object.
     Here each quad is updated by assigning each of its bnodes its new name
     via the 'namer' object. */ // update bnode names in each quad and serialize for ( var i = 0 ; i < quads . length ; ++ i ) { var quad = quads [ i ] ; var attrs = [ 'subject' , 'object' , 'name' ] ; for ( var ai = 0 ; ai < attrs . length ; ++ ai ) { var attr = attrs [ ai ] ; if ( quad [ attr ] && quad [ attr ] . type === 'blank node' && quad [ attr ] . value . indexOf ( '_:c14n' ) !== 0 ) { quad [ attr ] . value = namer . getName ( quad [ attr ] . value ) ; } } normalized . push ( _toNQuad ( quad , quad . name ? quad . name . value : null ) ) ; } // sort normalized output normalized . sort ( ) ; // handle output format if ( options . format ) { if ( options . format === 'application/nquads' ) { return callback ( null , normalized . join ( '' ) ) ; } return callback ( new JsonLdError ( 'Unknown output format.' , 'jsonld.UnknownFormat' , { format : options . format } ) ) ; } // output RDF dataset callback ( null , _parseNQuads ( normalized . join ( '' ) ) ) ; }
creates the sorted array of RDF quads
creates the sorted array of RDF quads