How open-draft/until works
Project type and purpose
• This is an open-source JavaScript/TypeScript utility library published to NPM (@open-draft/until).
• Purpose: provide a single until() function that wraps Promise calls with consistent error/data output.
File structure
• Top-level files:
• package.json, pnpm-lock.yaml (package manifest and lock)
• .github/workflows/ci.yml (CI pipeline)
• jest.config.js (test runner)
• tsup.config.ts (bundler config)
• ossjs.release.config.js (release automation)
• src/ (source code) with:
– index.ts (entry point)
– until.ts (core implementation)
– until.test.ts (unit tests)
• No frontend/backend split—this is a library.
README for additional insights
• Describes the API (until()), usage examples (JS & TS), and rationale.
Main components and their interactions
a. Source Code
• until.ts: Core logic
• index.ts: Exports API
• until.test.ts: Unit tests for core logic
b. Build & Test
• Tsup (bundler) compiles TypeScript → JavaScript, generates type declarations
• Jest runs unit tests against source code
c. CI/CD Pipeline
• GitHub Actions (ci.yml):
1. Checkout code
2. Install dependencies
3. Run lint/type-check
4. Run tests (Jest)
5. Bundle (Tsup)
6. Publish to NPM (via ossjs.release.config.js)
d. Consumers & Registry
• NPM Registry: hosts published package
• Library Consumers: downstream applications import @open-draft/until
Architectural patterns and design principles
• Single-responsibility: one core module (until)
• Test-driven: unit tests live alongside implementation
• CI-driven release: automated build/test/publish
• Minimal external dependencies
• Clear separation: source, tests, build config, CI config
Putting it all together
• Left side: Developer commits code → GitHub repo.
• Center top: CI pipeline (checkout → install → lint/type-check → test → bundle → publish).
• Center bottom: Modules and tools:
┌───────────┐ ┌─────────┐
│ index.ts ├─┬─▶ │ until.ts │
└───────────┘ │ └─────────┘
│ ▲
▼ │
┌─────────┐ │
│ tests ├──┘
└─────────┘
• Right side: NPM registry → Consumers import library.