{"name":"get-uri","version":"8.0.1","type":"module","description":"Returns a `stream.Readable` from a URI string","exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"repository":{"type":"git","url":"git+https://github.com/TooTallNate/proxy-agents.git","directory":"packages/get-uri"},"keywords":["uri","read","readstream","stream","get","http","https","ftp","file","data","protocol","url"],"author":{"name":"Nathan Rajlich","email":"nathan@tootallnate.net","url":"http://n8.io/"},"license":"MIT","devDependencies":{"@types/debug":"^4.1.7","@types/ftpd":"^0.2.35","@types/node":"^22.13.0","async-listen":"^3.0.0","ftpd":"^0.2.14","st":"^3.0.0","typescript":"^5.1.6","tsconfig":"0.0.0"},"dependencies":{"basic-ftp":"^5.3.1","debug":"^4.3.4","data-uri-to-buffer":"8.0.0"},"engines":{"node":">= 20"},"scripts":{"build":"tsc","test":"vitest","lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs"},"_id":"get-uri@8.0.1","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"homepage":"https://github.com/TooTallNate/proxy-agents#readme","_integrity":"sha512-/5N/P4Lrh0p/mDwlDRi7Y1+P2o/OyzZI3l6Iz1Ov6XXwwm1y3RlZLuo3gVgML99djrEDtV980bBxSuOeHLk8ww==","_resolved":"/tmp/a5c58c8dfc93e668506e51017c9e1d09/get-uri-8.0.1.tgz","_from":"file:get-uri-8.0.1.tgz","_nodeVersion":"20.20.2","_npmVersion":"11.16.0","dist":{"integrity":"sha512-/5N/P4Lrh0p/mDwlDRi7Y1+P2o/OyzZI3l6Iz1Ov6XXwwm1y3RlZLuo3gVgML99djrEDtV980bBxSuOeHLk8ww==","shasum":"772b1418bf034c2c43ddd6a41af24a4262e135ee","tarball":"http://registry-npm.ywwl.com/get-uri/download/get-uri-8.0.1.tgz","fileCount":39,"unpackedSize":44722,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/get-uri@8.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDrTbURwZIN1In31PKOSsJKXDMSXgKx0R8paDKBJlh+dwIhAKBbW3l8Kp0XJR3SF4BaWUmm3oTTKN6xEXA6CCWc99zR"}],"size":13834,"noattachment":false,"key":"/get-uri/-/get-uri-8.0.1.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:161f169d-7deb-4a01-b2c4-3efe441e06ad"}},"directories":{},"maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/get-uri_8.0.1_1780937240440_0.012142181843036282"},"_hasShrinkwrap":false,"readme":"get-uri\n=======\n### Returns a `stream.Readable` from a URI string\n\nThis high-level module accepts a URI string and returns a `Readable` stream\ninstance. There is built-in support for a variety of \"protocols\", and it's\neasily extensible with more:\n\n| Protocol  | Description                     | Example\n|:---------:|:-------------------------------:|:---------------------------------:\n| `data`    | [Data URIs][data]               | `data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D`\n| `file`    | [File URIs][file]               | `file:///c:/windows/example.ini`\n| `ftp`     | [FTP URIs][ftp]                 | `ftp://ftp.kernel.org/pub/site/README`\n| `http`    | [HTTP URIs][http]               | `http://www.example.com/path/to/name`\n| `https`   | [HTTPS URIs][https]             | `https://www.example.com/path/to/name`\n\nExample\n-------\n\nTo simply get a `stream.Readable` instance from a `file:` URI, try something like:\n\n```ts\nimport { getUri } from 'get-uri';\n\n// `file:` maps to a `fs.ReadStream` instance…\nconst stream = await getUri('file:///Users/nrajlich/wat.json');\nstream.pipe(process.stdout);\n```\n\n\nMissing Endpoints\n-----------------\n\nWhen you pass in a URI in which the resource referenced does not exist on the\ndestination server, then a `NotFoundError` will be thrown. The `code` of the\nerror instance is set to `\"ENOTFOUND\"`, so you can check for that value\nto detect when a bad filename is requested:\n\n```ts\ntry {\n  await getUri('http://example.com/resource.json');\n} catch (err) {\n  if (err.code === 'ENOTFOUND') {\n    // bad file path requested\n  } else {\n    // something else bad happened...\n    throw err;\n  }\n}\n```\n\n\nCacheability\n------------\n\nWhen calling `getUri()` with the same URI multiple times, the `get-uri` module\nsupports sending an indicator that the remote resource has not been modified\nsince the last time it has been retrieved from that node process.\n\nTo do this, define a `cache` property on the \"options object\" argument\nwith the value set to the `stream.Readable` instance that was previously\nreturned. If the remote resource has not been changed since the last call for\nthat same URI, then a `NotModifiedError` instance will be thrown with its\n`code` property set to `\"ENOTMODIFIED\"`.\n\nWhen the `\"ENOTMODIFIED\"` error occurs, then you can safely re-use the\nresults from the previous `getUri()` call for that same URI:\n\n``` js\n// First time fetches for real\nconst stream = await getUri('http://example.com/resource.json');\n\ntry {\n  // … some time later, if you need to get this same URI again, pass in the\n  // previous `stream.Readable` instance as `cache` option to potentially\n  // have an \"ENOTMODIFIED\" error thrown:\n  await getUri('http://example.com/resource.json', { cache: stream });\n} catch (err) {\n  if (err.code === 'ENOTMODIFIED') {\n    // source file has not been modified since last time it was requested,\n    // so you are expected to re-use results from a previous call to `getUri()`\n  } else {\n    // something else bad happened...\n    throw err;\n  }\n}\n```\n\n\nAPI\n---\n\n### getUri(uri: string | URL, options?: Object]): Promise<Readable>\n\nA `uri` is required. An optional `options` object may be passed in:\n\n - `cache` - A `stream.Readable` instance from a previous call to `getUri()` with the same URI. If this option is passed in, and the destination endpoint has not been modified, then an `ENOTMODIFIED` error is thrown\n\nAny other options passed in to the `options` object will be passed through\nto the low-level connection creation functions (`http.get()`, `ftp.connect()`,\netc).\n\nReturns a `stream.Readable` instance to read the resource at the given `uri`.\n\n[data]: http://tools.ietf.org/html/rfc2397\n[file]: http://tools.ietf.org/html/draft-hoffman-file-uri-03\n[ftp]: http://www.w3.org/Protocols/rfc959/\n[http]: http://www.w3.org/Protocols/rfc2616/rfc2616.html\n[https]: http://wikipedia.org/wiki/HTTP_Secure\n","publish_time":1780937240580,"_cnpm_publish_time":1780937240580,"dist-tags":{"latest":"8.0.2"}}