From 6052ef36a532b516596bd8a62e01dde8c40ac9c0 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Mon, 18 May 2020 11:17:52 -0600 Subject: [PATCH 1/5] Replace cint.partialAt with _.partialRight. --- bin/ncu.js | 5 ++--- lib/npm-check-updates.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/ncu.js b/bin/ncu.js index 477693d2..62c8e453 100755 --- a/bin/ncu.js +++ b/bin/ncu.js @@ -4,7 +4,6 @@ const program = require('commander') const updateNotifier = require('update-notifier') -const cint = require('cint') const _ = require('lodash') const ncu = require('../lib/npm-check-updates') const pkg = require('../package.json') @@ -19,12 +18,12 @@ program .description('[filter] is a list or regex of package names to check (all others will be ignored).') .usage('[options] [filter]') .version(pkg.version) - .option('--concurrency ', 'max number of concurrent HTTP requests to npm registry.', cint.partialAt(parseInt, 1, 10), 8) + .option('--concurrency ', 'max number of concurrent HTTP requests to npm registry.', _.partialRight(parseInt, 10), 8) .option('--configFilePath ', 'rc config file path (default: directory of `packageFile` or ./ otherwise)') .option('--configFileName ', 'rc config file name (default: .ncurc.{json,yml,js})') .option('--cwd ', 'Used as current working directory for `spawn` in npm listing') .option('--dep ', 'check only a specific section(s) of dependencies: prod|dev|peer|optional|bundle (comma-delimited)') - .option('-e, --error-level ', 'set the error-level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 if no packages need updating (useful for continuous integration).', cint.partialAt(parseInt, 1, 10), 1) + .option('-e, --error-level ', 'set the error-level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 if no packages need updating (useful for continuous integration).', _.partialRight(parseInt, 10), 1) .option('--engines-node', 'upgrade to version which satisfies engines.node range') .option('-f, --filter ', 'include only package names matching the given string, comma-or-space-delimited list, or /regex/') .option('-g, --global', 'check global packages instead of in the current project') diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index f72d1840..e408c690 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -116,7 +116,7 @@ function toDependencyTable(args) { return table } -const readPackageFile = cint.partialAt(promisify(fs.readFile), 1, 'utf8') +const readPackageFile = _.partialRight(promisify(fs.readFile), 'utf8') const writePackageFile = promisify(fs.writeFile) // From 225f68be5fc63dc0ded30cf4169e3919cf77cb9d Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Mon, 18 May 2020 12:08:00 -0600 Subject: [PATCH 2/5] Remove cint.aritize. --- lib/versionmanager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/versionmanager.js b/lib/versionmanager.js index cc04c353..e045c743 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -237,8 +237,8 @@ function packageNameFilter(filter) { throw new TypeError('Invalid packages filter. Must be a RegExp, array, or comma-or-space-delimited list.') } - // (limit the arity to 1 to avoid passing the value) - return cint.aritize(filterPackages, 1) + // limit the arity to 1 to avoid passing the value + return dep => filterPackages(dep) } /** From a5a5ce1fd115a4796eca8b0b4edbc0a1cff5fb34 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Mon, 18 May 2020 12:17:22 -0600 Subject: [PATCH 3/5] Replace cint.keyValue with native object literal. --- lib/npm-check-updates.js | 6 +++--- lib/package-managers/npm.js | 6 +++--- lib/versionmanager.js | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index e408c690..454d45b1 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -224,9 +224,9 @@ function analyzeProjectDependencies(options, pkgData, pkgFile) { // split the deps into satisfied and unsatisfied to display in two separate tables const deps = Object.keys(selectedNewDependencies) - const satisfied = cint.toObject(deps, dep => - cint.keyValue(dep, vm.isSatisfied(latest[dep], current[dep])) - ) + const satisfied = cint.toObject(deps, dep => ({ + [dep]: vm.isSatisfied(latest[dep], current[dep]) + })) const isSatisfied = _.propertyOf(satisfied) const filteredUpgraded = options.minimal ? cint.filterObject(selectedNewDependencies, cint.not(isSatisfied)) : selectedNewDependencies diff --git a/lib/package-managers/npm.js b/lib/package-managers/npm.js index ee53788a..22cbef86 100644 --- a/lib/package-managers/npm.js +++ b/lib/package-managers/npm.js @@ -183,10 +183,10 @@ module.exports = { const json = parseJson(result, { command: 'npm ls' }) - return cint.mapObject(json.dependencies, (name, info) => + return cint.mapObject(json.dependencies, (name, info) => ({ // unmet peer dependencies have a different structure - cint.keyValue(name, info.version || (info.required && info.required.version)) - ) + [name]: info.version || (info.required && info.required.version) + })) }) }, diff --git a/lib/versionmanager.js b/lib/versionmanager.js index e045c743..1a28f82d 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -87,9 +87,9 @@ function upgradeDependencyDeclaration(declaration, latestVersion, options = {}) } // create a new semver object with major, minor, patch, build, and release parts - const newSemver = cint.toObject(versionUtil.VERSION_PARTS, part => - cint.keyValue(part, chooseVersion(part)) - ) + const newSemver = cint.toObject(versionUtil.VERSION_PARTS, part => ({ + [part]: chooseVersion(part) + })) const newSemverString = versionUtil.stringify(newSemver) const version = v(declaredSemver.semver) + newSemverString @@ -485,9 +485,9 @@ function queryVersions(packageMap, options = {}) { * @returns */ function zipVersions(versionList) { - return cint.toObject(versionList, (version, i) => { - return cint.keyValue(packageList[i], version) - }) + return cint.toObject(versionList, (version, i) => ({ + [packageList[i]]: version + })) } return pMap(packageList, getPackageVersionProtected, { concurrency: options.concurrency }) .then(zipVersions) From f44d4b137357068b76916c78f4a7d09497605fcc Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Mon, 18 May 2020 12:18:43 -0600 Subject: [PATCH 4/5] Replace cint.not with lambda function. --- lib/npm-check-updates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index 454d45b1..5c4600f4 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -229,7 +229,7 @@ function analyzeProjectDependencies(options, pkgData, pkgFile) { })) const isSatisfied = _.propertyOf(satisfied) - const filteredUpgraded = options.minimal ? cint.filterObject(selectedNewDependencies, cint.not(isSatisfied)) : selectedNewDependencies + const filteredUpgraded = options.minimal ? cint.filterObject(selectedNewDependencies, dep => !isSatisfied(dep)) : selectedNewDependencies const numUpgraded = Object.keys(filteredUpgraded).length // print From e0beef807db6d9e0a1cb91f08151aad855247bba Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Mon, 18 May 2020 12:34:22 -0600 Subject: [PATCH 5/5] Replace cint.index with native array index. --- lib/versionmanager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/versionmanager.js b/lib/versionmanager.js index 1a28f82d..61cb41f2 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -215,7 +215,7 @@ function packageNameFilter(filter) { } else if (typeof filter === 'string') { // RegExp filter - if (filter[0] === '/' && cint.index(filter, -1) === '/') { + if (filter[0] === '/' && filter[filter.length - 1] === '/') { const regexp = new RegExp(filter.slice(1, -1)) filterPackages = regexp.test.bind(regexp) }