tasks/jsonld/js/jsonld.js
function nameDuplicates(duplicates) {
    // enumerate duplicate hash groups in sorted order
    var hashes = Object.keys(duplicates).sort();

    // process each group
    processGroup(0);
    function processGroup(i) {
      if(i === hashes.length) {
        // done, create JSON-LD array
        return createArray();
      }

      // name each group member
      var group = duplicates[hashes[i]];
      var results = [];
      nameGroupMember(group, 0);
      function nameGroupMember(group, n) {
        if(n === group.length) {
          // name bnodes in hash order
          results.sort(function(a, b) {
            a = a.hash;
            b = b.hash;
            return (a < b) ? -1 : ((a > b) ? 1 : 0);
          });
          for(var r in results) {
            // name all bnodes in path namer in key-entry order
            // Note: key-order is preserved in javascript
            for(var key in results[r].pathNamer.existing) {
              namer.getName(key);
            }
          }
          return processGroup(i + 1);
        }

        // skip already-named bnodes
        var bnode = group[n];
        if(namer.isNamed(bnode)) {
          return nameGroupMember(group, n + 1);
        }

        // hash bnode paths
        var pathNamer = new UniqueNamer('_:b');
        pathNamer.getName(bnode);
        _hashPaths(bnode, bnodes, namer, pathNamer,
          function(err, result) {
            if(err) {
              return callback(err);
            }
            results.push(result);
            nameGroupMember(group, n + 1);
          });
      }
    }
  }
function nameDuplicates(duplicates) {
    // enumerate duplicate hash groups in sorted order
    var hashes = Object.keys(duplicates).sort();

    // process each group
    processGroup(0);
    function processGroup(i) {
      if(i === hashes.length) {
        // done, create JSON-LD array
        return createArray();
      }

      // name each group member
      var group = duplicates[hashes[i]];
      var results = [];
      nameGroupMember(group, 0);
      function nameGroupMember(group, n) {
        if(n === group.length) {
          // name bnodes in hash order
          results.sort(function(a, b) {
            a = a.hash;
            b = b.hash;
            return (a < b) ? -1 : ((a > b) ? 1 : 0);
          });
          for(var r in results) {
            // name all bnodes in path namer in key-entry order
            // Note: key-order is preserved in javascript
            for(var key in results[r].pathNamer.existing) {
              namer.getName(key);
            }
          }
          return processGroup(i + 1);
        }

        // skip already-named bnodes
        var bnode = group[n];
        if(namer.isNamed(bnode)) {
          return nameGroupMember(group, n + 1);
        }

        // hash bnode paths
        var pathNamer = new UniqueNamer('_:b');
        pathNamer.getName(bnode);
        _hashPaths(bnode, bnodes, namer, pathNamer,
          function(err, result) {
            if(err) {
              return callback(err);
            }
            results.push(result);
            nameGroupMember(group, n + 1);
          });
      }
    }
  }
function nameDuplicates ( duplicates ) { // enumerate duplicate hash groups in sorted order var hashes = Object . keys ( duplicates ) . sort ( ) ; // process each group processGroup ( 0 ) ; function processGroup ( i ) { if ( i === hashes . length ) { // done, create JSON-LD array return createArray ( ) ; } // name each group member var group = duplicates [ hashes [ i ] ] ; var results = [ ] ; nameGroupMember ( group , 0 ) ; function nameGroupMember ( group , n ) { if ( n === group . length ) { // name bnodes in hash order results . sort ( function ( a , b ) { a = a . hash ; b = b . hash ; return ( a < b ) ? - 1 : ( ( a > b ) ? 1 : 0 ) ; } ) ; for ( var r in results ) { // name all bnodes in path namer in key-entry order // Note: key-order is preserved in javascript for ( var key in results [ r ] . pathNamer . existing ) { namer . getName ( key ) ; } } return processGroup ( i + 1 ) ; } // skip already-named bnodes var bnode = group [ n ] ; if ( namer . isNamed ( bnode ) ) { return nameGroupMember ( group , n + 1 ) ; } // hash bnode paths var pathNamer = new UniqueNamer ( '_:b' ) ; pathNamer . getName ( bnode ) ; _hashPaths ( bnode , bnodes , namer , pathNamer , function ( err , result ) { if ( err ) { return callback ( err ) ; } results . push ( result ) ; nameGroupMember ( group , n + 1 ) ; } ) ; } } }
names duplicate hash bnodes
names duplicate hash bnodes