Last 12 weeks ยท 10 commits
4 of 6 standards met
Bug and both validate that the provided value is an array at construction time, throwing a descriptive error immediately. was missing this same guard. Passing a non-array (e.g. a single status code number) silently passes through and only fails later inside as a confusing: This error appears during a retry attempt โ well after construction โ making it hard to diagnose. Fix Add the missing validation to so all three array options are consistent: Verification Result: 1 test passed (new test). Full : 85 tests passed, 0 failed. AI-assisted contribution.
Problem accepts a number as shorthand for (per the docs: "If is a number, it will be used as and other defaults will remain in place."). However, when a numeric is set on a parent instance and then extended with an object, the numeric limit is silently dropped and falls back to the default (): The reverse direction (object on the parent, number on the child) and the all-object case both work correctly โ only the number โ object merge loses data. Cause In , is merged like any other nested object. When the parent value is the numeric shorthand () and the incoming value is an object, the recursion ends up as . A non-object source is skipped entirely by , so the is discarded and only survives โ the limit is lost. Fix Expand the numeric shorthand to before the deep merge, so extending it with an object preserves the limit. This mirrors the documented shorthand semantics and leaves every other case (object โ object, object โ number replacement, ) unchanged. Test Added a test in that sets on a parent, extends it with , and asserts the request is attempted times. It fails on (3 attempts) and passes with the fix (4 attempts).
deep-clones (#861) and so init-hook mutations don't leak across requests, but and are still only shallow-cloned (one level). A nested mutation in a hook (e.g. on a reused ) leaks into subsequent requests. Existing tests only cover top-level mutation, so it's undetected. #861 established the deep-clone-nested-init-hook-structures pattern for ; / were left behind. The fix applies the same isolation (+2 tests). Verified both ways: old leaks the nested mutation, fix isolates it; top-level, Date, and class-instance cases preserved, 0 regression.
The retry documentation describes the header value as a "date, timeout, or timestamp". "timeout" isn't one of the accepted forms. Per the HTTP spec the value is either a delay in seconds or an HTTP date, and ky additionally treats a large number as a Unix timestamp (). So the accurate set is delay / date / timestamp. This replaces the inaccurate "timeout" with "delay" in the readme and the matching JSDoc in . Docs-only, no behavior change.
๐ Bartek from the Deno team here. The install instructions show , but not Deno. Since Deno is a drop-in replacement for npm these days, I'd like to add a Deno line so Deno users have a copy-pasteable command, in parity with the others: (As of Deno 2.8 there's no prefix needed, it's the same command shape as .) Totally fine to close this if you'd rather keep the list short, no hard feelings. Happy to adjust wording, placement, or move it to a docs site instead. _Disclosure: I work on Deno, so I have an interest here. The goal is parity with the package managers you already list, not promotion. This PR was prepared with AI assistance under human supervision: I review every change myself and personally respond to any comments or review feedback._
Repository: sindresorhus/ky. Description: ๐ณ Tiny & elegant JavaScript HTTP client based on the Fetch API Stars: 16966, Forks: 476. Primary language: TypeScript. Languages: TypeScript (100%). License: MIT. Topics: fetch, http-client, http-request, javascript, js, json, npm-package, request, rest, tiny, whatwg-fetch. Latest release: v2.0.2 (2mo ago). Open PRs: 2, open issues: 0. Last activity: 1w ago. Community health: 85%. Top contributors: sindresorhus, sholladay, szmarczak, whitecrownclown, clicktodev, mgcrea, jabuj, poppinlp, joaovieira, cristobal and others.