{"name":"get-uri","version":"6.0.5","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@6.0.5","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":"714892aa4a871db671abc5395e5e9447bc306a16","tarball":"http://registry-npm.ywwl.com/get-uri/download/get-uri-6.0.5.tgz","fileCount":31,"integrity":"sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==","signatures":[{"sig":"MEYCIQCKwqGTJ8ytENUgiOeMtqaXBidMNze+JoY7gBbGS2cg/wIhAI4TFeaB1d8NZXXl2UJCgPoWnP6Ht0iMtYSWsGxDQ7xp","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44220,"size":13135,"noattachment":false,"key":"/get-uri/-/get-uri-6.0.5.tgz"},"main":"./dist/index.js","_from":"file:get-uri-6.0.5.tgz","types":"./dist/index.d.ts","engines":{"node":">= 14"},"scripts":{"lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs","test":"jest --env node --verbose --bail","build":"tsc"},"_npmUser":{"name":"tootallnate","actor":{"name":"tootallnate","type":"user","email":"nathan@tootallnate.net"},"email":"nathan@tootallnate.net"},"_resolved":"/tmp/6216b68e2f458b2bcd5c60e95501762f/get-uri-6.0.5.tgz","_integrity":"sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==","repository":{"url":"git+https://github.com/TooTallNate/proxy-agents.git","type":"git","directory":"packages/get-uri"},"_npmVersion":"10.8.2","description":"Returns a `stream.Readable` from a URI string","directories":{},"_nodeVersion":"20.19.2","dependencies":{"debug":"^4.3.4","basic-ftp":"^5.0.2","data-uri-to-buffer":"^6.0.2"},"_hasShrinkwrap":false,"devDependencies":{"st":"^3.0.0","ftpd":"https://files-jg1s1zt9l.n8.io/ftpd-v0.2.14.tgz","jest":"^29.5.0","ts-jest":"^29.1.0","tsconfig":"0.0.0","typescript":"^5.0.4","@types/ftpd":"^0.2.35","@types/jest":"^29.5.1","@types/node":"^14.18.45","@types/debug":"^4.1.7","async-listen":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/get-uri_6.0.5_1751910243487_0.7580027355292769","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":1751910243663,"_cnpm_publish_time":1751910243663,"dist-tags":{"latest":"8.0.2"}}