From 1aef825c46fe5771de13a77d2631396ce42b0d0f Mon Sep 17 00:00:00 2001 From: morningstarxcdcode Date: Fri, 13 Jun 2025 13:01:07 +0530 Subject: [PATCH] Fix code issues and improve maintainability 1. Fix syntax error in tsconfig.json by removing trailing comma 2. Rename confusing function isAbsoluteModule2 to createModuloChecker 3. Update Whitespace type definition to be more accurate --- source/index.ts | 6 +++--- source/types.ts | 2 +- tsconfig.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/index.ts b/source/index.ts index 894318e..eadf32a 100644 --- a/source/index.ts +++ b/source/index.ts @@ -326,7 +326,7 @@ const is = Object.assign( }, ); -function isAbsoluteModule2(remainder: 0 | 1) { +function createModuloChecker(remainder: 0 | 1) { return (value: unknown): value is number => isInteger(value) && Math.abs(value % 2) === remainder; } @@ -466,7 +466,7 @@ export function isError(value: unknown): value is Error { } export function isEvenInteger(value: unknown): value is number { - return isAbsoluteModule2(0)(value); + return createModuloChecker(0)(value); } // Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);` @@ -647,7 +647,7 @@ export function isObservable(value: unknown): value is ObservableLike { } export function isOddInteger(value: unknown): value is number { - return isAbsoluteModule2(1)(value); + return createModuloChecker(1)(value); } export function isPlainObject(value: unknown): value is Record { diff --git a/source/types.ts b/source/types.ts index b79a603..c033fbf 100644 --- a/source/types.ts +++ b/source/types.ts @@ -74,4 +74,4 @@ export type Predicate = (value: unknown) => boolean; export type NonEmptyString = string & {0: string}; -export type Whitespace = ' '; +export type Whitespace = string & {_whitespace: true}; // String containing only whitespace characters diff --git a/tsconfig.json b/tsconfig.json index 0aace6f..d9a0389 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,5 +2,5 @@ "extends": "@sindresorhus/tsconfig", "include": [ "source" - ], + ] }