{"name":"get-uri","version":"7.0.0","keywords":["uri","read","readstream","stream","get","http","https","ftp","file","data","protocol","url"],"author":{"url":"http://n8.io/","name":"Nathan Rajlich","email":"nathan@tootallnate.net"},"license":"MIT","_id":"get-uri@7.0.0","maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"homepage":"https://github.com/TooTallNate/proxy-agents#readme","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"dist":{"shasum":"c2f0ff109d6f5ff4d9061f19ad44f6f34deaba36","tarball":"http://registry-npm.ywwl.com/get-uri/download/get-uri-7.0.0.tgz","fileCount":39,"integrity":"sha512-ZsC7KQxm1Hra8yO0RvMZ4lGJT7vnBtSNpEHKq39MPN7vjuvCiu1aQ8rkXUaIXG1y/TSDez97Gmv04ibnYqCp/A==","signatures":[{"sig":"MEQCIDO/fJMiFjx6aXTTwnhnj37VqR5eHzMEY86tqJbkHYmgAiATdOb/jA3mykRP3/t1UrDYhaqltk9FOgOKuq7PQbdXWw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/get-uri@7.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":44748,"size":13847,"noattachment":false,"key":"/get-uri/-/get-uri-7.0.0.tgz"},"type":"module","_from":"file:get-uri-7.0.0.tgz","engines":{"node":">= 14"},"exports":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs","test":"vitest","build":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:161f169d-7deb-4a01-b2c4-3efe441e06ad"}},"_resolved":"/tmp/d553960e57e7dab1225a095a70f0c180/get-uri-7.0.0.tgz","_integrity":"sha512-ZsC7KQxm1Hra8yO0RvMZ4lGJT7vnBtSNpEHKq39MPN7vjuvCiu1aQ8rkXUaIXG1y/TSDez97Gmv04ibnYqCp/A==","repository":{"url":"git+https://github.com/TooTallNate/proxy-agents.git","type":"git","directory":"packages/get-uri"},"_npmVersion":"11.11.0","description":"Returns a `stream.Readable` from a URI string","directories":{},"_nodeVersion":"20.20.0","dependencies":{"debug":"^4.3.4","basic-ftp":"^5.0.2","data-uri-to-buffer":"7.0.0"},"_hasShrinkwrap":false,"devDependencies":{"st":"^3.0.0","ftpd":"^0.2.14","tsconfig":"0.0.0","typescript":"^5.1.6","@types/ftpd":"^0.2.35","@types/node":"^22.13.0","@types/debug":"^4.1.7","async-listen":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/get-uri_7.0.0_1773248319031_0.21345694743279697","host":"s3://npm-registry-packages-npm-production"},"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":1773248319170,"_cnpm_publish_time":1773248319170,"dist-tags":{"latest":"8.0.2"}}