Skip to content

Commit

Permalink
Upgrade fp-and-or.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Nov 5, 2023
1 parent c39c48b commit 28940d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions src/lib/filterAndReject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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.')
}
Expand All @@ -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,

Check failure on line 93 in src/lib/filterAndReject.ts

View workflow job for this annotation

GitHub Actions / Node 16 on ubuntu-latest

Argument of type '{ <T>(value: T): T; (): undefined; } | ((name: string, versionSpec?: string | undefined) => boolean)' is not assignable to parameter of type 'boolean | Predicate<[]>'.

Check failure on line 93 in src/lib/filterAndReject.ts

View workflow job for this annotation

GitHub Actions / Node 16 on windows-latest

Argument of type '{ <T>(value: T): T; (): undefined; } | ((name: string, versionSpec?: string | undefined) => boolean)' is not assignable to parameter of type 'boolean | Predicate<[]>'.

Check failure on line 93 in src/lib/filterAndReject.ts

View workflow job for this annotation

GitHub Actions / Node 18 on ubuntu-latest

Argument of type '{ <T>(value: T): T; (): undefined; } | ((name: string, versionSpec?: string | undefined) => boolean)' is not assignable to parameter of type 'boolean | Predicate<[]>'.

Check failure on line 93 in src/lib/filterAndReject.ts

View workflow job for this annotation

GitHub Actions / Node 18 on windows-latest

Argument of type '{ <T>(value: T): T; (): undefined; } | ((name: string, versionSpec?: string | undefined) => boolean)' is not assignable to parameter of type 'boolean | Predicate<[]>'.

Check failure on line 93 in src/lib/filterAndReject.ts

View workflow job for this annotation

GitHub Actions / Node 20 on ubuntu-latest

Argument of type '{ <T>(value: T): T; (): undefined; } | ((name: string, versionSpec?: string | undefined) => boolean)' is not assignable to parameter of type 'boolean | Predicate<[]>'.

Check failure on line 93 in src/lib/filterAndReject.ts

View workflow job for this annotation

GitHub Actions / Node 20 on windows-latest

Argument of type '{ <T>(value: T): T; (): undefined; } | ((name: string, versionSpec?: string | undefined) => boolean)' is not assignable to parameter of type 'boolean | Predicate<[]>'.
rejectVersion ? negate(composeFilter(rejectVersion)) : identity,
Expand Down

0 comments on commit 28940d6

Please sign in to comment.