Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove function types #115

Merged
merged 19 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import type {
OperatorFunctionType,
parsed,
SemanticFunctionType,
VersionFunctionType,
} from "./lib/shared";
import { parsed } from "./lib/shared";
import type { SemVer } from "semver";

export function valid(fn: VersionFunctionType): string | null;
export function clean(fn: VersionFunctionType): string | null;
export function explain(fn: VersionFunctionType): parsed | null;
export function valid(version: string): string | null;
export function clean(version: string): string | null;
export function explain(version: string): parsed | null;

//operator
export function compare(fn: OperatorFunctionType): number;
export function rcompare(fn: OperatorFunctionType): number;
export function gt(fn: OperatorFunctionType): boolean;
export function eq(fn: OperatorFunctionType): boolean;
export function lt(fn: OperatorFunctionType): boolean;
export function ge(fn: OperatorFunctionType): boolean;
export function nq(fn: OperatorFunctionType): boolean;
export function gte(fn: OperatorFunctionType): boolean;
export function neq(fn: OperatorFunctionType): boolean;
export function le(fn: OperatorFunctionType): boolean;
export function lte(fn: OperatorFunctionType): boolean;
export function arbitrary(fn: OperatorFunctionType): boolean;
export function compare(version: string, other: string): number;
export function rcompare(version: string, other: string): number;
export function gt(version: string, other: string): boolean;
export function eq(version: string, other: string): boolean;
export function lt(version: string, other: string): boolean;
export function ge(version: string, other: string): boolean;
export function nq(version: string, other: string): boolean;
export function gte(version: string, other: string): boolean;
export function neq(version: string, other: string): boolean;
export function le(version: string, other: string): boolean;
export function lte(version: string, other: string): boolean;
export function arbitrary(version: string, other: string): boolean;

//range
export function satisfies(version: string, specifier: string): boolean;
Expand All @@ -38,7 +34,7 @@ export function minSatisfying(
): string | null;

//semantic
export function major(fn: SemanticFunctionType): number;
export function minor(fn: SemanticFunctionType): number;
export function patch(fn: SemanticFunctionType): number;
export function inc(fn: SemanticFunctionType): string | null;
export function major(input: string | SemVer): number;
export function minor(input: string | SemVer): number;
export function patch(input: string | SemVer): number;
export function inc(input: string | SemVer): string | null;
20 changes: 9 additions & 11 deletions lib/operator.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { OperatorFunctionType } from "./shared";

export function compare(fn: OperatorFunctionType): number;
export function rcompare(fn: OperatorFunctionType): number;
export function gt(fn: OperatorFunctionType): boolean;
export function eq(fn: OperatorFunctionType): boolean;
export function lt(fn: OperatorFunctionType): boolean;
export function ge(fn: OperatorFunctionType): boolean;
export function nq(fn: OperatorFunctionType): boolean;
export function le(fn: OperatorFunctionType): boolean;
export function arbitrary(fn: OperatorFunctionType): boolean;
export function compare(version: string, other: string): number;
export function rcompare(version: string, other: string): number;
export function gt(version: string, other: string): boolean;
export function eq(version: string, other: string): boolean;
export function lt(version: string, other: string): boolean;
export function ge(version: string, other: string): boolean;
export function nq(version: string, other: string): boolean;
export function le(version: string, other: string): boolean;
export function arbitrary(version: string, other: string): boolean;
10 changes: 5 additions & 5 deletions lib/semantic.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SemanticFunctionType } from "./shared";
import type { SemVer } from "semver";

export function major(fn: SemanticFunctionType): number;
export function minor(fn: SemanticFunctionType): number;
export function patch(fn: SemanticFunctionType): number;
export function inc(fn: SemanticFunctionType): string | null;
export function major(input: string | SemVer): number;
export function minor(input: string | SemVer): number;
export function patch(input: string | SemVer): number;
export function inc(input: string | SemVer): string | null;
4 changes: 0 additions & 4 deletions lib/shared.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { SemVer } from "semver";
export interface parsed {
viceice marked this conversation as resolved.
Show resolved Hide resolved
public: string;
base_version: string;
Expand All @@ -17,6 +16,3 @@ export interface Range {
prefix: string;
version: string;
}
export type VersionFunctionType = (version: string) => string | null;
export type SemanticFunctionType = (input: string | SemVer) => number;
export type OperatorFunctionType = (version: string, other: string) => number;
12 changes: 6 additions & 6 deletions lib/version.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { VersionFunctionType, parsed } from "./shared";
import type { parsed } from "./shared";

export const VERSION_PATTERN: string;
export function valid(fn: VersionFunctionType): string | null;
export function clean(fn: VersionFunctionType): string | null;
export function stringify(fn: VersionFunctionType): string | null;
export function parse(fn: VersionFunctionType): parsed | null;
export function explain(fn: VersionFunctionType): parsed | null;
export function valid(version: string): string | null;
export function clean(version: string): string | null;
export function stringify(version: string): string | null;
export function parse(version: string): parsed | null;
export function explain(version: string): parsed | null;