cp-fetch is a lightweight wrapper around the Fetch API that returns cancelable CPromise objects (from c-promise2) instead of native Promises, enabling automatic abort of network requests when the promise is cancelled, rejected, or resolved in a race/all pattern. Version 0.3.2 (stable) works in both browser and Node.js via cross-fetch ponyfill, supporting timeouts, cancellation, and concurrent request management (e.g., auto-abort other requests in CPromise.race/all on failure). It differentiates from axios and wretch by deeply integrating cancellation into the promise chain, not just the fetch signal. Released under MIT license, with low maintenance frequency (last update 2021).
npm install cp-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates cancelable fetch with timeout using cp-fetch and CPromise, aborting the request after 1 second.
Always use CPromise concurrency methods (CPromise.all, CPromise.race) for auto-abort; avoid mixing with native Promise.all.
For Node.js <18 or older browsers, use default import (includes cross-fetch). For modern environments, use native import to avoid polyfill overhead.
Use CPromise.finally or check cancellation with 'chain.promiseIsCancelled' property to handle cancellation cleanup.
Use default import (require('cp-fetch')) which includes cross-fetch polyfill, or install a fetch polyfill (e.g., node-fetch) and assign to globalThis.Run: npm install c-promise2
Use require('cp-fetch') or configure your bundler (e.g., webpack) to handle CommonJS modules.