How devlato/async-wait-until works
Main Components
• Core Library Module: The central functionality lives in src/index.ts where the waitUntil function is defined. This is the entry point for users of the library.
• Error Handling: Special attention is given to timeouts (e.g., the custom TimeoutError) and configurable options like timeout and intervalBetweenAttempts.
• Utility Functions: Under src/utils (e.g., create_tests.ts), additional helper functions may be in use to support testing or enhance functionality.
• Testing Framework: The presence of unit tests in both src/tests and tests directories as well as multiple jest config files implies a strong focus on testing.
• Build & Documentation: Configuration files for Rollup (rollup.config.mjs), TypeScript (tsconfig.json), and Typedoc (typedoc.config.mjs) indicate automated build and documentation processes.
• Code Quality & CI: Files like .eslint, .prettier configurations, GitHub workflows, and Husky pre-commit hooks form the ancillary components that maintain code quality and enforce standards.
Relationships and Interactions
• User Interaction: The library exports functions (notably waitUntil) that users call in different JavaScript environments (UMD, CommonJS, ESM), ensuring compatibility.
• Internal Utilities and Error Handling: Within the core logic, utility functions support predicate evaluation while error handling (e.g., throwing TimeoutError) manages failure conditions.
• Testing and Build Pipelines: Unit and integration tests in the tests directories interact with the core module, ensuring that changes are validated by CI (see GitHub workflows). The build process (using Rollup) compiles source code into different module formats.
• Documentation Generation: Typedoc is used to generate documentation, which should be part of the development pipeline but is external to the runtime library.
Architectural Patterns and Design Principles
• Modular Design: The separation between core logic, utilities, and tests supports clarity and maintainability.
• Zero Dependency & Cross-Environment Compatibility: The design intentionally has no extra dependencies, focusing on lightweight, pure JavaScript implementation.
• Continuous Integration/Deployment: The CI workflows (e.g., linting, tests, publishing, releases) ensure high-quality code and smooth deployment processes.
Technologies, Frameworks, or Libraries
• TypeScript for type safety (tsconfig.json).
• Build tools like Rollup for bundling.
• Jest for testing (multiple jest configurations).
• Typedoc for documentation.
• GitHub Actions for CI/CD workflows.
• Husky for pre-commit hooks to enforce code quality.