From 117ad5b6facc55d2e51e66f62bd62e05f06b2d24 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Tue, 4 Jan 2022 23:38:20 +0545 Subject: [PATCH 01/16] add type declarations --- index.d.ts | 43 +++++++++++++++++++++++++++++++++++++++++ lib/operator.d.ts | 9 +++++++++ lib/semantic.d.ts | 5 +++++ lib/specifier.d.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++ lib/version.d.ts | 25 ++++++++++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 index.d.ts create mode 100644 lib/operator.d.ts create mode 100644 lib/semantic.d.ts create mode 100644 lib/specifier.d.ts create mode 100644 lib/version.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..33706c1 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,43 @@ +import {SemVer} from "semver"; +interface parsed{ + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; + } +export declare function valid(version: string): string | null; +export declare function clean(version: string): string | null; +export declare function explain(version: string): parsed | null; + +//operator +export declare function compare(version: string, other: string): number; +export declare function rcompare(version: string, other: string): number; +export declare function gt(version: string, other: string): boolean; +export declare function eq(version: string, other: string): boolean; +export declare function lt(version: string, other: string): boolean; +export declare function ge(version: string, other: string): boolean; +export declare function nq(version: string, other: string): boolean; +export declare function gte(version: string, other: string): boolean; +export declare function neq(version: string, other: string): boolean; +export declare function le(version: string, other: string): boolean; +export declare function lte(version: string, other: string): boolean; +export declare function arbitrary(version: string, other: string): boolean; + +//range +export function satisfies(version: string, specifier: string): boolean; +export function validRange(specifier: string): boolean; +export function maxSatisfying(version: string, specifier: string, options: parsed): string | null; +export function minSatisfying(version: string, specifier: string, options: parsed): string | null; + +//semantic +export declare function major(input: string | SemVer): number; +export declare function minor(input: string | SemVer): number; +export declare function patch(input: string | SemVer): number; +export declare function inc(input: string | SemVer): string | null; diff --git a/lib/operator.d.ts b/lib/operator.d.ts new file mode 100644 index 0000000..80b81fc --- /dev/null +++ b/lib/operator.d.ts @@ -0,0 +1,9 @@ +export declare function compare(version: string, other: string): number; +export declare function rcompare(version: string, other: string): number; +export declare function gt(version: string, other: string): boolean; +export declare function eq(version: string, other: string): boolean; +export declare function lt(version: string, other: string): boolean; +export declare function ge(version: string, other: string): boolean; +export declare function nq(version: string, other: string): boolean; +export declare function le(version: string, other: string): boolean; +export declare function arbitrary(version: string, other: string): boolean; diff --git a/lib/semantic.d.ts b/lib/semantic.d.ts new file mode 100644 index 0000000..eec1b08 --- /dev/null +++ b/lib/semantic.d.ts @@ -0,0 +1,5 @@ +import {SemVer} from "semver"; +export declare function major(input: string | SemVer): number; +export declare function minor(input: string | SemVer): number; +export declare function patch(input: string | SemVer): number; +export declare function inc(input: string | SemVer): string | null; diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts new file mode 100644 index 0000000..c78ad36 --- /dev/null +++ b/lib/specifier.d.ts @@ -0,0 +1,48 @@ +export declare const RANGE_PATTERN : string; +interface Range { + operator: string; + prefix: string; + version: string; + } + interface parsed{ + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; + } + /* + parse function takes a string and returns an object that has the values of both th ebelow interfaces combined + interface Range { + operator: string; + prefix: string; + version: string; + } + * interface parsed{ + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; +} + still I have used interface Range as its return type cause it is being used in the file + lib/versioning/pep440/range.ts as so L52 + */ + export function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed + export function filter(versions: string[], range: string): string[]; + export function satisfies(version: string, specifier: string): boolean; + export function validRange(specifier: string): boolean; + export function maxSatisfying(version: string, specifier: string, options: parsed): string | null; + export function minSatisfying(version: string, specifier: string, options: parsed): string | null; diff --git a/lib/version.d.ts b/lib/version.d.ts new file mode 100644 index 0000000..d1bed8a --- /dev/null +++ b/lib/version.d.ts @@ -0,0 +1,25 @@ +export declare const VERSION_PATTERN: string; +export declare function valid(version: string): string | null; +export declare function clean(version: string): string | null; +export declare function stringify(version: string): string | null; + +interface parsed{ + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; +} +export declare function parse(version: string): parsed | null; +export declare function explain(version: string): parsed | null; + + + + + From 1075f1667b7962b557d00cb4c0b7f3174a22b16a Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 01:06:04 +0545 Subject: [PATCH 02/16] refactor: run prettier --- index.d.ts | 46 +++++++++++++++++++++--------------- lib/semantic.d.ts | 10 ++++---- lib/specifier.d.ts | 58 ++++++++++++++++++++++++++-------------------- lib/version.d.ts | 7 +----- 4 files changed, 66 insertions(+), 55 deletions(-) diff --git a/index.d.ts b/index.d.ts index 33706c1..dc60766 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,17 +1,17 @@ -import {SemVer} from "semver"; -interface parsed{ - public: string; - base_version: string; - is_prerelease: boolean; - is_devrelease: boolean; - is_postrelease: boolean; - epoch: number; - release: number[]; - pre: (string | number)[]; - post: (string | number)[]; - dev: (string | number)[]; - local: string | null; - } +import { SemVer } from "semver"; +interface parsed { + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; +} export declare function valid(version: string): string | null; export declare function clean(version: string): string | null; export declare function explain(version: string): parsed | null; @@ -33,11 +33,19 @@ export declare function arbitrary(version: string, other: string): boolean; //range export function satisfies(version: string, specifier: string): boolean; export function validRange(specifier: string): boolean; -export function maxSatisfying(version: string, specifier: string, options: parsed): string | null; -export function minSatisfying(version: string, specifier: string, options: parsed): string | null; +export function maxSatisfying( + version: string, + specifier: string, + options: parsed +): string | null; +export function minSatisfying( + version: string, + specifier: string, + options: parsed +): string | null; //semantic export declare function major(input: string | SemVer): number; -export declare function minor(input: string | SemVer): number; -export declare function patch(input: string | SemVer): number; -export declare function inc(input: string | SemVer): string | null; +export declare function minor(input: string | SemVer): number; +export declare function patch(input: string | SemVer): number; +export declare function inc(input: string | SemVer): string | null; diff --git a/lib/semantic.d.ts b/lib/semantic.d.ts index eec1b08..78fcc72 100644 --- a/lib/semantic.d.ts +++ b/lib/semantic.d.ts @@ -1,5 +1,5 @@ -import {SemVer} from "semver"; -export declare function major(input: string | SemVer): number; -export declare function minor(input: string | SemVer): number; -export declare function patch(input: string | SemVer): number; -export declare function inc(input: string | SemVer): string | null; +import { SemVer } from "semver"; +export declare function major(input: string | SemVer): number; +export declare function minor(input: string | SemVer): number; +export declare function patch(input: string | SemVer): number; +export declare function inc(input: string | SemVer): string | null; diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts index c78ad36..2fa9972 100644 --- a/lib/specifier.d.ts +++ b/lib/specifier.d.ts @@ -1,23 +1,23 @@ -export declare const RANGE_PATTERN : string; +export declare const RANGE_PATTERN: string; interface Range { - operator: string; - prefix: string; - version: string; - } - interface parsed{ - public: string; - base_version: string; - is_prerelease: boolean; - is_devrelease: boolean; - is_postrelease: boolean; - epoch: number; - release: number[]; - pre: (string | number)[]; - post: (string | number)[]; - dev: (string | number)[]; - local: string | null; - } - /* + operator: string; + prefix: string; + version: string; +} +interface parsed { + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; +} +/* parse function takes a string and returns an object that has the values of both th ebelow interfaces combined interface Range { operator: string; @@ -40,9 +40,17 @@ interface Range { still I have used interface Range as its return type cause it is being used in the file lib/versioning/pep440/range.ts as so L52 */ - export function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed - export function filter(versions: string[], range: string): string[]; - export function satisfies(version: string, specifier: string): boolean; - export function validRange(specifier: string): boolean; - export function maxSatisfying(version: string, specifier: string, options: parsed): string | null; - export function minSatisfying(version: string, specifier: string, options: parsed): string | null; +export function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed +export function filter(versions: string[], range: string): string[]; +export function satisfies(version: string, specifier: string): boolean; +export function validRange(specifier: string): boolean; +export function maxSatisfying( + version: string, + specifier: string, + options: parsed +): string | null; +export function minSatisfying( + version: string, + specifier: string, + options: parsed +): string | null; diff --git a/lib/version.d.ts b/lib/version.d.ts index d1bed8a..3fb4016 100644 --- a/lib/version.d.ts +++ b/lib/version.d.ts @@ -3,7 +3,7 @@ export declare function valid(version: string): string | null; export declare function clean(version: string): string | null; export declare function stringify(version: string): string | null; -interface parsed{ +interface parsed { public: string; base_version: string; is_prerelease: boolean; @@ -18,8 +18,3 @@ interface parsed{ } export declare function parse(version: string): parsed | null; export declare function explain(version: string): parsed | null; - - - - - From fbdeb17a87c9bf90c3f124643fec2abb051ed2c7 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 14:45:07 +0545 Subject: [PATCH 03/16] added shared types file --- index.d.ts | 59 ++++++++++++++++++++-------------------------- lib/operator.d.ts | 20 +++++++++------- lib/semantic.d.ts | 11 +++++---- lib/shared.ts | 22 +++++++++++++++++ lib/specifier.d.ts | 21 +++-------------- lib/version.d.ts | 25 +++++--------------- 6 files changed, 74 insertions(+), 84 deletions(-) create mode 100644 lib/shared.ts diff --git a/index.d.ts b/index.d.ts index dc60766..10451a0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,34 +1,27 @@ -import { SemVer } from "semver"; -interface parsed { - public: string; - base_version: string; - is_prerelease: boolean; - is_devrelease: boolean; - is_postrelease: boolean; - epoch: number; - release: number[]; - pre: (string | number)[]; - post: (string | number)[]; - dev: (string | number)[]; - local: string | null; -} -export declare function valid(version: string): string | null; -export declare function clean(version: string): string | null; -export declare function explain(version: string): parsed | null; +import { + OperatorFunctionType, + parsed, + SemanticFunctionType, + VersionFunctionType, +} from "./lib/shared"; + +export declare function valid(fn: VersionFunctionType): string | null; +export declare function clean(fn: VersionFunctionType): string | null; +export declare function explain(fn: VersionFunctionType): parsed | null; //operator -export declare function compare(version: string, other: string): number; -export declare function rcompare(version: string, other: string): number; -export declare function gt(version: string, other: string): boolean; -export declare function eq(version: string, other: string): boolean; -export declare function lt(version: string, other: string): boolean; -export declare function ge(version: string, other: string): boolean; -export declare function nq(version: string, other: string): boolean; -export declare function gte(version: string, other: string): boolean; -export declare function neq(version: string, other: string): boolean; -export declare function le(version: string, other: string): boolean; -export declare function lte(version: string, other: string): boolean; -export declare function arbitrary(version: string, other: string): boolean; +export declare function compare(fn: OperatorFunctionType): number; +export declare function rcompare(fn: OperatorFunctionType): number; +export declare function gt(fn: OperatorFunctionType): boolean; +export declare function eq(fn: OperatorFunctionType): boolean; +export declare function lt(fn: OperatorFunctionType): boolean; +export declare function ge(fn: OperatorFunctionType): boolean; +export declare function nq(fn: OperatorFunctionType): boolean; +export declare function gte(fn: OperatorFunctionType): boolean; +export declare function neq(fn: OperatorFunctionType): boolean; +export declare function le(fn: OperatorFunctionType): boolean; +export declare function lte(fn: OperatorFunctionType): boolean; +export declare function arbitrary(fn: OperatorFunctionType): boolean; //range export function satisfies(version: string, specifier: string): boolean; @@ -45,7 +38,7 @@ export function minSatisfying( ): string | null; //semantic -export declare function major(input: string | SemVer): number; -export declare function minor(input: string | SemVer): number; -export declare function patch(input: string | SemVer): number; -export declare function inc(input: string | SemVer): string | null; +export declare function major(fn: SemanticFunctionType): number; +export declare function minor(fn: SemanticFunctionType): number; +export declare function patch(fn: SemanticFunctionType): number; +export declare function inc(fn: SemanticFunctionType): string | null; diff --git a/lib/operator.d.ts b/lib/operator.d.ts index 80b81fc..33bc837 100644 --- a/lib/operator.d.ts +++ b/lib/operator.d.ts @@ -1,9 +1,11 @@ -export declare function compare(version: string, other: string): number; -export declare function rcompare(version: string, other: string): number; -export declare function gt(version: string, other: string): boolean; -export declare function eq(version: string, other: string): boolean; -export declare function lt(version: string, other: string): boolean; -export declare function ge(version: string, other: string): boolean; -export declare function nq(version: string, other: string): boolean; -export declare function le(version: string, other: string): boolean; -export declare function arbitrary(version: string, other: string): boolean; +import { OperatorFunctionType } from "./shared"; + +export declare function compare(fn: OperatorFunctionType): number; +export declare function rcompare(fn: OperatorFunctionType): number; +export declare function gt(fn: OperatorFunctionType): boolean; +export declare function eq(fn: OperatorFunctionType): boolean; +export declare function lt(fn: OperatorFunctionType): boolean; +export declare function ge(fn: OperatorFunctionType): boolean; +export declare function nq(fn: OperatorFunctionType): boolean; +export declare function le(fn: OperatorFunctionType): boolean; +export declare function arbitrary(fn: OperatorFunctionType): boolean; diff --git a/lib/semantic.d.ts b/lib/semantic.d.ts index 78fcc72..31aeee4 100644 --- a/lib/semantic.d.ts +++ b/lib/semantic.d.ts @@ -1,5 +1,6 @@ -import { SemVer } from "semver"; -export declare function major(input: string | SemVer): number; -export declare function minor(input: string | SemVer): number; -export declare function patch(input: string | SemVer): number; -export declare function inc(input: string | SemVer): string | null; +import { SemanticFunctionType } from "./shared"; + +export declare function major(fn: SemanticFunctionType): number; +export declare function minor(fn: SemanticFunctionType): number; +export declare function patch(fn: SemanticFunctionType): number; +export declare function inc(fn: SemanticFunctionType): string | null; diff --git a/lib/shared.ts b/lib/shared.ts new file mode 100644 index 0000000..0cd2ee0 --- /dev/null +++ b/lib/shared.ts @@ -0,0 +1,22 @@ +import { SemVer } from "semver"; +export interface parsed { + public: string; + base_version: string; + is_prerelease: boolean; + is_devrelease: boolean; + is_postrelease: boolean; + epoch: number; + release: number[]; + pre: (string | number)[]; + post: (string | number)[]; + dev: (string | number)[]; + local: string | null; +} +export interface Range { + operator: string; + 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; diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts index 2fa9972..b3339c8 100644 --- a/lib/specifier.d.ts +++ b/lib/specifier.d.ts @@ -1,22 +1,7 @@ +import { parsed, Range } from "./shared"; + export declare const RANGE_PATTERN: string; -interface Range { - operator: string; - prefix: string; - version: string; -} -interface parsed { - public: string; - base_version: string; - is_prerelease: boolean; - is_devrelease: boolean; - is_postrelease: boolean; - epoch: number; - release: number[]; - pre: (string | number)[]; - post: (string | number)[]; - dev: (string | number)[]; - local: string | null; -} + /* parse function takes a string and returns an object that has the values of both th ebelow interfaces combined interface Range { diff --git a/lib/version.d.ts b/lib/version.d.ts index 3fb4016..47dbf89 100644 --- a/lib/version.d.ts +++ b/lib/version.d.ts @@ -1,20 +1,7 @@ +import type { VersionFunctionType, parsed } from "./shared"; export declare const VERSION_PATTERN: string; -export declare function valid(version: string): string | null; -export declare function clean(version: string): string | null; -export declare function stringify(version: string): string | null; - -interface parsed { - public: string; - base_version: string; - is_prerelease: boolean; - is_devrelease: boolean; - is_postrelease: boolean; - epoch: number; - release: number[]; - pre: (string | number)[]; - post: (string | number)[]; - dev: (string | number)[]; - local: string | null; -} -export declare function parse(version: string): parsed | null; -export declare function explain(version: string): parsed | null; +export declare function valid(fn: VersionFunctionType): string | null; +export declare function clean(fn: VersionFunctionType): string | null; +export declare function stringify(fn: VersionFunctionType): string | null; +export declare function parse(fn: VersionFunctionType): parsed | null; +export declare function explain(fn: VersionFunctionType): parsed | null; From 866765e0bec209bad086479ea3d7faba7769e132 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 15:27:22 +0545 Subject: [PATCH 04/16] Update lib/version.d.ts Co-authored-by: Michael Kriese --- lib/version.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/version.d.ts b/lib/version.d.ts index 47dbf89..214ea15 100644 --- a/lib/version.d.ts +++ b/lib/version.d.ts @@ -1,4 +1,5 @@ import type { VersionFunctionType, parsed } from "./shared"; + export declare const VERSION_PATTERN: string; export declare function valid(fn: VersionFunctionType): string | null; export declare function clean(fn: VersionFunctionType): string | null; From fd3f8507b6c59347a0f92ce6e586b7c53c139ff4 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 15:27:32 +0545 Subject: [PATCH 05/16] Update index.d.ts Co-authored-by: Michael Kriese --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 10451a0..9124a35 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import { +import type { OperatorFunctionType, parsed, SemanticFunctionType, From 7568f8cabe6b09bab26b8f157336b18168c5808d Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 15:27:38 +0545 Subject: [PATCH 06/16] Update lib/semantic.d.ts Co-authored-by: Michael Kriese --- lib/semantic.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/semantic.d.ts b/lib/semantic.d.ts index 31aeee4..012b8f3 100644 --- a/lib/semantic.d.ts +++ b/lib/semantic.d.ts @@ -1,4 +1,4 @@ -import { SemanticFunctionType } from "./shared"; +import type { SemanticFunctionType } from "./shared"; export declare function major(fn: SemanticFunctionType): number; export declare function minor(fn: SemanticFunctionType): number; From 669b698332d1e4242ea16a35c0e67775b4223638 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 15:27:50 +0545 Subject: [PATCH 07/16] Update lib/operator.d.ts Co-authored-by: Michael Kriese --- lib/operator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/operator.d.ts b/lib/operator.d.ts index 33bc837..b36e008 100644 --- a/lib/operator.d.ts +++ b/lib/operator.d.ts @@ -1,4 +1,4 @@ -import { OperatorFunctionType } from "./shared"; +import type { OperatorFunctionType } from "./shared"; export declare function compare(fn: OperatorFunctionType): number; export declare function rcompare(fn: OperatorFunctionType): number; From 08fed9696d50677a9645fe1587727cc205779f88 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 15:27:57 +0545 Subject: [PATCH 08/16] Update lib/shared.ts Co-authored-by: Michael Kriese --- lib/shared.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shared.ts b/lib/shared.ts index 0cd2ee0..aef4bc2 100644 --- a/lib/shared.ts +++ b/lib/shared.ts @@ -1,4 +1,4 @@ -import { SemVer } from "semver"; +import type { SemVer } from "semver"; export interface parsed { public: string; base_version: string; From 7d8bb7c5b2a395124ad34788b0a1d1cf166e42b7 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Fri, 7 Jan 2022 15:28:02 +0545 Subject: [PATCH 09/16] Update lib/specifier.d.ts Co-authored-by: Michael Kriese --- lib/specifier.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts index b3339c8..34d1bc2 100644 --- a/lib/specifier.d.ts +++ b/lib/specifier.d.ts @@ -1,4 +1,4 @@ -import { parsed, Range } from "./shared"; +import type { parsed, Range } from "./shared"; export declare const RANGE_PATTERN: string; From 7a395a044789ec12974ce28434b8e42e36c743cb Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sat, 8 Jan 2022 09:36:35 +0545 Subject: [PATCH 10/16] refactor: add missing declare in some fns --- index.d.ts | 8 ++++---- lib/specifier.d.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 10451a0..6c3c554 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,14 +24,14 @@ export declare function lte(fn: OperatorFunctionType): boolean; export declare function arbitrary(fn: OperatorFunctionType): boolean; //range -export function satisfies(version: string, specifier: string): boolean; -export function validRange(specifier: string): boolean; -export function maxSatisfying( +export declare function satisfies(version: string, specifier: string): boolean; +export declare function validRange(specifier: string): boolean; +export declare function maxSatisfying( version: string, specifier: string, options: parsed ): string | null; -export function minSatisfying( +export declare function minSatisfying( version: string, specifier: string, options: parsed diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts index b3339c8..b0c4b23 100644 --- a/lib/specifier.d.ts +++ b/lib/specifier.d.ts @@ -25,16 +25,16 @@ export declare const RANGE_PATTERN: string; still I have used interface Range as its return type cause it is being used in the file lib/versioning/pep440/range.ts as so L52 */ -export function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed -export function filter(versions: string[], range: string): string[]; -export function satisfies(version: string, specifier: string): boolean; -export function validRange(specifier: string): boolean; -export function maxSatisfying( +export declare function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed +export declare function filter(versions: string[], range: string): string[]; +export declare function satisfies(version: string, specifier: string): boolean; +export declare function validRange(specifier: string): boolean; +export declare function maxSatisfying( version: string, specifier: string, options: parsed ): string | null; -export function minSatisfying( +export declare function minSatisfying( version: string, specifier: string, options: parsed From b83990f51c2d4891843851276f393506358d0b1f Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sat, 8 Jan 2022 17:17:04 +0545 Subject: [PATCH 11/16] refactor: removed declare keyword --- index.d.ts | 46 +++++++++++++++++++++++----------------------- lib/operator.d.ts | 18 +++++++++--------- lib/semantic.d.ts | 8 ++++---- lib/specifier.d.ts | 12 ++++++------ lib/version.d.ts | 12 ++++++------ 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/index.d.ts b/index.d.ts index 00b9984..79c7e3b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,40 +5,40 @@ import type { VersionFunctionType, } from "./lib/shared"; -export declare function valid(fn: VersionFunctionType): string | null; -export declare function clean(fn: VersionFunctionType): string | null; -export declare function explain(fn: VersionFunctionType): parsed | null; +export function valid(fn: VersionFunctionType): string | null; +export function clean(fn: VersionFunctionType): string | null; +export function explain(fn: VersionFunctionType): parsed | null; //operator -export declare function compare(fn: OperatorFunctionType): number; -export declare function rcompare(fn: OperatorFunctionType): number; -export declare function gt(fn: OperatorFunctionType): boolean; -export declare function eq(fn: OperatorFunctionType): boolean; -export declare function lt(fn: OperatorFunctionType): boolean; -export declare function ge(fn: OperatorFunctionType): boolean; -export declare function nq(fn: OperatorFunctionType): boolean; -export declare function gte(fn: OperatorFunctionType): boolean; -export declare function neq(fn: OperatorFunctionType): boolean; -export declare function le(fn: OperatorFunctionType): boolean; -export declare function lte(fn: OperatorFunctionType): boolean; -export declare function arbitrary(fn: OperatorFunctionType): boolean; +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; //range -export declare function satisfies(version: string, specifier: string): boolean; -export declare function validRange(specifier: string): boolean; -export declare function maxSatisfying( +export function satisfies(version: string, specifier: string): boolean; +export function validRange(specifier: string): boolean; +export function maxSatisfying( version: string, specifier: string, options: parsed ): string | null; -export declare function minSatisfying( +export function minSatisfying( version: string, specifier: string, options: parsed ): string | null; //semantic -export declare function major(fn: SemanticFunctionType): number; -export declare function minor(fn: SemanticFunctionType): number; -export declare function patch(fn: SemanticFunctionType): number; -export declare function inc(fn: SemanticFunctionType): string | null; +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; diff --git a/lib/operator.d.ts b/lib/operator.d.ts index b36e008..9f70d5e 100644 --- a/lib/operator.d.ts +++ b/lib/operator.d.ts @@ -1,11 +1,11 @@ import type { OperatorFunctionType } from "./shared"; -export declare function compare(fn: OperatorFunctionType): number; -export declare function rcompare(fn: OperatorFunctionType): number; -export declare function gt(fn: OperatorFunctionType): boolean; -export declare function eq(fn: OperatorFunctionType): boolean; -export declare function lt(fn: OperatorFunctionType): boolean; -export declare function ge(fn: OperatorFunctionType): boolean; -export declare function nq(fn: OperatorFunctionType): boolean; -export declare function le(fn: OperatorFunctionType): boolean; -export declare function arbitrary(fn: OperatorFunctionType): boolean; +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; diff --git a/lib/semantic.d.ts b/lib/semantic.d.ts index 012b8f3..c073897 100644 --- a/lib/semantic.d.ts +++ b/lib/semantic.d.ts @@ -1,6 +1,6 @@ import type { SemanticFunctionType } from "./shared"; -export declare function major(fn: SemanticFunctionType): number; -export declare function minor(fn: SemanticFunctionType): number; -export declare function patch(fn: SemanticFunctionType): number; -export declare function inc(fn: SemanticFunctionType): string | null; +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; diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts index 8e4f0cb..34d1bc2 100644 --- a/lib/specifier.d.ts +++ b/lib/specifier.d.ts @@ -25,16 +25,16 @@ export declare const RANGE_PATTERN: string; still I have used interface Range as its return type cause it is being used in the file lib/versioning/pep440/range.ts as so L52 */ -export declare function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed -export declare function filter(versions: string[], range: string): string[]; -export declare function satisfies(version: string, specifier: string): boolean; -export declare function validRange(specifier: string): boolean; -export declare function maxSatisfying( +export function parse(ranges: string): Range[]; // have doubts regarding this which need to be discussed +export function filter(versions: string[], range: string): string[]; +export function satisfies(version: string, specifier: string): boolean; +export function validRange(specifier: string): boolean; +export function maxSatisfying( version: string, specifier: string, options: parsed ): string | null; -export declare function minSatisfying( +export function minSatisfying( version: string, specifier: string, options: parsed diff --git a/lib/version.d.ts b/lib/version.d.ts index 214ea15..f31cd53 100644 --- a/lib/version.d.ts +++ b/lib/version.d.ts @@ -1,8 +1,8 @@ import type { VersionFunctionType, parsed } from "./shared"; -export declare const VERSION_PATTERN: string; -export declare function valid(fn: VersionFunctionType): string | null; -export declare function clean(fn: VersionFunctionType): string | null; -export declare function stringify(fn: VersionFunctionType): string | null; -export declare function parse(fn: VersionFunctionType): parsed | null; -export declare function explain(fn: VersionFunctionType): parsed | null; +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; From 6d67e522c0238526061fa4cd3cc8c5ed1812b7e0 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sun, 9 Jan 2022 16:15:10 +0545 Subject: [PATCH 12/16] Update lib/specifier.d.ts Co-authored-by: Michael Kriese --- lib/specifier.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/specifier.d.ts b/lib/specifier.d.ts index 34d1bc2..f9a4998 100644 --- a/lib/specifier.d.ts +++ b/lib/specifier.d.ts @@ -1,6 +1,6 @@ import type { parsed, Range } from "./shared"; -export declare const RANGE_PATTERN: string; +export const RANGE_PATTERN: string; /* parse function takes a string and returns an object that has the values of both th ebelow interfaces combined From 1362e9de0403bcbc664cae2697f211040f846d56 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sun, 9 Jan 2022 16:15:41 +0545 Subject: [PATCH 13/16] Rename shared.ts to shared.d.ts --- lib/{shared.ts => shared.d.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{shared.ts => shared.d.ts} (100%) diff --git a/lib/shared.ts b/lib/shared.d.ts similarity index 100% rename from lib/shared.ts rename to lib/shared.d.ts From b4160316035d0e853c45c5bcb2940ef77e629888 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sun, 9 Jan 2022 17:50:55 +0545 Subject: [PATCH 14/16] Update package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ca9c873..0e833c8 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ }, "files": [ "index.js", - "lib" + "lib", + "index.d.ts" ], "dependencies": { "xregexp": "4.4.1" From 2946a0c4370e555a3e47790f7484e923d09380e2 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Mon, 10 Jan 2022 14:45:56 +0545 Subject: [PATCH 15/16] refactor: remove function types --- index.d.ts | 46 +++++++++++++++++++++------------------------- lib/operator.d.ts | 20 +++++++++----------- lib/semantic.d.ts | 10 +++++----- lib/shared.ts | 4 ---- lib/version.d.ts | 12 ++++++------ package.json | 3 ++- 6 files changed, 43 insertions(+), 52 deletions(-) diff --git a/index.d.ts b/index.d.ts index 79c7e3b..bf674bc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; @@ -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; diff --git a/lib/operator.d.ts b/lib/operator.d.ts index 9f70d5e..45f703e 100644 --- a/lib/operator.d.ts +++ b/lib/operator.d.ts @@ -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; diff --git a/lib/semantic.d.ts b/lib/semantic.d.ts index c073897..98c1811 100644 --- a/lib/semantic.d.ts +++ b/lib/semantic.d.ts @@ -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; diff --git a/lib/shared.ts b/lib/shared.ts index aef4bc2..c549b7f 100644 --- a/lib/shared.ts +++ b/lib/shared.ts @@ -1,4 +1,3 @@ -import type { SemVer } from "semver"; export interface parsed { public: string; base_version: string; @@ -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; diff --git a/lib/version.d.ts b/lib/version.d.ts index f31cd53..6991c05 100644 --- a/lib/version.d.ts +++ b/lib/version.d.ts @@ -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; diff --git a/package.json b/package.json index ca9c873..0e833c8 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ }, "files": [ "index.js", - "lib" + "lib", + "index.d.ts" ], "dependencies": { "xregexp": "4.4.1" From e0c8d053063d9d9f00838cbdabe4c9d15b5b32d1 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Mon, 10 Jan 2022 14:53:49 +0545 Subject: [PATCH 16/16] refactor: run prettier --- index.d.ts | 2 +- lib/operator.d.ts | 2 +- lib/shared.d.ts | 2 +- lib/version.d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index c725e9f..bf674bc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -37,4 +37,4 @@ export function minSatisfying( 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; \ No newline at end of file +export function inc(input: string | SemVer): string | null; diff --git a/lib/operator.d.ts b/lib/operator.d.ts index 42f0905..45f703e 100644 --- a/lib/operator.d.ts +++ b/lib/operator.d.ts @@ -6,4 +6,4 @@ 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; \ No newline at end of file +export function arbitrary(version: string, other: string): boolean; diff --git a/lib/shared.d.ts b/lib/shared.d.ts index e43333d..c549b7f 100644 --- a/lib/shared.d.ts +++ b/lib/shared.d.ts @@ -15,4 +15,4 @@ export interface Range { operator: string; prefix: string; version: string; -} \ No newline at end of file +} diff --git a/lib/version.d.ts b/lib/version.d.ts index fc0071c..6991c05 100644 --- a/lib/version.d.ts +++ b/lib/version.d.ts @@ -5,4 +5,4 @@ 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; \ No newline at end of file +export function explain(version: string): parsed | null;