Enhance project structure and testing capabilities
- Updated .dockerignore to include additional logs and IDE files, improving Docker build efficiency. - Added .eslintrc.json for TypeScript linting configuration, ensuring code quality and consistency. - Refactored Dockerfile to streamline the build process and utilize a slimmer Node.js image. - Introduced jest-resolver.cjs and jest.setup.js for improved Jest testing configuration and setup. - Updated jest.config.js to support ESM and added new test patterns for better test organization. - Enhanced TypeScript schemas to include new device types (media_player, fan, lock, vacuum, scene, script, camera) for comprehensive validation. - Added unit tests for device schemas and Home Assistant connection, improving test coverage and reliability. - Updated README.md with new testing instructions and device control examples, enhancing user guidance.
This commit is contained in:
24
src/polyfills.ts
Normal file
24
src/polyfills.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
// Extend global Array interface to include toSorted and toReversed methods
|
||||
declare global {
|
||||
interface Array<T> {
|
||||
toSorted(compareFn?: (a: T, b: T) => number): T[];
|
||||
toReversed(): T[];
|
||||
}
|
||||
}
|
||||
|
||||
// Polyfill for toSorted method
|
||||
if (typeof Array.prototype.toSorted !== 'function') {
|
||||
Array.prototype.toSorted = function <T>(compareFn?: (a: T, b: T) => number): T[] {
|
||||
return [...this].sort(compareFn);
|
||||
};
|
||||
}
|
||||
|
||||
// Polyfill for toReversed method
|
||||
if (typeof Array.prototype.toReversed !== 'function') {
|
||||
Array.prototype.toReversed = function <T>(): T[] {
|
||||
return [...this].reverse();
|
||||
};
|
||||
}
|
||||
|
||||
// Export an empty object to make this a module
|
||||
export { };
|
||||
Reference in New Issue
Block a user