lib/syncmanager.js
function(parent, depToVersions) {
    var newdeps = {};
    var packages = Object.keys(depToVersions);
    packages.forEach(function(package) {
      var currVersions = this.packageToVersions[package];
      var depVersions = depToVersions[package];
      newdeps[package] = {};

      // Check if we are watching this package.
      if (!currVersions) {
        // Add all of the versions.
        debug(parent + ' needs ' + package + '@' +
              Object.keys(depVersions).join(', '));
        this.packageToVersions[package] = depVersions;
        newdeps[package] = depVersions;
        return;
      }

      // Check which versions we are watching.
      var versions = Object.keys(depVersions);
      versions
        .filter(function(version) {
          return !(version in currVersions);
        })
        .forEach(function(version) {
          // Add this version.
          debug(parent + ' needs ' + package + '@' + version);
          this.packageToVersions[package][version] = true;
          newdeps[package][version] = true;
        }.bind(this));
    }.bind(this));

    return newdeps;
  }
function(parent, depToVersions) {
    var newdeps = {};
    var packages = Object.keys(depToVersions);
    packages.forEach(function(package) {
      var currVersions = this.packageToVersions[package];
      var depVersions = depToVersions[package];
      newdeps[package] = {};

      // Check if we are watching this package.
      if (!currVersions) {
        // Add all of the versions.
        debug(parent + ' needs ' + package + '@' +
              Object.keys(depVersions).join(', '));
        this.packageToVersions[package] = depVersions;
        newdeps[package] = depVersions;
        return;
      }

      // Check which versions we are watching.
      var versions = Object.keys(depVersions);
      versions
        .filter(function(version) {
          return !(version in currVersions);
        })
        .forEach(function(version) {
          // Add this version.
          debug(parent + ' needs ' + package + '@' + version);
          this.packageToVersions[package][version] = true;
          newdeps[package][version] = true;
        }.bind(this));
    }.bind(this));

    return newdeps;
  }
function ( parent , depToVersions ) { var newdeps = { } ; var packages = Object . keys ( depToVersions ) ; packages . forEach ( function ( package ) { var currVersions = this . packageToVersions [ package ] ; var depVersions = depToVersions [ package ] ; newdeps [ package ] = { } ; // Check if we are watching this package. if ( ! currVersions ) { // Add all of the versions. debug ( parent + ' needs ' + package + '@' + Object . keys ( depVersions ) . join ( ', ' ) ) ; this . packageToVersions [ package ] = depVersions ; newdeps [ package ] = depVersions ; return ; } // Check which versions we are watching. var versions = Object . keys ( depVersions ) ; versions . filter ( function ( version ) { return ! ( version in currVersions ) ; } ) . forEach ( function ( version ) { // Add this version. debug ( parent + ' needs ' + package + '@' + version ) ; this . packageToVersions [ package ] [ version ] = true ; newdeps [ package ] [ version ] = true ; } . bind ( this ) ) ; } . bind ( this ) ) ; return newdeps ; }
Add dependencies to our in-memory map from packages to versions.

@param {string} parent package that needs these dependencies.
@param {Object} depToVersions map from package name to object with key list
of versions we need for the dep package.
@return {Object} new deps.
Add dependencies to our in - memory map from packages to versions .