Files
homeassistant-mcp/src/polyfills.ts
jango-blockchained ada5ea4646 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.
2024-12-17 15:07:40 +01:00

24 lines
689 B
TypeScript

// 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 { };