A small loader fetches delivery status by tracking code, validates the source response, and caches successful results. After a recent refactor, the module started behaving unstably on repeated calls and source failures.
loadDeliveryStatus(trackingCode, fetcher) accepts a tracking code and an async fetcher.trackingCode or one containing only spaces must raise Tracking code is required before calling fetcher.code — a string matching the normalized code;state — one of the strings: queued, in_transit, delivered;checkpoints — an array of objects, where each element has a non-empty string label.Invalid delivery payload.fetcher fails, the function must not mask the failure with a successful result from cache.src/deliveryStatus.ts." ab-12 " and "AB-12".fetcher.checkpoints with an empty label.Example test run:
node --import tsx src/demo.ts
payload must not be accepted as a successful result and must not be cached.22.x5.8ES modulesstrict=truetsx 4.19.2 is required to run the examplesrc/demo.tsUse line comments to explain the problem, its impact, the fix and how to test it.