How melleb/tinyduration works
Project type and purpose
• This is a lightweight TypeScript-based JavaScript library (an NPM package) called “TinyDuration.”
• Its sole responsibility is to parse ISO-8601 duration strings into a plain object and serialize such objects back into ISO-8601 strings.
• It ships to the NPM registry (< 1 KB minified+gzipped) and has zero runtime dependencies.
File structure
• Top-level: configuration for ESLint, Prettier, GitHub Actions CI, Changesets (for versioning), TypeScript, Jest tests, and .gitignore/.npmignore.
• src/index.ts: the single entry point exporting parse() and serialize().
• src/index.test.ts: Jest tests covering both functions.
• dist (generated at publish time): transpiled JavaScript artifacts for distribution.
README for additional insights
• Confirms that this is a library (no server, database, or UI).
• Describes development workflow: npm test, npm run lint, npm run prettify, CI via GitHub Actions, Changesets for version bumps, npx changeset publish.
a. Main Components
• Developer workstation (TypeScript source + tests + config)
• Build & Test pipeline (TypeScript compiler → Jest tests → lint/format checks)
• CI/CD server (GitHub Actions)
• NPM Registry (artifact storage)
• Consumer application (any JS/TS project that installs tinyduration)
b. Relationships & Data Flow
1. Developer writes/edits src/index.ts & src/index.test.ts.
2. Local build: tsc compiles to dist/, jest runs tests, eslint/prettier validate style.
3. Push to GitHub: triggers CI workflow (runs the same build/test/lint steps).
4. When a Changeset version is merged and CI passes, the package is published to NPM.
5. Consumer apps install via npm install tinyduration and invoke parse()/serialize() at runtime.
c. Architectural patterns/design principles
• Single-responsibility: only two exported functions.
• Pure functions with no side effects.
• Zero runtime dependencies for minimal bundle size.
• Test-driven, with 100% coverage enforced by CI.
• Automated semantic versioning & changelog via Changesets.
d. Key technologies/frameworks
• TypeScript (source) → JavaScript (dist)
• Jest (unit testing)
• ESLint + Prettier (code quality)
• GitHub Actions (CI)
• Changesets (versioning & changelog)
• NPM (package distribution)