Skip to content

Commit 1aef825

Browse files
author
morningstarxcdcode
committed
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
1 parent ef35cc3 commit 1aef825

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

source/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ const is = Object.assign(
326326
},
327327
);
328328

329-
function isAbsoluteModule2(remainder: 0 | 1) {
329+
function createModuloChecker(remainder: 0 | 1) {
330330
return (value: unknown): value is number => isInteger(value) && Math.abs(value % 2) === remainder;
331331
}
332332

@@ -466,7 +466,7 @@ export function isError(value: unknown): value is Error {
466466
}
467467

468468
export function isEvenInteger(value: unknown): value is number {
469-
return isAbsoluteModule2(0)(value);
469+
return createModuloChecker(0)(value);
470470
}
471471

472472
// 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 {
647647
}
648648

649649
export function isOddInteger(value: unknown): value is number {
650-
return isAbsoluteModule2(1)(value);
650+
return createModuloChecker(1)(value);
651651
}
652652

653653
export function isPlainObject<Value = unknown>(value: unknown): value is Record<PropertyKey, Value> {

source/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ export type Predicate = (value: unknown) => boolean;
7474

7575
export type NonEmptyString = string & {0: string};
7676

77-
export type Whitespace = ' ';
77+
export type Whitespace = string & {_whitespace: true}; // String containing only whitespace characters

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"extends": "@sindresorhus/tsconfig",
33
"include": [
44
"source"
5-
],
5+
]
66
}

0 commit comments

Comments
 (0)