examples/jobs-agent.js
function updateInstalledPackage(updatedPackage) {
   var packageIndex = installedPackages.findIndex(function(element) { 
      return (element.packageName === updatedPackage.packageName); 
   });

   if (packageIndex < 0) {
      packageIndex = installedPackages.length;
      installedPackages.push(updatedPackage);
   } else {
      installedPackages[packageIndex] = updatedPackage;
   }

   fs.writeFileSync(installedPackagesDataFileName, JSON.stringify(installedPackages));
}
function updateInstalledPackage(updatedPackage) {
   var packageIndex = installedPackages.findIndex(function(element) { 
      return (element.packageName === updatedPackage.packageName); 
   });

   if (packageIndex < 0) {
      packageIndex = installedPackages.length;
      installedPackages.push(updatedPackage);
   } else {
      installedPackages[packageIndex] = updatedPackage;
   }

   fs.writeFileSync(installedPackagesDataFileName, JSON.stringify(installedPackages));
}
function updateInstalledPackage ( updatedPackage ) { var packageIndex = installedPackages . findIndex ( function ( element ) { return ( element . packageName === updatedPackage . packageName ) ; } ) ; if ( packageIndex < 0 ) { packageIndex = installedPackages . length ; installedPackages . push ( updatedPackage ) ; } else { installedPackages [ packageIndex ] = updatedPackage ; } fs . writeFileSync ( installedPackagesDataFileName , JSON . stringify ( installedPackages ) ) ; }
Private function to update installed package
Private function to update installed package