From 28940d6690e0895d833bfb0f4cd7fc2ca3825493 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Sun, 5 Nov 2023 03:24:16 +0000 Subject: [PATCH] Upgrade fp-and-or. --- package-lock.json | 10 +++++----- package.json | 2 +- src/lib/filterAndReject.ts | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f7c0cfd..a067289f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "commander": "^11.1.0", "fast-memoize": "^2.5.2", "find-up": "5.0.0", - "fp-and-or": "^0.1.4", + "fp-and-or": "^1.0.2", "get-stdin": "^8.0.0", "globby": "^11.0.4", "hosted-git-info": "^5.1.0", @@ -4138,11 +4138,11 @@ } }, "node_modules/fp-and-or": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/fp-and-or/-/fp-and-or-0.1.4.tgz", - "integrity": "sha512-+yRYRhpnFPWXSly/6V4Lw9IfOV26uu30kynGJ03PW+MnjOEQe45RZ141QcS0aJehYBYA50GfCDnsRbFJdhssRw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/fp-and-or/-/fp-and-or-1.0.2.tgz", + "integrity": "sha512-jRuhDpN/8LaE2ghHYKuj11SqUcfus38Rhsd+m9EReVes4KQdLErmHoP5FAWUBg+kci56ucryVryKda7cCyHT6A==", "engines": { - "node": ">=10" + "node": "^16.10.0 || >=18.0.0" } }, "node_modules/fs-minipass": { diff --git a/package.json b/package.json index 0a6c1e6c..a1eb52c1 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "commander": "^11.1.0", "fast-memoize": "^2.5.2", "find-up": "5.0.0", - "fp-and-or": "^0.1.4", + "fp-and-or": "^1.0.2", "get-stdin": "^8.0.0", "globby": "^11.0.4", "hosted-git-info": "^5.1.0", diff --git a/src/lib/filterAndReject.ts b/src/lib/filterAndReject.ts index 52280d2f..8caf7810 100644 --- a/src/lib/filterAndReject.ts +++ b/src/lib/filterAndReject.ts @@ -2,7 +2,7 @@ import { and, or } from 'fp-and-or' import identity from 'lodash/identity' import negate from 'lodash/negate' import { minimatch } from 'minimatch' -import { SemVer, parseRange } from 'semver-utils' +import { parseRange } from 'semver-utils' import { FilterPattern } from '../types/FilterPattern' import { Maybe } from '../types/Maybe' import { VersionSpec } from '../types/VersionSpec' @@ -14,8 +14,8 @@ import { VersionSpec } from '../types/VersionSpec' * @param [filterPattern] * @returns */ -function composeFilter(filterPattern: FilterPattern): (name: string, versionSpec: VersionSpec) => boolean { - let predicate: (name: string, versionSpec: VersionSpec) => boolean +function composeFilter(filterPattern: FilterPattern): (name: string, versionSpec?: string) => boolean { + let predicate: (name: string, versionSpec?: string) => boolean // no filter if (!filterPattern) { @@ -48,7 +48,7 @@ function composeFilter(filterPattern: FilterPattern): (name: string, versionSpec } // array else if (Array.isArray(filterPattern)) { - predicate = (dependencyName: string, versionSpec: string) => + predicate = (dependencyName: string, versionSpec?: string) => filterPattern.some(subpattern => composeFilter(subpattern)(dependencyName, versionSpec)) } // raw RegExp @@ -57,8 +57,8 @@ function composeFilter(filterPattern: FilterPattern): (name: string, versionSpec } // function else if (typeof filterPattern === 'function') { - predicate = (dependencyName: string, versionSpec: string) => - filterPattern(dependencyName, parseRange(versionSpec ?? dependencyName)) + predicate = (dependencyName: string, versionSpec?: string) => + filterPattern(dependencyName, parseRange((versionSpec as string) ?? dependencyName)) } else { throw new TypeError('Invalid filter. Must be a RegExp, array, or comma-or-space-delimited list.') } @@ -82,13 +82,13 @@ function filterAndReject( ) { return and( // filter dep - (dependencyName: VersionSpec, version: SemVer[]) => - and(filter ? composeFilter(filter) : identity, reject ? negate(composeFilter(reject)) : identity)( + (dependencyName: VersionSpec, version: string) => + and(filter ? composeFilter(filter) : true, reject ? negate(composeFilter(reject)) : true)( dependencyName, version, ), // filter version - (dependencyName: VersionSpec, version: SemVer[]) => + (dependencyName: VersionSpec, version: string) => and( filterVersion ? composeFilter(filterVersion) : identity, rejectVersion ? negate(composeFilter(rejectVersion)) : identity,