{"_id":"undici-fetch","_rev":"12-406994c2b0a38ba6606158cbc21978cd","name":"undici-fetch","dist-tags":{"latest":"1.0.0-rc.4"},"versions":{"0.1.0":{"name":"undici-fetch","version":"0.1.0","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint":"standard --verbose","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^3.0.0"},"devDependencies":{"minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.4","standard":"^16.0.3","tap":"^14.11.0"},"gitHead":"4e370404b80170e668d74a992e1aca59a9112e74","_id":"undici-fetch@0.1.0","_nodeVersion":"15.5.0","_npmVersion":"7.3.0","dist":{"integrity":"sha512-tjJZgJ3dVCfKzDxWC1KyBzTEsil0U0YnF+cG/Nf3nP5FzvYemLYbxPV+D7YfQqOmBjC5kFzOUbIJETCfXlqDkA==","shasum":"2918676b4b4ea57ab0b09fe89335dd6d7516d7c8","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-0.1.0.tgz","fileCount":22,"unpackedSize":58568,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+ebUCRA9TVsSAnZWagAAmKMP+gN81U4kc1XnaFazs4Fx\nejiWBGOzib9aw5pwct1Nf4S/TtWlKFkAbOoXKXauqReaxODxFsQwuehacssE\nCt2DThHGnZgLOOpAtH0koRvahc/TiZexc+rQOOr0DTz0IbhPQ+iKsObs6M5h\nHdueoGETXmxXU1DOVvMfy1hE6AZJqKdM2Um8FzxqGHXAgDxISfDQ0E81mXdf\n7+mBVJmPlNIZmdfvu9mjD8NVHAAtKTnL/zAzZixDv7hpdZt+gwWCb1cwOML1\nW7Nqda5uZAxlxsRAYrpbtC5Wwc2Sq+Yu5WwgNTokpJqxfHZHm03Vac12h2vA\nrRAfocPRYcn6vhiz/+FVngKqcyap6xGJt+Mo/tPFBeTltjV/7cEaqkDJ57/r\nYcVHtoWbWCA5WjPEy0krA2tjS5oj2LIAFBcW286Vo0gXh/bvH53rrGeYvlhD\n14VZuhHD1sp14VGVwdr6oakEYTJKNMqNR4/uNUEzYiVW0gj2cDDq3KJdSRgc\niTDqNMBkUg5Sv9RW9t+FoGd8dbEjHKZQhhAX1/yHYKSyqXEjth2z9ST6PTwG\n01e3YczgWZ/3dOMTtPbjuUfoAzvUDcJmOIVjOLSb5J8Rpg4zCfLD/CbA5mjZ\neFIzd/bCmHdUPok0zkcdfBO2HHzu9rH9R0x7KSYbroPKgPBfJQ7s3M+2nkKE\nfhvQ\r\n=F0tE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDzLDV3qzoHoum5DcQAcesw5nx23jE6bx8fGg31p2EXyAiEAqqQvhuMBf/AjERTdN36RtGgDNcD8RNvJC4EYB7+aaE0="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_0.1.0_1610213076410_0.7256154339485459"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"0.1.1":{"name":"undici-fetch","version":"0.1.1","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint":"standard --verbose","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^3.0.0"},"devDependencies":{"minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.4","standard":"^16.0.3","tap":"^14.11.0"},"readme":"# undici-fetch\n\n```sh\nnpm i undici-fetch\n```\n\nBuilt on [Undici](https://github.com/nodejs/undici)\n\n## Table of Contents\n\n- [undici-fetch](#undici-fetch)\n\t- [Table of Contents](#table-of-contents)\n- [Benchmarks](#benchmarks)\n- [API](#api)\n\t- [Default Method: `fetch(resource, [init])`](#default-method-fetchresource-init)\n\t- [Method: `buildFetch()`](#method-buildfetch)\n\t- [Class: Headers](#class-headers)\n\t\t- [`new Headers([init])`](#new-headersinit)\n\t\t- [Instance Methods](#instance-methods)\n\t\t\t- [`Headers.append(name, value)`](#headersappendname-value)\n\t\t\t- [`Headers.delete(name)`](#headersdeletename)\n\t\t\t- [`Headers.get(name)`](#headersgetname)\n\t\t\t- [`Headers.has(name)`](#headershasname)\n\t\t\t- [`Headers.set(name, value)`](#headerssetname-value)\n\t\t\t- [`Headers.values()`](#headersvalues)\n\t\t\t- [`Headers.keys()`](#headerskeys)\n\t\t\t- [`Headers.forEach(callback, [thisArg])`](#headersforeachcallback-thisarg)\n\t\t\t- [`Headers[Symbol.iterator]`](#headerssymboliterator)\n\t\t\t- [`Headers.entries()`](#headersentries)\n\t- [Class: Body](#class-body)\n\t\t- [`new Body([input])`](#new-bodyinput)\n\t\t- [Instance Properties](#instance-properties)\n\t\t\t- [`Body.body`](#bodybody)\n\t\t\t- [`Body.bodyUsed`](#bodybodyused)\n\t\t- [Instance Methods](#instance-methods-1)\n\t\t\t- [`Body.arrayBuffer()`](#bodyarraybuffer)\n\t\t\t- [`Body.blob()`](#bodyblob)\n\t\t\t- [`Body.formData()`](#bodyformdata)\n\t\t\t- [`Body.json()`](#bodyjson)\n\t\t\t- [`Body.text()`](#bodytext)\n\t- [Class: Request](#class-request)\n\t\t- [`new Request(input, [init])`](#new-requestinput-init)\n\t\t- [Instance Properties:](#instance-properties-1)\n\t\t\t- [`Request.url`](#requesturl)\n\t\t\t- [`Request.method`](#requestmethod)\n\t\t\t- [`Request.headers`](#requestheaders)\n\t\t- [Instance Methods:](#instance-methods-2)\n\t\t\t- [`Request.clone()`](#requestclone)\n\t- [Class: Response](#class-response)\n\t\t- [`new Response(body, [init])`](#new-responsebody-init)\n\t\t- [Instance Properties](#instance-properties-2)\n\t\t\t- [`Response.headers`](#responseheaders)\n\t\t\t- [`Response.ok`](#responseok)\n\t\t\t- [`Response.status`](#responsestatus)\n\t\t\t- [`Response.statusText`](#responsestatustext)\n\t\t\t- [`Response.type`](#responsetype)\n\t\t- [Instance Methods](#instance-methods-3)\n\t\t\t- [`Response.clone()`](#responseclone)\n\t\t- [Static Methods](#static-methods)\n\t\t\t- [`Response.error()`](#responseerror)\n\t\t\t- [`Response.redirect(url, status)`](#responseredirecturl-status)\n- [TypeScript](#typescript)\n- [Spec Omissions](#spec-omissions)\n\n# Benchmarks\n\n`npm run benchmarks`\n\nOn my personal machine:\n\n```\nMacBook Pro (15-inch, 2018)\nProcessor 2.9 GHz 6-Core Intel Core i9\nMemory 32 GB 2400 MHz DDR4\n```\n\nResults:\n\n```\n{\n  undici: { startTime: 72530288319510n, endTime: 72544207363031n },\n  node: { startTime: 72530283341532n, endTime: 72575809241450n },\n  minipass: { startTime: 72530290384674n, endTime: 72576867597178n }\n}\nResults for 10000 subsequent requests: \nundici-fetch | total time: 13919043521ns (13919.044ms)\nnode-fetch | total time: 45525899918ns (45525.900ms)\nminipass-fetch | total time: 46577212504ns (46577.213ms)\n---\nundici-fetch <> node-fetch percent change: -69.426%\nundici-fetch <> minipass-fetch percent change: -70.116%\n```\n\n# API\n\nThe default export for this module is a fetch client instance [`fetch`](). It uses the default `Undici.Pool()` options.\n\nIn order to pass options to the underlying Pool instance, use the named export [`buildFetch`]() method. The fetch instance returned by this method should be used throughout a project. Behind the scenes, `undici-fetch` reuses the pool instances for similar url origins. The pools are memoized in a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) that is initialized in the `buildFetch` closure.\n\n**Notice:** You must call `fetch.close()` at the end of your project in order to safely close all of the Undici request pools. This step is will be removed before v1 release when an auto-close feature is added (https://github.com/nodejs/undici/pull/508).\n\n```js\nconst fetch = require('undici-fetch')\n\nasync function run() {\n\tconst res = await fetch('https://example.com')\n\tconst json = await res.json()\n\n\tconsole.log(json)\n\n\tawait fetch.close()\n}\n\nrun()\n```\n\n> All mentions of `stream.Readable` or `Readable` in this documentation is referring to the Node.js Stream API [Readable Class](https://nodejs.org/api/stream.html#stream_class_stream_readable)\n\nKeep in mind that many of these classes were designed to be directly integrated with Undici and thus may not offer the best stand-alone dev experience. They follow the fetch spec as close as possible and should not deviate from that spec API.\n\n## Default Method: `fetch(resource, [init])`\n\n* **resource** `string | Request`\n* **init** `object` (optional)\n  * **method** `string` (optional) - Defaults to `'GET'`\n  * **headers** `Headers | HeadersInit` (optional)\n  * **body** `Readable | null` (optional)\n\nReturns: `Promise<Response>`\n\n```js\n// import and initialize all-at-once\nconst fetch = require('undici-fetch')()\n\n// Promise Chain\nfetch('https://example.com')\n\t.then(res => res.json())\n\t.then(json => console.log(json))\n\n// Async/Await\nconst res = await fetch('https://example.com')\nconst json = await res.json()\n```\n\n## Method: `buildFetch()`\n\nReturns: [fetch](#default-method-fetchresource-init)\n\n```js\nconst { buildFetch } = require('undici-fetch')\nconst fetch = buildFetch({ /* Undici.Pool options */ })\n```\n\n## Class: Headers\n\nRepresents a WHATWG Fetch Spec [Headers Class](https://fetch.spec.whatwg.org/#headers-class)\n\n### `new Headers([init])`\n\n* **init** `Iterable<[string, string]> | Record<string, string>` (optional) - Initial header list to be cloned into the new instance\n\n```js\nnew Headers()\n\nnew Headers([\n\t[\"undici\", \"fetch\"]\n])\n\nconst headers = new Headers({\n\t\"undici\": \"fetch\"\n})\n\nnew Headers(headers)\n```\n\n### Instance Methods\n\n#### `Headers.append(name, value)`\n\n* **name** `string`\n* **value** `string`\n\nReturns: `void`\n\nNon-destructive operation for adding header entries. When called multiple times with the same _name_, the values will be collected in a list and returned together when retrieved using [Headers.get](#headersgetname).\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.get('undici') // -> 'fetch'\n\nheaders.append('foobar', 'fuzz')\nheaders.append('foobar', 'buzz')\nheaders.get('foobar') // -> 'fuzz, buzz'\n```\n\n#### `Headers.delete(name)`\n\n* **name** `string`\n\nReturns: `void`\n\nRemoves a header entry. This operation is destructive and cannot be restored. Does **not** throw an error if the given _name_ does not exist. Reminder that [Headers.get](#headersgetname) will return `null` if the _name_ does not exist.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\n\nheaders.get('undici') // -> 'fetch'\n\nheaders.delete('undici')\n\nheaders.get('undici') // -> null\n```\n\n#### `Headers.get(name)`\n\n* **name** `string`\n\nReturns: `string | null`\n\nRetrieves a header entry. If the entry _name_ has multiple values, they are returned as a string joined by `','` characters. If the _name_ does not exist, this method returns null.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.get('undici') // -> 'fetch'\n\nheaders.append('foobar', 'fuzz')\nheaders.append('foobar', 'buzz')\nheaders.get('foobar') // -> 'fuzz, buzz'\n\nheaders.get('nodejs') // -> null\n```\n\n#### `Headers.has(name)`\n\n* **name** `string`\n\nReturns `boolean`\n\nChecks for the existence of a given entry _name_.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.has('undici') // -> true\n```\n\n#### `Headers.set(name, value)`\n\n* **name** `string`\n* **value** `string`\n\nReturns: `void`\n\nDestructive operation that will override any existing values for the given entry _name_. For a non-destructive alternative see [Headers.append](#headersappendname-value).\n\n```js\nconst headers = new Headers()\n\nheaders.set('foobar', 'fuzz')\nheaders.get('foobar') // -> 'fuzz'\n\nheaders.set('foobar', 'buzz')\nheaders.get('foobar') // -> 'buzz'\n```\n\n#### `Headers.values()`\n\nReturns: `IteratableIterator<string>`\n\nEach iteration of the headers `values()` iterator yields a header _value_\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const value of headers.values()) {\n\tconsole.log(value)\n}\n\n// -> '123'\n// -> '456'\n// -> '789, 012'\n```\n\n#### `Headers.keys()`\n\nReturns: `IteratableIterator<string>`\n\nEach iteration of the headers `keys()` iterator yields a header _name_\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const name of headers.keys()) {\n\tconsole.log(name)\n}\n\n// -> 'abc'\n// -> 'def'\n// -> 'ghi'\n```\n#### `Headers.forEach(callback, [thisArg])`\n\n* **callback** `(value: string, key: string, iterable: Headers) => void`\n* **thisArg** `any` (optional)\n\nReturns: `void`\n\nA Headers class can be iterated using `.forEach(callback, [thisArg])`\n\nOptionally a `thisArg` can be passed which will be assigned to the `this` context of callback\n\n```js\nconst headers = new Headers([['abc', '123']])\n\nheaders.forEach(function (value, key, headers) {\n\tconsole.log(key, value)\n})\n// -> 'abc', '123'\n```\n\n#### `Headers[Symbol.iterator]`\n\nReturns: `Iterator<[string, string]>`\n\nA Headers class instance is iterable. It yields each of its entries as a pair where the first value is the entry _name_ and the second value is the header _value_.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const [name, value] of headers) {\n\tconsole.log(name, value)\n}\n\n// -> 'abc', '123'\n// -> 'def', '456'\n// -> 'ghi', '789, 012'\n```\n#### `Headers.entries()`\n\nReturns: `IteratableIterator<[string, string]>`\n\nEach iteration of the headers `entries()` iterator yields the same entry result as the default iterator\n\n## Class: Body\n\nRepresents a WHATWG Fetch Spec [Body Mixin](https://fetch.spec.whatwg.org/#body-mixin)\n\n### `new Body([input])`\n\n* **input** `Readable | null | undefined` (optional) - Defaults to `null`\n\nThis class is the core for the [Request](#class-request) and [Response](#class-response) classes. Since this class is only ever going to recieve response data from Undici requests, it only supports Readable streams.\n\n```js\nnew Body()\nnew Body(undefined)\nnew Body(null)\nnew Body(Readable.from('undici-fetch', { objectMode: false }))\n```\n\n### Instance Properties\n\n#### `Body.body`\n\n* `Readable | null`\n\nA property representing the payload of the Body instance\n\n#### `Body.bodyUsed`\n\n* `boolean`\n\nA property representing the consumption state of the Body instance. Do not confuse this property with the Node.js [stream](https://nodejs.org/api/stream.html#stream_three_states) state of `Body.body`. This property is used by the other instance methods for indicating to other parts of the API if the body has been consumed or not.\n\n### Instance Methods\n\n#### `Body.arrayBuffer()`\n\nReturns: `Promise<Buffer>`\n\nReturns the `Body.body` content as a Node.js [Buffer](https://nodejs.org/api/buffer.html#buffer_class_buffer) instance.\n\n```js\nconst body = new Body(Readable.from('undici-fetch', { objectMode: false }))\n\nconst buf = await body.arrayBuffer()\nconsole.log(buf instanceof Buffer) // -> true\nconsole.log(buf.toString('utf8')) // -> 'undici-fetch'\n```\n\n#### `Body.blob()`\n\nReturns: `never`\n\nCurrently, this implementation does not support returning content as a blob. Calling this method will throw an error. This may change in future API updates.\n\n```js\nconst body = new Body(new Readable())\n\ntry {\n\tawait body.blob()\n} catch (err) {\n\tconsole.log(err.message) // -> 'Body.blob() is not supported yet by undici-fetch'\n}\n```\n\n#### `Body.formData()`\n\nReturns: `never`\n\nCurrently, this implementation does not support returning content as a blob. Calling this method will throw an error. This may change in future API updates.\n\n```js\nconst body = new Body(new Readable())\n\ntry {\n\tawait body.formData()\n} catch (err) {\n\tconsole.log(err.message) // -> 'Body.formData() is not supported yet by undici-fetch'\n}\n```\n\n#### `Body.json()`\n\nReturns: `Promise<any>`\n\nReturns the `Body.body` content as a JSON object.\n\n```js\nconst content = JSON.stringify({ undici: 'fetch' })\nconst body = new Body(Readable.from(content, { objectMode: false }))\n\nconst res = await body.json()\n\nconsole.log(res) // -> { undici: 'fetch' }\n```\n\n#### `Body.text()`\n\nReturns: `Promise<string>`\n\nReturns the `Body.body` content as a UTF-8 string.\n\n```js\nconst body = new Body(Readable.from('undici-fetch', { objectMode: false }))\n\nconst res = await body.text()\n\nconsole.log(res) // -> 'undici-fetch'\n```\n\n## Class: Request\n\nExtends: `Body`\n\nRepresents a WHATWG Fetch Spec [Request Class](https://fetch.spec.whatwg.org/#request-class)\n\n### `new Request(input, [init])`\n* **input** `Request | string`\n* **init** `object` (optional)\n  * **method** `string` (optional) - Defaults to `'GET'`\n  * **headers** `Headers | HeadersInit` (optional)\n  * **body** `Readable | null | undefined` (optional)\n\nCreates a new `Request` object. The resulting instance can be passed directly to the [fetch](#method-fetchresource-init) method. The input string will be transformed into a Node.js [URL](https://nodejs.org/api/url.html#url_class_url) instance.\n\n```js\nconst request = new Request('https://example.com', {\n\tmethod: 'POST',\n\tbody: Readable.from('undici-fetch', { objectMode: false })\n})\n\nconst res = await fetch(request)\n```\n\n### Instance Properties:\n\n#### `Request.url`\n\n* `URL`\n\nA Node.js [URL Class](https://nodejs.org/api/url.html#url_class_url) instance representing the destination of the Request instance\n\n#### `Request.method`\n\n* `string`\n\nA property representing the type of the Request instance. Will be normalized to uppercase format and validated as one of [`http.METHODS`](https://nodejs.org/api/http.html#http_http_methods).\n\n#### `Request.headers`\n\n* `Headers`\n\nA [Headers](#class-headers) class instance representing the Headers instance for the request instance.\n\n### Instance Methods:\n\n#### `Request.clone()`\n\nReturns: `Request`\n\nWill throw an `Error` if the current instance `Responce.bodyUsed` is `true`. Returns a new Request instance based on the existing instance.\n\n```js\nconst request = new Request('https://example.com')\n\nconst newRequest = request.clone()\n\nconsole.log(newRequest.url) // => 'https://example.com'\n```\n\n## Class: Response\n\nExtends: `Body`\n\nRepresents a WHATWG Fetch Spec [Response Class](https://fetch.spec.whatwg.org/#response-class)\n\n### `new Response(body, [init])`\n\n* **body** `Readable | null | undefined`\n* **init** `object` (optional)\n  * **status** `number` (optional) - Defaults to `200`\n  * **statusText** `string` (optional) - Defaults to `''`\n  * **headers** `Headers | HeadersInit` (optional)\n\nCreates a new `Response` object. This is the result resolved from a successful `fetch()` call. Remember that this class extends from [Body](#class-body) so you can use methods such as `.text()` and `.json()`.\n\n```js\nconst response = new Response(Readable.from('undici-fetch', { objectMode: false }))\n\nif (response.ok) {\n\tconst text = await response.text()\n\n\tconsole.log(text) // -> 'undici-fetch'\n}\n```\n\n### Instance Properties\n\n#### `Response.headers`\n\n* `Headers`\n\nA property representing a [Headers](#class-headers) instance for the response.\n\n#### `Response.ok`\n\n* `boolean`\n\nA property representing if the response is _ok_. A Response is considered _ok_ if the `status` is between 200 and 299 inclusive.\n\n#### `Response.status`\n\n* `number`\n\nA property representing the status code of the response.\n\n#### `Response.statusText`\n\n* `string`\n\nA property representing the status of the response instance based on [`http.STATUS_CODES`](https://nodejs.org/api/http.html#http_http_status_codes).\n\n#### `Response.type`\n\n* `string`\n\nDefaults to `'default'`. A property representing the type of response instance. Currently only used to indicate an error response from [`Response.error()`](#responseerror).\n\n### Instance Methods\n\n#### `Response.clone()`\n\nReturns: `Response`\n\nWill throw an `Error` if the current instance `Responce.bodyUsed` is `true`.\n\n### Static Methods\n\n#### `Response.error()`\n\nReturns: `Response`\n\nGenerates a Response instance with `type` set to `'error'` and a `body` set to `null`.\n\n```js\nconst errorResponse = Response.error()\n```\n\n#### `Response.redirect(url, status)`\n\n* **url** `string` - The redirect location--will be assigned to a `'location'` header\n* **status** `number` - Must be one of: 301, 302, 303, 307, or 308\n\nReturns: `Response`\n\n```js\nconst redirectResponse = Response.redirect('https://example.com', 301)\n```\n\n---\n\n# TypeScript\n\nSimilar to Undici, this module ships with its own TypeScript definitions. Make sure to install `@types/node` as well.\n\n# Spec Omissions\n\nFetch is a browser API, but this library is written in Node.js. We try to be as spec compliant as possible; however, some aspects just cannot be recreated on the server. **All Fetch WHATWG Spec omissions are detailed here**. Each part should have a summary of the omission, plus links to relevant spec section and additional documentation.\n\nEntries in this section have been considered for the implementation and explicitly ommitted. If you do not find an aspect of the Fetch API listed here that is **also** missing from the implementation, open an issue describing the feature request.\n","readmeFilename":"README.md","gitHead":"1b42dadc84d51b3a91f194c1be5e94d2715f3a63","_id":"undici-fetch@0.1.1","_nodeVersion":"14.15.4","_npmVersion":"6.14.10","dist":{"integrity":"sha512-MY5Eaowi9TQSXzM4r4MvI9kmYNOV/uGbmlKCp6/vy9uaKwgJLNoF3jkoiGCVvugI1CCd+3QTZr5p75Gjv5sG7Q==","shasum":"6f62211a92447f1f2963a1eb77e99fa2fa36f568","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-0.1.1.tgz","fileCount":22,"unpackedSize":62221,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/Hv+CRA9TVsSAnZWagAAc0MQAJiJX3awAGHbY/mWr+mp\nDscbk6D92c9RKCVwh/UnB64JWj+5uDX0Pdp9NP5dW/2o6YUlg/Onjz57kaJ8\nSHj63kMjvO+gy1iXOsLeAmyb8WR69HXItxWCzc6PPl4BptSXpethlwdwTofw\n3/t8YmIWaKUZI0nNarcW4E19z6DfSa0vnw680m33RcN2UdG03ISPNn7dKKvY\n+Pj2WZweMn6FroXHEKo0dE38VvA8BgStA94nWQ5AuRPKZglIRj3cVCmGNscD\nAoJsxy2/HY30usDdPC/4zZSt2CHwCRYv7f2y0HF/gR+WFMo4eZRHDuDu5eTy\nyyHtD7OAce0uGMHAcpGuHCSuNiGYD+WzSd+v47bL/QHzg/iAAh8By0AFwH2l\nhm67qK9/E6qdqiyj1lT/pl9Fe5DrAa6wkrKa8kvw29QaU6f3DoUBEgDgvz3T\nHX5BjhrGqEUJGgRghuEaBHb8Nsk2YvrxLTG0zDBkFsJcqq5wQAgIL2KpA+C7\n1x2OViTAf04RUQsgftkl+9OXm36el3vlYsR8FI7h6TjN3qoNiPDmcWz4dKrp\nofw4NvRRyGzCwr64DTUGPgW/QolRXsHaHniTZB0oZUHUIsbQF/GSyMsTXVcP\n2w36Vyb3pe+nOa3Vc7zDGytr2N96wPQ+zioVKDG3YBnIX2N0Y5DlqjwvpQNu\n2a4x\r\n=neA5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG4z9ok1BLexGSl/XUyBrvE9qYEWuvLW6GHtcE6ByqsMAiEAumx42qWRektu3I6+lLn/YpuLaiR7VfybtTwMrEkDY4s="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_0.1.1_1610382334253_0.20419863724828446"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"0.1.2":{"name":"undici-fetch","version":"0.1.2","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint":"standard --verbose","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^3.0.0"},"devDependencies":{"minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.4","standard":"^16.0.3","tap":"^14.11.0"},"gitHead":"6247bf22c1b1c33fa9d69fcea4b94eb20e749992","_id":"undici-fetch@0.1.2","_nodeVersion":"15.8.0","_npmVersion":"7.5.1","dist":{"integrity":"sha512-eSzCiA2gvD1gUiTTEIpWpd/Z8TC65K+3I6l0CM28qJu8xaMNjbpETov/4FatSdE52Clos5u++O9l7J+EbPKIMQ==","shasum":"be62e27060534000ea0b088266b85bd0472a1ce0","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-0.1.2.tgz","fileCount":22,"unpackedSize":63292,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgZhhnCRA9TVsSAnZWagAA+DYP/3hWC9uNhMroOL0T7UoR\n7m1+XrCWo4YqF4U7JAghy/TcJK/F8wy9YYg74wd7Mnc8pXWG4b/7Klm3tBnZ\nx2PpeYP9Wij/VrMb7TCTmjFduh3SBzdNW+FrJe0+sD3iR8YIyBXWFtLPvb9W\nFvXYIBYY4kvz8p0xrvOX6+R+DBimPRqFM6iXpZ2bxOjfFQlrqx61QCKH6ndO\n6UhmQ7uB9hvSDNGJovunOmyL5qiOB4M0HUNZPeSvAPlQqiPzZI7Ol411QuZA\nLQaVEBY4sou1MnH0hGod41FLu83qhdhUMLNcNmrE5QBlJdWdwtN4y3uSINhX\nSfVrYocRGp5TrUsgVqeupjOAbKrJRgcmWvOSF2cbvZaxM/GHRpxs0himlpmQ\nfMBK+oTyGAtUDBbNWayNumawaERY5jSxKkPx1ooRpSvNzGNRtgQL9su/+CQg\nf6qCCcBDiipCAZiPjLnAEL+2oANZ4P3YHrZepmRZLvzOrOOmBHXHuAY63tdF\nTnZ6/WJUDUwAIxQH15ovUX9q6woZtsuZkwWX0/b19CciJNAwtYunE/CeFWtM\nwCObY5Rvd6rb9ClHqm/f8drcD8TeVBlWv/XbGZlBOXEeiMj119b0SdSijdap\nt0ajjflWiZ7sw9t140eZtKo1jpDZeOjqfKhRC1cGAQOuET0u0dnww1K2EZrz\nDFLO\r\n=azOA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICf1P/t91YK6elEE5jeNmy7Nsn6al8YU+krNdd5lIFOMAiEA4EllW4sYQ9fHP2EF9L3FrCvMWU4GEIljPY/2jE5XOGQ="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_0.1.2_1617303655317_0.7753729469850206"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"0.2.0":{"name":"undici-fetch","version":"0.2.0","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint":"standard --verbose","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^3.0.0"},"devDependencies":{"minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.4","standard":"^16.0.3","tap":"^14.11.0"},"gitHead":"6e5b530fc7b21c599587ed972083500cc985106e","_id":"undici-fetch@0.2.0","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-7yVO/OhUgDmliJ4pJBU/VKbIA8BnQFR4Q604zwbs1/g2KiBavv6pKRkVGWaObjqq8uJHPnDDX/F7Nh/tkjnZcw==","shasum":"956c0133398dfc577ad5861f992d1db2230c672d","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-0.2.0.tgz","fileCount":22,"unpackedSize":63520,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgZ4F5CRA9TVsSAnZWagAAE/MQAJPnov1yq6sgh33tNu0J\n/5C7Oj26EAzjvV0aVwb9/Ho0uWBqkbpn3lWh6cMiQirYprCO5toGOzw/8BVa\nAXGO7SylnNfU7Ci3zmyXWNZ05ViDo4dsdVAiGUU7rSgXenHnppaoXNeu36vh\nJ0Am/NUaMEnoxSVtLBaX6lh3w3ZHjKHf/NKLN0qOf6KJTgoqHWdzq+bn88mT\nypMKc51Bl/VolL8IErwET+uFH351TowMYAK8Xd22qYrqNL9xIfiNO/xQQ/XX\nvCJ1dm2IrpmuTkCFMUfTB51FUd0ks7ziY+8i+RIo1OR545aYU/Kxh2H++R2q\n46FidDzwfJI1jb8ga809dmMFyrdNf0GQ0CNgRYG0ne6Zrscb/lj8o4rBAj1i\n+DOnAMTm1dAzkgKMZ7qozman86SMkgMsFh0Sce5PnrD1S9avycCVynC36LRn\nn82GJSERR8Q/y87fNHBBnYsp5O3Ci5r4Pa6UKT430Tkx51opkAHiMcyjBmJE\nZRM3gN1f01Fh37hV19+tPjPU4/F5u6tWzl/pB6BHgU0r0uqgL/MTTfzwqGaU\nAVAYWANQIu1J/o1AY1WENjCprg0grqsuvn+hJ1cKQk7BA+AYkkVjbJlq8Jc5\nihQDaBybmQ3dW1tNRP2nVVqTvQkH4tVgiOnnZuRO3MWn6+dOH8NYQzSnAx5y\n9sNB\r\n=w1J0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCu9esDx0bPkgw67DLaAOQKHf+SUKkwjgejUM0+gkcp6QIhAOm9/v3VXx68HxFF/+N2V74F9GmIF6liZLjuy2bTiNbE"}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_0.2.0_1617396088565_0.609065439824277"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"0.3.0":{"name":"undici-fetch","version":"0.3.0","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint:js":"standard --verbose","lint:ts":"ts-standard --verbose","lint":"npm run lint:js && npm run lint:ts","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^3.0.0"},"devDependencies":{"@types/node":"^14.14.37","minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.4","standard":"^16.0.3","tap":"^14.11.0","ts-standard":"^10.0.0"},"readme":"# undici-fetch\n\n⚠️ This module is currently in beta. It is **not** spec compliant yet. v1 will be released when this can be a drop-in replacement for other Node.js fetch implementations.\n\n```sh\nnpm i undici-fetch@beta\n```\n\nBuilt on [Undici](https://github.com/nodejs/undici)\n\n## Table of Contents\n\n- [undici-fetch](#undici-fetch)\n\t- [Table of Contents](#table-of-contents)\n- [Benchmarks](#benchmarks)\n- [API](#api)\n\t- [Default Method: `fetch(resource, [init])`](#default-method-fetchresource-init)\n\t- [Method: `buildFetch()`](#method-buildfetch)\n\t- [Class: Headers](#class-headers)\n\t\t- [`new Headers([init])`](#new-headersinit)\n\t\t- [Instance Methods](#instance-methods)\n\t\t\t- [`Headers.append(name, value)`](#headersappendname-value)\n\t\t\t- [`Headers.delete(name)`](#headersdeletename)\n\t\t\t- [`Headers.get(name)`](#headersgetname)\n\t\t\t- [`Headers.has(name)`](#headershasname)\n\t\t\t- [`Headers.set(name, value)`](#headerssetname-value)\n\t\t\t- [`Headers.values()`](#headersvalues)\n\t\t\t- [`Headers.keys()`](#headerskeys)\n\t\t\t- [`Headers.forEach(callback, [thisArg])`](#headersforeachcallback-thisarg)\n\t\t\t- [`Headers[Symbol.iterator]`](#headerssymboliterator)\n\t\t\t- [`Headers.entries()`](#headersentries)\n\t- [Class: Body](#class-body)\n\t\t- [`new Body([input])`](#new-bodyinput)\n\t\t- [Instance Properties](#instance-properties)\n\t\t\t- [`Body.body`](#bodybody)\n\t\t\t- [`Body.bodyUsed`](#bodybodyused)\n\t\t- [Instance Methods](#instance-methods-1)\n\t\t\t- [`Body.arrayBuffer()`](#bodyarraybuffer)\n\t\t\t- [`Body.blob()`](#bodyblob)\n\t\t\t- [`Body.formData()`](#bodyformdata)\n\t\t\t- [`Body.json()`](#bodyjson)\n\t\t\t- [`Body.text()`](#bodytext)\n\t- [Class: Request](#class-request)\n\t\t- [`new Request(input, [init])`](#new-requestinput-init)\n\t\t- [Instance Properties:](#instance-properties-1)\n\t\t\t- [`Request.url`](#requesturl)\n\t\t\t- [`Request.method`](#requestmethod)\n\t\t\t- [`Request.headers`](#requestheaders)\n\t\t- [Instance Methods:](#instance-methods-2)\n\t\t\t- [`Request.clone()`](#requestclone)\n\t- [Class: Response](#class-response)\n\t\t- [`new Response(body, [init])`](#new-responsebody-init)\n\t\t- [Instance Properties](#instance-properties-2)\n\t\t\t- [`Response.headers`](#responseheaders)\n\t\t\t- [`Response.ok`](#responseok)\n\t\t\t- [`Response.status`](#responsestatus)\n\t\t\t- [`Response.statusText`](#responsestatustext)\n\t\t\t- [`Response.type`](#responsetype)\n\t\t- [Instance Methods](#instance-methods-3)\n\t\t\t- [`Response.clone()`](#responseclone)\n\t\t- [Static Methods](#static-methods)\n\t\t\t- [`Response.error()`](#responseerror)\n\t\t\t- [`Response.redirect(url, status)`](#responseredirecturl-status)\n- [TypeScript](#typescript)\n- [Spec Omissions](#spec-omissions)\n\n# Benchmarks\n\n`npm run benchmarks`\n\nOn my personal machine:\n\n```\nMacBook Pro (15-inch, 2018)\nProcessor 2.9 GHz 6-Core Intel Core i9\nMemory 32 GB 2400 MHz DDR4\n```\n\nResults:\n\n```\n{\n  undici: { startTime: 72530288319510n, endTime: 72544207363031n },\n  node: { startTime: 72530283341532n, endTime: 72575809241450n },\n  minipass: { startTime: 72530290384674n, endTime: 72576867597178n }\n}\nResults for 10000 subsequent requests: \nundici-fetch | total time: 13919043521ns (13919.044ms)\nnode-fetch | total time: 45525899918ns (45525.900ms)\nminipass-fetch | total time: 46577212504ns (46577.213ms)\n---\nundici-fetch <> node-fetch percent change: -69.426%\nundici-fetch <> minipass-fetch percent change: -70.116%\n```\n\n# API\n\nThe default export for this module is a fetch client instance [`fetch`](). It uses the default `Undici.Pool()` options.\n\nIn order to pass options to the underlying Pool instance, use the named export [`buildFetch`]() method. The fetch instance returned by this method should be used throughout a project. Behind the scenes, `undici-fetch` reuses the pool instances for similar url origins. The pools are memoized in a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) that is initialized in the `buildFetch` closure.\n\n**Notice:** You must call `fetch.close()` at the end of your project in order to safely close all of the Undici request pools. This step is will be removed before v1 release when an auto-close feature is added (https://github.com/nodejs/undici/pull/508).\n\n```js\nconst fetch = require('undici-fetch')\n\nasync function run() {\n\tconst res = await fetch('https://example.com')\n\tconst json = await res.json()\n\n\tconsole.log(json)\n\n\tawait fetch.close()\n}\n\nrun()\n```\n\n> All mentions of `stream.Readable` or `Readable` in this documentation is referring to the Node.js Stream API [Readable Class](https://nodejs.org/api/stream.html#stream_class_stream_readable)\n\nKeep in mind that many of these classes were designed to be directly integrated with Undici and thus may not offer the best stand-alone dev experience. They follow the fetch spec as close as possible and should not deviate from that spec API.\n\n## Default Method: `fetch(resource, [init])`\n\n* **resource** `string | Request`\n* **init** `object` (optional)\n  * **method** `string` (optional) - Defaults to `'GET'`\n  * **headers** `Headers | HeadersInit` (optional)\n  * **body** `Readable | null` (optional)\n\nReturns: `Promise<Response>`\n\n```js\n// import and initialize all-at-once\nconst fetch = require('undici-fetch')()\n\n// Promise Chain\nfetch('https://example.com')\n\t.then(res => res.json())\n\t.then(json => console.log(json))\n\n// Async/Await\nconst res = await fetch('https://example.com')\nconst json = await res.json()\n```\n\n## Method: `buildFetch()`\n\nReturns: [fetch](#default-method-fetchresource-init)\n\n```js\nconst { buildFetch } = require('undici-fetch')\nconst fetch = buildFetch({ /* Undici.Pool options */ })\n```\n\n## Class: Headers\n\nRepresents a WHATWG Fetch Spec [Headers Class](https://fetch.spec.whatwg.org/#headers-class)\n\n### `new Headers([init])`\n\n* **init** `Iterable<[string, string]> | Record<string, string>` (optional) - Initial header list to be cloned into the new instance\n\n```js\nnew Headers()\n\nnew Headers([\n\t[\"undici\", \"fetch\"]\n])\n\nconst headers = new Headers({\n\t\"undici\": \"fetch\"\n})\n\nnew Headers(headers)\n```\n\n### Instance Methods\n\n#### `Headers.append(name, value)`\n\n* **name** `string`\n* **value** `string`\n\nReturns: `void`\n\nNon-destructive operation for adding header entries. When called multiple times with the same _name_, the values will be collected in a list and returned together when retrieved using [Headers.get](#headersgetname).\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.get('undici') // -> 'fetch'\n\nheaders.append('foobar', 'fuzz')\nheaders.append('foobar', 'buzz')\nheaders.get('foobar') // -> 'fuzz, buzz'\n```\n\n#### `Headers.delete(name)`\n\n* **name** `string`\n\nReturns: `void`\n\nRemoves a header entry. This operation is destructive and cannot be restored. Does **not** throw an error if the given _name_ does not exist. Reminder that [Headers.get](#headersgetname) will return `null` if the _name_ does not exist.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\n\nheaders.get('undici') // -> 'fetch'\n\nheaders.delete('undici')\n\nheaders.get('undici') // -> null\n```\n\n#### `Headers.get(name)`\n\n* **name** `string`\n\nReturns: `string | null`\n\nRetrieves a header entry. If the entry _name_ has multiple values, they are returned as a string joined by `','` characters. If the _name_ does not exist, this method returns null.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.get('undici') // -> 'fetch'\n\nheaders.append('foobar', 'fuzz')\nheaders.append('foobar', 'buzz')\nheaders.get('foobar') // -> 'fuzz, buzz'\n\nheaders.get('nodejs') // -> null\n```\n\n#### `Headers.has(name)`\n\n* **name** `string`\n\nReturns `boolean`\n\nChecks for the existence of a given entry _name_.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.has('undici') // -> true\n```\n\n#### `Headers.set(name, value)`\n\n* **name** `string`\n* **value** `string`\n\nReturns: `void`\n\nDestructive operation that will override any existing values for the given entry _name_. For a non-destructive alternative see [Headers.append](#headersappendname-value).\n\n```js\nconst headers = new Headers()\n\nheaders.set('foobar', 'fuzz')\nheaders.get('foobar') // -> 'fuzz'\n\nheaders.set('foobar', 'buzz')\nheaders.get('foobar') // -> 'buzz'\n```\n\n#### `Headers.values()`\n\nReturns: `IteratableIterator<string>`\n\nYields a list of header values combined and sorted by their respective keys.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const value of headers.values()) {\n\tconsole.log(value)\n}\n\n// -> '123'\n// -> '456'\n// -> '789, 012'\n```\n\n#### `Headers.keys()`\n\nReturns: `IteratableIterator<string>`\n\nYields a sorted list of header keys.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const name of headers.keys()) {\n\tconsole.log(name)\n}\n\n// -> 'abc'\n// -> 'def'\n// -> 'ghi'\n```\n#### `Headers.forEach(callback, [thisArg])`\n\n* **callback** `(value: string, key: string, iterable: Headers) => void`\n* **thisArg** `any` (optional)\n\nReturns: `void`\n\nA Headers class can be iterated using `.forEach(callback, [thisArg])`.\n\nOptionally a `thisArg` can be passed which will be assigned to the `this` context of callback.\n\nThe headers are returned in a sorted order, and values are combined on similar keys.\n\n```js\nconst headers = new Headers([['abc', '123']])\n\nheaders.forEach(function (value, key, headers) {\n\tconsole.log(key, value)\n})\n// -> 'abc', '123'\n```\n\n#### `Headers[Symbol.iterator]`\n\nReturns: `Iterator<[string, string]>`\n\nA Headers class instance is iterable. It yields each of its entries as a pair where the first value is the entry _name_ and the second value is the header _value_. They are sorted by _name_ or otherwise referred to as the header key.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const [name, value] of headers) {\n\tconsole.log(name, value)\n}\n\n// -> 'abc', '123'\n// -> 'def', '456'\n// -> 'ghi', '789, 012'\n```\n\n#### `Headers.entries()`\n\nReturns: `IteratableIterator<[string, string]>`\n\nYields a list of headers sorted and combined by key.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const entry of headers.entries()) {\n\tconsole.log(entry)\n}\n\n// -> 'abc', '123'\n// -> 'def', '456'\n// -> 'ghi', '789, 012'\n```\n\n## Class: Body\n\nRepresents a WHATWG Fetch Spec [Body Mixin](https://fetch.spec.whatwg.org/#body-mixin)\n\n### `new Body([input])`\n\n* **input** `Readable | null | undefined` (optional) - Defaults to `null`\n\nThis class is the core for the [Request](#class-request) and [Response](#class-response) classes. Since this class is only ever going to recieve response data from Undici requests, it only supports Readable streams.\n\n```js\nnew Body()\nnew Body(undefined)\nnew Body(null)\nnew Body(Readable.from('undici-fetch', { objectMode: false }))\n```\n\n### Instance Properties\n\n#### `Body.body`\n\n* `Readable | null`\n\nA property representing the payload of the Body instance\n\n#### `Body.bodyUsed`\n\n* `boolean`\n\nA property representing the consumption state of the Body instance. Do not confuse this property with the Node.js [stream](https://nodejs.org/api/stream.html#stream_three_states) state of `Body.body`. This property is used by the other instance methods for indicating to other parts of the API if the body has been consumed or not.\n\n### Instance Methods\n\n#### `Body.arrayBuffer()`\n\nReturns: `Promise<Buffer>`\n\nReturns the `Body.body` content as a Node.js [Buffer](https://nodejs.org/api/buffer.html#buffer_class_buffer) instance.\n\n```js\nconst body = new Body(Readable.from('undici-fetch', { objectMode: false }))\n\nconst buf = await body.arrayBuffer()\nconsole.log(buf instanceof Buffer) // -> true\nconsole.log(buf.toString('utf8')) // -> 'undici-fetch'\n```\n\n#### `Body.blob()`\n\nReturns: `never`\n\nCurrently, this implementation does not support returning content as a blob. Calling this method will throw an error. This may change in future API updates.\n\n```js\nconst body = new Body(new Readable())\n\ntry {\n\tawait body.blob()\n} catch (err) {\n\tconsole.log(err.message) // -> 'Body.blob() is not supported yet by undici-fetch'\n}\n```\n\n#### `Body.formData()`\n\nReturns: `never`\n\nCurrently, this implementation does not support returning content as a blob. Calling this method will throw an error. This may change in future API updates.\n\n```js\nconst body = new Body(new Readable())\n\ntry {\n\tawait body.formData()\n} catch (err) {\n\tconsole.log(err.message) // -> 'Body.formData() is not supported yet by undici-fetch'\n}\n```\n\n#### `Body.json()`\n\nReturns: `Promise<any>`\n\nReturns the `Body.body` content as a JSON object.\n\n```js\nconst content = JSON.stringify({ undici: 'fetch' })\nconst body = new Body(Readable.from(content, { objectMode: false }))\n\nconst res = await body.json()\n\nconsole.log(res) // -> { undici: 'fetch' }\n```\n\n#### `Body.text()`\n\nReturns: `Promise<string>`\n\nReturns the `Body.body` content as a UTF-8 string.\n\n```js\nconst body = new Body(Readable.from('undici-fetch', { objectMode: false }))\n\nconst res = await body.text()\n\nconsole.log(res) // -> 'undici-fetch'\n```\n\n## Class: Request\n\nExtends: `Body`\n\nRepresents a WHATWG Fetch Spec [Request Class](https://fetch.spec.whatwg.org/#request-class)\n\n### `new Request(input, [init])`\n* **input** `Request | string`\n* **init** `object` (optional)\n  * **method** `string` (optional) - Defaults to `'GET'`\n  * **headers** `Headers | HeadersInit` (optional)\n  * **body** `Readable | null | undefined` (optional)\n\nCreates a new `Request` object. The resulting instance can be passed directly to the [fetch](#method-fetchresource-init) method. The input string will be transformed into a Node.js [URL](https://nodejs.org/api/url.html#url_class_url) instance.\n\n```js\nconst request = new Request('https://example.com', {\n\tmethod: 'POST',\n\tbody: Readable.from('undici-fetch', { objectMode: false })\n})\n\nconst res = await fetch(request)\n```\n\n### Instance Properties:\n\n#### `Request.url`\n\n* `URL`\n\nA Node.js [URL Class](https://nodejs.org/api/url.html#url_class_url) instance representing the destination of the Request instance\n\n#### `Request.method`\n\n* `string`\n\nA property representing the type of the Request instance. Will be normalized to uppercase format and validated as one of [`http.METHODS`](https://nodejs.org/api/http.html#http_http_methods).\n\n#### `Request.headers`\n\n* `Headers`\n\nA [Headers](#class-headers) class instance representing the Headers instance for the request instance.\n\n### Instance Methods:\n\n#### `Request.clone()`\n\nReturns: `Request`\n\nWill throw an `Error` if the current instance `Responce.bodyUsed` is `true`. Returns a new Request instance based on the existing instance.\n\n```js\nconst request = new Request('https://example.com')\n\nconst newRequest = request.clone()\n\nconsole.log(newRequest.url) // => 'https://example.com'\n```\n\n## Class: Response\n\nExtends: `Body`\n\nRepresents a WHATWG Fetch Spec [Response Class](https://fetch.spec.whatwg.org/#response-class)\n\n### `new Response(body, [init])`\n\n* **body** `Readable | null | undefined`\n* **init** `object` (optional)\n  * **status** `number` (optional) - Defaults to `200`\n  * **statusText** `string` (optional) - Defaults to `''`\n  * **headers** `Headers | HeadersInit` (optional)\n\nCreates a new `Response` object. This is the result resolved from a successful `fetch()` call. Remember that this class extends from [Body](#class-body) so you can use methods such as `.text()` and `.json()`.\n\n```js\nconst response = new Response(Readable.from('undici-fetch', { objectMode: false }))\n\nif (response.ok) {\n\tconst text = await response.text()\n\n\tconsole.log(text) // -> 'undici-fetch'\n}\n```\n\n### Instance Properties\n\n#### `Response.headers`\n\n* `Headers`\n\nA property representing a [Headers](#class-headers) instance for the response.\n\n#### `Response.ok`\n\n* `boolean`\n\nA property representing if the response is _ok_. A Response is considered _ok_ if the `status` is between 200 and 299 inclusive.\n\n#### `Response.status`\n\n* `number`\n\nA property representing the status code of the response.\n\n#### `Response.statusText`\n\n* `string`\n\nA property representing the status of the response instance based on [`http.STATUS_CODES`](https://nodejs.org/api/http.html#http_http_status_codes).\n\n#### `Response.type`\n\n* `string`\n\nDefaults to `'default'`. A property representing the type of response instance. Currently only used to indicate an error response from [`Response.error()`](#responseerror).\n\n### Instance Methods\n\n#### `Response.clone()`\n\nReturns: `Response`\n\nWill throw an `Error` if the current instance `Responce.bodyUsed` is `true`.\n\n### Static Methods\n\n#### `Response.error()`\n\nReturns: `Response`\n\nGenerates a Response instance with `type` set to `'error'` and a `body` set to `null`.\n\n```js\nconst errorResponse = Response.error()\n```\n\n#### `Response.redirect(url, status)`\n\n* **url** `string` - The redirect location--will be assigned to a `'location'` header\n* **status** `number` - Must be one of: 301, 302, 303, 307, or 308\n\nReturns: `Response`\n\n```js\nconst redirectResponse = Response.redirect('https://example.com', 301)\n```\n\n---\n\n# TypeScript\n\nSimilar to Undici, this module ships with its own TypeScript definitions. Make sure to install `@types/node` as well.\n\n# Spec Omissions\n\nFetch is a browser API, but this library is written in Node.js. We try to be as spec compliant as possible; however, some aspects just cannot be recreated on the server. **All Fetch WHATWG Spec omissions are detailed here**. Each part should have a summary of the omission, plus links to relevant spec section and additional documentation.\n\nEntries in this section have been considered for the implementation and explicitly ommitted. If you do not find an aspect of the Fetch API listed here that is **also** missing from the implementation, open an issue describing the feature request.\n","readmeFilename":"README.md","gitHead":"298f26dc813587fc62cbaa5e2de12f7bf7fb76e2","_id":"undici-fetch@0.3.0","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-RH3hrvrVfBqIIBOqxDfHZIA0Fm1X8VPDuvWQepQwB6R6gBsv8MCcD5r2CsUFy2mhDGqKhq31R04cmL/fcVA3XA==","shasum":"d30d12f917c6f046eba0dc863b748066471007d7","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-0.3.0.tgz","fileCount":24,"unpackedSize":60373,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaQAVCRA9TVsSAnZWagAAyO4P/Agq653+6612L5icYqwc\nnS91+2KI9UmHZcUNi9q7pJUWSFv4x1ubZG5daCFkKc5xuc/e1+48jrxMt46p\nz7Wi7YbTC3BI/XfpIhqXtDgh2BIvDl/e3vNJUmBkQyAa3dVSMGLJAgu7zPka\nD2t8S7XMgByEZOMsBfflB/w+p9EjokopWJIviiSs1eNlgPzWySM/azP0EVLW\n/5E6gCiFqp7XVu4hzBJg2b0nuTUZyEOrd9QveR7+WBz2bRuIzfhRS4jMUR1X\nAQ6BW7iyy/9CXl2UUOi0a2va+5v1++w40rykqEMVvhEgktFC+yaddr6GiDlQ\nrmfPoojx/Nz79CJZf4UA3Vac/pGJqBHVnaTr2i4jBHP6eZkaVD0rxY6wrF0+\nwFiJhHbsPQQu4BlWxVXNHKFdkxhqNgsYgDgzpZTCN3q4wsBkax/evvXrRQ2F\napznP6rM35VlB4BKnC96ThtWDw6uFMCdH+OpAu8QM6as0eKvtmUX8TLfQQJc\nt5r7nGxO+QjfaFMwtg/ev6UyESlEOrquaeCQ4sHlDxtZYvKBCmq7NfVu53qV\nKbW8tPdfBCLLF4y6/14ISHVPoCSOd/fTXjpSe28drgDJwmCVEvYQh0dwfOMw\n5GlAhGYyI2eYvrk8rFnD3u/zuLfhF9BxpDRA/tuk+EltqtmBzeEvStAO18pW\nrl58\r\n=Y6FW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFVr4+RBnKc/kgJwGCwxy2XtKbleu0xoJ3l4Qj02Dk3zAiEA4btmebDOFu63fFx7pdnkOhWoGOEaqB+URLBO+blfKRw="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_0.3.0_1617494036901_0.9376818373377849"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"1.0.0-rc.1":{"name":"undici-fetch","version":"1.0.0-rc.1","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint:js":"standard --verbose","lint:ts":"ts-standard --verbose","lint":"npm run lint:js && npm run lint:ts","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^4.0.0-rc.1"},"devDependencies":{"@types/node":"^14.14.37","abortcontroller-polyfill":"^1.7.1","axios":"^0.21.1","minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.5","standard":"^16.0.3","tap":"^15.0.6","ts-standard":"^10.0.0","typescript":"^4.2.4"},"gitHead":"c331d965571c6a2fad40c9bfda46844efec89836","_id":"undici-fetch@1.0.0-rc.1","_nodeVersion":"16.1.0","_npmVersion":"7.11.2","dist":{"integrity":"sha512-VPMBog6ke/hSABltjVrcq+xc0RSnqfgmufn+5hfKBoIEJJq5nkKWQcWzW/uGlesSC2eKFQ6sPCQesFc7LfqGAg==","shasum":"75c0c5032485fbe50a340d66b6c7ddf1195cac38","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-1.0.0-rc.1.tgz","fileCount":34,"unpackedSize":95627,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgw/2lCRA9TVsSAnZWagAA1XcP/jECko0KeKo7ehyFQa2B\ngYZ6pLJYRpnWUPywysy5xqrGPpuJbcH5/wA/ZNIl4xJe7oFuB5SyOv7O+Bok\nofWl3lar5yDd8h11Ik5z/1T1crCwYsrgY3mU4AQH03G37xNlJRDumSKAnbFr\nsqo2CpEFbWpd6IVNV8K87NeCRcZljUI/+7FIGt/uLIi+FxsycC17+apq4osm\ncNseRUo3mN0m1CsX76Q1ct/63PHyFOT7ifUe1io2hHhYmW+d3WDJ8VH9Ae2+\nvtZbCDOjPbUTAOSF9n4UG/DvF8IyVmKtJAzutDWdq3WVdM6f6mG5C9lAsqHo\nSN+ZhZ2jQH35mdkK9vu1+mjeTBtSEfZaUJPt/gJEvPE5dWHZFNxr5oZdwxfQ\nKLJtndZpFmsqUpIf6nWZK7ohLLvc7bWtZKBB8eksp8s+0jWmKdzuQapj0Sm+\nmFKpCssrmgDkmT8gZtLF5oxdLBg0UqZoOiY+Qy7uqOaFSIXN7xrqK6W0D+3e\nikAxBch8y3luKlu7D6slGgVMVN0F4OPRmXinGqmPgTuIgUzI0hxwYBvXd3ii\nNqtkTgMi9kzB05Iox26GlmAB3FeUnqgQ0EIrDdw0miO8QGq6f0YzQqrOXd52\n81vYiAP4c3X7sO7AT6lS8crCAkV67SvcfVIRFrwd8odMURWyGnDDyA++SSZN\nKBVw\r\n=Tde/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAgQ3V+lfUx4ytXmdcikhWc8l5+gRcGpNheY1P4xOIXsAiEAvjjQ9c+fWoUFpV4hRGzgMzzr9GD5VjGzpM8W92oWnsk="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_1.0.0-rc.1_1623457189758_0.5289389389420707"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"1.0.0-rc.2":{"name":"undici-fetch","version":"1.0.0-rc.2","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint:js":"standard --verbose","lint:ts":"ts-standard --verbose","lint":"npm run lint:js && npm run lint:ts","test":"tap -J --test-ignore='testUtils.js'","bench":"node benchmarks"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"engines":{"node":">=14.0.0"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^4.0.0"},"devDependencies":{"@types/node":"^14.14.37","abortcontroller-polyfill":"^1.7.1","axios":"^0.21.1","minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.5","standard":"^16.0.3","tap":"^15.0.6","ts-standard":"^10.0.0","typescript":"^4.2.4"},"gitHead":"5cecc3f940504bfa0ae6b62f874a96ba477da75c","_id":"undici-fetch@1.0.0-rc.2","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-CbAeZ+Cl9OGl8Q0DOprZN/dYYdul5yepiK7jkgMQJuESexnk9HdeGY6ca4LL4rWMZuWhpMz0XzJSyHcWrdykow==","shasum":"04fef6affb7e49b325e692c8eee90c33c07270f9","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-1.0.0-rc.2.tgz","fileCount":33,"unpackedSize":80645,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg0+98CRA9TVsSAnZWagAAZZIQAJkpe5Jo8ljdiJlGZ7mF\nhGPLJ9wpORbrQt4aiPv3Nv+92xXeU57ygoL55IFalNixoaCSoK4Pc+QRaC4B\ngBMxJA98c6FqW54/PBC9ViN8XkDB6BbROa/znzuVPKB2lkPCIqLfSksAlDSa\n7WmnfZPVpBd1YBNNak9o2MnxiLGU8K+eR19gusissU3D7hHDuGkYaTb029H8\nrAt94wFD3ad7wkrIqh1So+G84miVdE6KnKD2udUtxKjFFMt/+YSkqEnYAYnO\nH0fy3MO/uh7F4zefwh3v+yp5MRe73XeacxUeEw7P2dxNEZc0p6JmxBUT3AQN\nI3z9+AoWWYF79u9LgL5xOOfiaHZoAwKArHjy0g3sixuIazFRwT5e2fwQCoe0\nR/WqK9OOvqojJSBiRp2TP0ii+mnKV+VU8FCeCuaoY2UMsWew9Bj9QcaIy3IE\nCem9Z3wMcdYzazuyMRh92brDV4nZb2/JETY4bmb7eq3P4lX/ojwrr6UygzYg\nMDLZjxyaSOBAD0H/a1WlVkYRRQ//YnK5Wok7kbZ2zLKiDpmBjj/1H4QheMyh\nb7KTkJjN4ZZxItIfQ/hM7p0m7oTlwoaeHPfYlEKsa8qlvXTYGIctpwVHg3cj\nE+kB1Nfp6YAvTuG7JttsMKbcf0tN/ds+FUGutStLsxo7qVTB+fmRRlyv/X7F\nPDGY\r\n=QhA1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAxFYXtWpCrkDtHzHSPPyaCwzDK0qE7eIISK+PedE5KiAiEAj3ju1W2YuZK39xcC0twmtFSnTtHe/TlXHUmAsvmt0CE="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_1.0.0-rc.2_1624502140253_0.07197110890972369"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"1.0.0-rc.3":{"name":"undici-fetch","version":"1.0.0-rc.3","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint:js":"standard --verbose","lint:ts":"ts-standard --verbose","lint":"npm run lint:js && npm run lint:ts","test":"tap -J --test-ignore='testUtils.js'","benchmarks":"node benchmarks/index.mjs"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"engines":{"node":">=14.0.0"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^4.0.0"},"devDependencies":{"@types/node":"^14.14.37","abortcontroller-polyfill":"^1.7.1","axios":"^0.21.1","minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.5","standard":"^16.0.3","tap":"^15.0.6","ts-standard":"^10.0.0","typescript":"^4.2.4"},"gitHead":"f01bd2e99149ff823c32b6007213d8bedb46d12b","_id":"undici-fetch@1.0.0-rc.3","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-1DzvbH/QWhTJEPfHLspn2hmvhpfLG/+dOEWWazQmvlfA5AKKY+Rp61ypM9OAee6cSEiGnTt7eMZRhUr3NDIqtQ==","shasum":"b8e766eb49d367812d8ab5c41212fa1c4f2210b6","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-1.0.0-rc.3.tgz","fileCount":56,"unpackedSize":106481,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg1k/2CRA9TVsSAnZWagAAU5MP/RyUcisKo0RDxpummFmr\nipCK3tt3/481+deamQ6GYvPQ8Sv/XNsixsvU1qxRsKfZxD5f6wdvUNai60IF\nCoEPTExJKTIIoV4lEQn1H+TWIJL7WWzTYF1AmQ37/4h9533bU93pDFBHiFz8\n55D2QKeX0AmYofcQRoCaCVhdUOGydTZXhX51dF5yPnbfiSkkfnObuxPmlT+R\nc+XbHv2pDcvgXaPwVcnigAltwVJkuABQEkwHOF8fubAP4BXHTUjrpQccbwZH\nuIyJrzo4OFeOUK53adwC6+8tXO/OJUGe741FVVb4w4qbObfpCHfnImbvttP3\nBbAN+PaVBDA3phj339naMsGvOz0A/E+fisu9O9si2J1FsWoL/jzd1D3nGXpV\nXyh+LJCzoRrPmwnSYm9Kj6hErJEzzUIDVe9l+QE6q+yrPD7eMerd0Xtw6dac\ndvspQF4CqV9D86YVKwfEohLwcNwqHLk8LULnt7YUeb5LF05dzvHVk/9nr8r0\nszd0VjyC4PLApY0J/M7d2TqgJ9k5C2QzC0534IvpUYGaJ979DjEvXI3UMYNi\nYon7zAkZmKKUK80pCmkTvcUjT3EIJ4qM2zXfcQ9MkWa1AnqJvTrHCC+w4uTw\n5iCEhKcZ6XnErITHGPVx+hbWVJLnRaM8c19yzoUiZmao+uI/dU3lgzvgFXks\nUe/a\r\n=96gH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCPivtC86mlI+Xlpy++xFHtDfgGFjqJ7f5DPasJdEohrAIgCyZZPIbCRu0oI6ND7G6cLCMVHTTwtmdQhDwhWkU18dc="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_1.0.0-rc.3_1624657910246_0.7642233934782092"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"},"1.0.0-rc.4":{"name":"undici-fetch","version":"1.0.0-rc.4","description":"A WHATWG Fetch implementation based on @nodejs/undici","main":"./index.js","types":"./index.d.ts","scripts":{"lint:js":"standard --verbose","lint:ts":"ts-standard --verbose","lint":"npm run lint:js && npm run lint:ts","test":"tap -J --test-ignore='testUtils.js'","benchmarks":"node benchmarks/index.mjs"},"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"engines":{"node":">=14.0.0"},"keywords":["nodejs"],"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"license":"MIT","bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","dependencies":{"undici":"^4.0.0"},"devDependencies":{"@types/node":"^14.14.37","abortcontroller-polyfill":"^1.7.1","axios":"^0.21.1","minipass-fetch":"^1.3.2","node-fetch":"^2.6.1","semver":"^7.3.5","standard":"^16.0.3","tap":"^15.0.6","ts-standard":"^10.0.0","typescript":"^4.2.4"},"gitHead":"f400f890d19034d00562763f472c0d2f5824bcb6","_id":"undici-fetch@1.0.0-rc.4","_nodeVersion":"16.4.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-+F9lSstpd0YJkBBAMe1UXlUVeadsd/AJrB0643smYHcKAdwCtoBVWfoFO0ibk1sA1BEFH7himsWC5aHLomGK0g==","shasum":"7d836e3eb1964d5395d040665c868f49391d1e29","tarball":"https://registry.npmjs.org/undici-fetch/-/undici-fetch-1.0.0-rc.4.tgz","fileCount":57,"unpackedSize":108958,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg46UeCRA9TVsSAnZWagAAfy4P/2S1gwORB00oNVzplkv2\nMIppX/UQJiZ73IUNje6CqfV5GI9V4PUH0PaLpE67fKLAeDDVCLVPHlhcxapQ\ngfgm5gcSdwQOrAlxpY9yr2OBbILUCcOZIhUK34TXNVRN0ADxRr8LeLmByaxZ\nptzWJ3TuY1OzzRgJBccwAYFDOIUvvCmfM8zjeqnw7KT4T7G4JzLQKX7AbGdM\nVXD8sjvWsrX441Dh1jBhRw3nAvpDBL2+6HeSSHC+hKR8NcfImyDoZkowV7rb\naNcGjmMCz9qBWLfjvqZvKrDNORA7F7lvyix0bICWYZDfycbfI8Hsyx0ZuZCd\ngMncdsfKMN0WxLH0unGc3b1MqmZvB0YMA8uygHDVDQKjh7+lVfyw99EX5371\niL5L/xn3tprTsRkh8Bj0t8QTio9j5ipxTU2KAXJ7Ui8Rkpg/8fWXB5M9oMcm\nzoFV7JRCg8g8XdRdKAuAHXVl2AXOU2kIl0Rx8tJazzvGbeF67Rp7rbAkhjPg\nJYwUXJyMG43O9mT6RaOFJ8ZLSV8VVXukO0LxV4ZVBlS6ZNrh1MpLfgvrGZIk\nMoWQAUa1q4curFYypgwjbnmrwBlVi5JYTGMabKCXjxGUexHUqQDspu+y/Jwq\n1+0QRFcSOkamafTIVkYvEQeDFZtobDRcclsu3HTX+2AH0KO8rfnzxvjXTbCJ\nmNUY\r\n=b2am\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFRNsAapzkcvr3dS7zW6zJIMjHzqbnhGzckvWqbBPkqKAiEAzZPQHodUcl8GNvePd0EiLYj7sYydpNjOyrjqKfSNdUM="}]},"_npmUser":{"name":"ethan_arrowood","email":"ethan@arrowood.dev"},"directories":{},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/undici-fetch_1.0.0-rc.4_1625531678056_0.019512729686767427"},"_hasShrinkwrap":false,"deprecated":"Merged into core undici project"}},"time":{"created":"2021-01-09T17:24:36.410Z","0.1.0":"2021-01-09T17:24:36.534Z","modified":"2022-05-22T18:04:05.879Z","0.1.1":"2021-01-11T16:25:34.386Z","0.1.2":"2021-04-01T19:00:55.490Z","0.2.0":"2021-04-02T20:41:28.688Z","0.3.0":"2021-04-03T23:53:57.047Z","1.0.0-rc.1":"2021-06-12T00:19:49.927Z","1.0.0-rc.2":"2021-06-24T02:35:40.400Z","1.0.0-rc.3":"2021-06-25T21:51:50.390Z","1.0.0-rc.4":"2021-07-06T00:34:38.282Z"},"maintainers":[{"name":"ethan_arrowood","email":"ethan@arrowood.dev"}],"description":"A WHATWG Fetch implementation based on @nodejs/undici","homepage":"https://github.com/Ethan-Arrowood/undici-fetch#readme","keywords":["nodejs"],"repository":{"type":"git","url":"git+https://github.com/Ethan-Arrowood/undici-fetch.git"},"author":{"name":"Ethan Arrowood","email":"ethan@arrowood.dev"},"bugs":{"url":"https://github.com/Ethan-Arrowood/undici-fetch/issues"},"license":"MIT","readme":"# undici-fetch\n\n```sh\nnpm i undici-fetch\n```\n\nBuilt on [Undici](https://github.com/nodejs/undici)\n\n# Benchmarks\n\nView all benchmarks [here](./benchmarks.md)\n\n# API\n\nThe default export for this module is a fetch client instance [`fetch`](). It uses the top level `Undici.Request()` method. This project exposes the global dispatcher methods `getGlobalDispatcher` and `setGlobalDispatcher` if they need special configuration.\n\n## Exports\n\n_default_: [`fetch`](#default-method-fetchresource-init)\n\n_named exports_:\n* [`Request`](#class-request)\n* [`Response`](#class-response)\n* [`Headers`](#class-headers)\n* [`setGlobalDispatcher`](https://undici.nodejs.org/#/?id=undicisetglobaldispatcherdispatcher)\n* [`getGlobalDispatcher`](https://undici.nodejs.org/#/?id=undicigetglobaldispatcher)\n\n## Default Method: `fetch(resource, [init])`\n\n* **resource** `string | Request | URL`\n* **init** `RequestInit` (optional)\n\nReturns: `Promise<Response>`\n\n```js\n// import and initialize all-at-once\nconst fetch = require('undici-fetch')()\n\n// Promise Chain\nfetch('https://example.com')\n  .then(res => res.json())\n  .then(json => console.log(json))\n\n// Async/Await\nconst res = await fetch('https://example.com')\nconst json = await res.json()\n```\n\n## Class: Headers\n\nRepresents a WHATWG Fetch Spec [Headers Class](https://fetch.spec.whatwg.org/#headers-class)\n\n### `new Headers([init])`\n\n* **init** `Headers | Iterable<[string, string]> | string[] | Record<string, string>` (optional) - Initial header list to be cloned into the new instance\n\n```js\nnew Headers()\n\nnew Headers([\n\t[\"undici\", \"fetch\"]\n])\n\nnew Headers([ 'undici', 'fetch' ])\n\nconst headers = new Headers({\n\t\"undici\": \"fetch\"\n})\n\nnew Headers(headers)\n```\n\n### Instance Methods\n\n#### `Headers.append(name, value)`\n\n* **name** `string`\n* **value** `string`\n\nReturns: `void`\n\nNon-destructive operation for adding header entries. When called multiple times with the same _name_, the values will be collected in a list and returned together when retrieved using [Headers.get](#headersgetname).\n\nWhen _value_ is not a `string`, the _value_ will be stringified.\n\n```js\nconst headers = new Headers()\n\nheaders.append('key', ['value', 'value2'])\nheaders.get('key') // -> 'value,value2'\n\nheaders.append('undici', 'fetch')\nheaders.get('undici') // -> 'fetch'\n\nheaders.append('foobar', 'fuzz')\nheaders.append('foobar', 'buzz')\nheaders.get('foobar') // -> 'fuzz, buzz'\n```\n\n#### `Headers.delete(name)`\n\n* **name** `string`\n\nReturns: `void`\n\nRemoves a header entry. This operation is destructive and cannot be restored. Does **not** throw an error if the given _name_ does not exist. Reminder that [Headers.get](#headersgetname) will return `null` if the _name_ does not exist.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\n\nheaders.get('undici') // -> 'fetch'\n\nheaders.delete('undici')\n\nheaders.get('undici') // -> null\n```\n\n#### `Headers.get(name)`\n\n* **name** `string`\n\nReturns: `string | null`\n\nRetrieves a header entry. If the entry _name_ has multiple values, they are returned as a string joined by `','` characters. If the _name_ does not exist, this method returns null.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.get('undici') // -> 'fetch'\n\nheaders.append('foobar', 'fuzz')\nheaders.append('foobar', 'buzz')\nheaders.get('foobar') // -> 'fuzz, buzz'\n\nheaders.get('nodejs') // -> null\n```\n\n#### `Headers.has(name)`\n\n* **name** `string`\n\nReturns `boolean`\n\nChecks for the existence of a given entry _name_.\n\n```js\nconst headers = new Headers()\n\nheaders.append('undici', 'fetch')\nheaders.has('undici') // -> true\n```\n\n#### `Headers.set(name, value)`\n\n* **name** `string`\n* **value** `string`\n\nReturns: `void`\n\nDestructive operation that will override any existing values for the given entry _name_. For a non-destructive alternative see [Headers.append](#headersappendname-value).\n\nWhen _value_ is not a `string`, the _value_ will be stringified.\n\n```js\nconst headers = new Headers()\n\nheaders.set('foobar', 'fuzz')\nheaders.get('foobar') // -> 'fuzz'\n\nheaders.set('foobar', 'buzz')\nheaders.get('foobar') // -> 'buzz'\n```\n\n#### `Headers.values()`\n\nReturns: `IteratableIterator<string>`\n\nYields a list of header values combined and sorted by their respective keys.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const value of headers.values()) {\n\tconsole.log(value)\n}\n\n// -> '123'\n// -> '456'\n// -> '789, 012'\n```\n\n#### `Headers.keys()`\n\nReturns: `IteratableIterator<string>`\n\nYields a sorted list of header keys.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const name of headers.keys()) {\n\tconsole.log(name)\n}\n\n// -> 'abc'\n// -> 'def'\n// -> 'ghi'\n```\n#### `Headers.forEach(callback, [thisArg])`\n\n* **callback** `(value: string, key: string, iterable: Headers) => void`\n* **thisArg** `any` (optional)\n\nReturns: `void`\n\nA Headers class can be iterated using `.forEach(callback, [thisArg])`.\n\nOptionally a `thisArg` can be passed which will be assigned to the `this` context of callback.\n\nThe headers are returned in a sorted order, and values are combined on similar keys.\n\n```js\nconst headers = new Headers([['abc', '123']])\n\nheaders.forEach(function (value, key, headers) {\n\tconsole.log(key, value)\n})\n// -> 'abc', '123'\n```\n\n#### `Headers[Symbol.iterator]`\n\nReturns: `Iterator<[string, string]>`\n\nA Headers class instance is iterable. It yields each of its entries as a pair where the first value is the entry _name_ and the second value is the header _value_. They are sorted by _name_ or otherwise referred to as the header key.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const [name, value] of headers) {\n\tconsole.log(name, value)\n}\n\n// -> 'abc', '123'\n// -> 'def', '456'\n// -> 'ghi', '789, 012'\n```\n\n#### `Headers.entries()`\n\nReturns: `IteratableIterator<[string, string]>`\n\nYields a list of headers sorted and combined by key.\n\n```js\nconst headers = new Headers()\n\nheaders.set('abc', '123')\nheaders.set('def', '456')\nheaders.set('ghi', '789')\nheaders.append('ghi', '012')\n\nfor (const entry of headers.entries()) {\n\tconsole.log(entry)\n}\n\n// -> 'abc', '123'\n// -> 'def', '456'\n// -> 'ghi', '789, 012'\n```\n\n## Class: Request\n\nImplemets: `BodyMixin`\n\nRepresents a WHATWG Fetch Spec [Request Class](https://fetch.spec.whatwg.org/#request-class)\n\n### `new Request(input, [init])`\n* **input** `Request | string | URL`\n* **init** `object` (optional)\n  * **method** `string` (optional) - Defaults to `'GET'`\n  * **headers** `Headers | HeadersInit` (optional)\n  * **body** `AsyncIterable | Iterable | null | undefined` (optional)\n\t* **keepalive** `boolean` (optional)\n\t* **redirect** `string` (optional)\n\t* **integrity** `string` (optional)\n\t* **signal** `AbortSignal` (optional)\n\nCreates a new `Request` object. The resulting instance can be passed directly to the [fetch](#method-fetchresource-init) method. The input string will be transformed into a Node.js [URL](https://nodejs.org/api/url.html#url_class_url) instance.\n\n```js\nconst request = new Request('https://example.com', {\n\tmethod: 'POST',\n\tbody: 'undici-fetch'\n})\n\nconst res = await fetch(request)\n```\n\n### Instance Properties:\n\n#### `Request.url`\n\n* `URL`\n\nA Node.js [URL Class](https://nodejs.org/api/url.html#url_class_url) instance representing the destination of the Request instance\n\n#### `Request.method`\n\n* `string`\n\nA property representing the type of the Request instance. Will be normalized to uppercase format and validated as one of [`http.METHODS`](https://nodejs.org/api/http.html#http_http_methods).\n\n#### `Request.headers`\n\n* `Headers`\n\nA [Headers](#class-headers) class instance representing the Headers instance for the request instance.\n\n#### `Request.redirect`\n\n* `string`\n\n#### `Request.integrity`\n\n* `string`\n\n#### `Request.keepalive`\n\n* `boolean`\n\n#### `Request.signal`\n\n* `AbortSignal`\n\n### Instance Methods:\n\n#### `Request.clone()`\n\nReturns: `Request`\n\nWill throw an `Error` if the current instance `Responce.bodyUsed` is `true`. Returns a new Request instance based on the existing instance.\n\n```js\nconst request = new Request('https://example.com')\n\nconst newRequest = request.clone()\n\nconsole.log(newRequest.url) // => 'https://example.com'\n```\n\n## Class: Response\n\nExtends: `Body`\n\nRepresents a WHATWG Fetch Spec [Response Class](https://fetch.spec.whatwg.org/#response-class)\n\n### `new Response(body, [init])`\n\n* **body** `AsyncIterable | Iterable | null | undefined`\n* **init** `object` (optional)\n  * **status** `number` (optional) - Defaults to `200`\n  * **statusText** `string` (optional) - Defaults to `''`\n  * **headers** `Headers | HeadersInit` (optional)\n\nCreates a new `Response` object. This is the result resolved from a successful `fetch()` call. Remember that this class extends from [Body](#class-body) so you can use methods such as `.text()` and `.json()`.\n\n```js\nconst response = new Response('undici-fetch')\n\nif (response.ok) {\n\tconst text = await response.text()\n\n\tconsole.log(text) // -> 'undici-fetch'\n}\n```\n\n### Instance Properties\n\n#### `Response.headers`\n\n* `Headers`\n\nA property representing a [Headers](#class-headers) instance for the response.\n\n#### `Response.ok`\n\n* `boolean`\n\nA property representing if the response is _ok_. A Response is considered _ok_ if the `status` is between 200 and 299 inclusive.\n\n#### `Response.status`\n\n* `number`\n\nA property representing the status code of the response.\n\n#### `Response.statusText`\n\n* `string`\n\nA property representing the status of the response instance. If returned from `fetch()`, it will be based on [`http.STATUS_CODES`](https://nodejs.org/api/http.html#http_http_status_codes).\n\n#### `Response.type`\n\n* `string`\n\nDefaults to `'default'`. A property representing the type of response instance. Currently only used to indicate an error response from [`Response.error()`](#responseerror).\n\n### Instance Methods\n\n#### `Response.clone()`\n\nReturns: `Response`\n\nWill throw an `Error` if the current instance `Responce.bodyUsed` is `true`.\n\n### Static Methods\n\n#### `Response.error()`\n\nReturns: `Response`\n\nGenerates a Response instance with `type` set to `'error'` and a `body` set to `null`.\n\n```js\nconst errorResponse = Response.error()\n```\n\n#### `Response.redirect(url, status)`\n\n* **url** `string` - The redirect location--will be assigned to a `'location'` header\n* **status** `number` - Must be one of: 301, 302, 303, 307, or 308\n\nReturns: `Response`\n\n```js\nconst redirectResponse = Response.redirect('https://example.com', 301)\n```\n\n## Function: BodyMixin\n\nRepresents a WHATWG Fetch Spec [Body Mixin](https://fetch.spec.whatwg.org/#body-mixin).\n\nUse the mixin by called `BodyMixin` with the prototype of an object.\n\n```js\nclass Response {\n\tconstructor (body) {\n\t\tthis[kBody] = body\n\t}\n}\n\nBodyMixin(Response.prototype)\n\nconst response = new Response('undici-fetch')\n\nresponse.body // -> ControlledAsyncIterable from input 'undici-fetch'\n```\n\n### Properties\n\n#### `body`\n\n* `ControlledAsyncIterable | null`\n\nA property representing the payload of the instance. `ControlledAsyncIterable` is a mock WHATWG Readable Stream. It implements the `disturbed` property so that the Fetch api can operate accordingly.\n\n#### `bodyUsed`\n\n* `boolean`\n\nA property representing the consumption state of the instance. Do not confuse this property with the Node.js [stream](https://nodejs.org/api/stream.html#stream_three_states) state. This property is used by the other instance methods for indicating to other parts of the API if the body has been consumed or not.\n\n### Methods\n\n#### `arrayBuffer()`\n\nReturns: `Promise<Buffer>`\n\nReturns the `body` content as a Node.js [Buffer](https://nodejs.org/api/buffer.html#buffer_class_buffer) instance.\n\n```js\nconst response = new Response('undici-fetch')\n\nconst buf = await response.arrayBuffer()\nconsole.log(buf instanceof Buffer) // -> true\nconsole.log(buf.toString('utf8')) // -> 'undici-fetch'\n```\n\n#### `blob()`\n\nReturns: `never`\n\nCurrently, this implementation does not support returning content as a blob. Calling this method will throw an error. This may change in future API updates.\n\n```js\nconst response = new Response('undici-fetch')\n\ntry {\n\tawait response.blob()\n} catch (err) {\n\tconsole.log(err.message) // -> 'Response.blob() is not supported yet by undici-fetch'\n}\n```\n\n#### `formData()`\n\nReturns: `never`\n\nCurrently, this implementation does not support returning content as a blob. Calling this method will throw an error. This may change in future API updates.\n\n```js\nconst response = new Response('undici-fetch')\n\ntry {\n\tawait response.formData()\n} catch (err) {\n\tconsole.log(err.message) // -> 'Response.formData() is not supported yet by undici-fetch'\n}\n```\n\n#### `json()`\n\nReturns: `Promise<any>`\n\nReturns the `body` content as a JSON object.\n\n```js\nconst content = JSON.stringify({ undici: 'fetch' })\nconst response = new Response(content)\n\nconst data = await response.json()\n\nconsole.log(data) // -> { undici: 'fetch' }\n```\n\n#### `text()`\n\nReturns: `Promise<string>`\n\nReturns the `body` content as a UTF-8 string.\n\n```js\nconst response = new Response('undici-fetch')\n\nconst text = await response.text()\n\nconsole.log(text) // -> 'undici-fetch'\n```\n\n---\n\n# TypeScript\n\nSimilar to Undici, this module ships with its own TypeScript definitions. Make sure to install `@types/node` as well.\n\n# Spec Omissions\n\nFetch is a browser API, but this library is written in Node.js. We try to be as spec compliant as possible; however, some aspects just cannot be recreated on the server. **All Fetch WHATWG Spec omissions are detailed here**. Each part should have a summary of the omission, plus links to relevant spec section and additional documentation.\n\nEntries in this section have been considered for the implementation and explicitly ommitted. If you do not find an aspect of the Fetch API listed here that is **also** missing from the implementation, open an issue describing the feature request.\n\n## CORS\n\nAny CORS-related aspects of the Fetch api has been omitted from this implementation.","readmeFilename":"README.md"}