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
This commit is contained in:
parent
ef35cc350a
commit
1aef825c46
3 changed files with 5 additions and 5 deletions
|
|
@ -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: unknown): value is Record<PropertyKey, Value> {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
"extends": "@sindresorhus/tsconfig",
|
||||
"include": [
|
||||
"source"
|
||||
],
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue