barsa 1b944f57aa Update Configuration Files and Refactor Code Structure
- Adjusted .prettierrc to ensure consistent formatting with a newline at the end of the file.
- Reformatted eslint.config.mjs for improved readability by aligning array elements.
- Updated pnpm-lock.yaml to use single quotes for consistency across dependencies.
- Simplified worktree setup in .cursor/worktrees.json for cleaner configuration.
- Enhanced documentation in .cursor/plans to clarify architecture refactoring.
- Refactored various service files for improved readability and maintainability, including rate-limiting and auth services.
- Updated imports and exports across multiple files for consistency and clarity.
- Improved error handling and logging in service methods to enhance debugging capabilities.
- Streamlined utility functions for better performance and maintainability across the domain packages.
2025-12-25 17:30:02 +09:00

62 lines
1.4 KiB
TypeScript

/**
* Toolkit - Type Guards
*
* Type guard utilities for runtime type checking.
*/
/**
* Check if value is a non-null object
*/
export function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
/**
* Check if value is a non-empty array
*/
export function isNonEmptyArray<T>(value: unknown): value is [T, ...T[]] {
return Array.isArray(value) && value.length > 0;
}
/**
* Check if value is a string
*/
export function isString(value: unknown): value is string {
return typeof value === "string";
}
/**
* Check if value is a number
*/
export function isNumber(value: unknown): value is number {
return typeof value === "number" && !isNaN(value);
}
/**
* Check if value is a boolean
*/
export function isBoolean(value: unknown): value is boolean {
return typeof value === "boolean";
}
/**
* Check if value is null or undefined
*/
export function isNullish(value: unknown): value is null | undefined {
return value === null || value === undefined;
}
/**
* Check if value is defined (not null or undefined)
*/
export function isDefined<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined;
}
/**
* Filter out null/undefined values from array
*/
export function filterDefined<T>(arr: (T | null | undefined)[]): T[] {
return arr.filter(isDefined);
}