{"name":"get-uri","version":"6.0.4","description":"Returns a `stream.Readable` from a URI string","main":"./dist/index.js","types":"./dist/index.d.ts","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/jest":"^29.5.1","@types/node":"^14.18.45","async-listen":"^3.0.0","ftpd":"https://files-jg1s1zt9l.n8.io/ftpd-v0.2.14.tgz","jest":"^29.5.0","st":"^3.0.0","ts-jest":"^29.1.0","typescript":"^5.0.4","tsconfig":"0.0.0"},"dependencies":{"basic-ftp":"^5.0.2","data-uri-to-buffer":"^6.0.2","debug":"^4.3.4"},"engines":{"node":">= 14"},"scripts":{"build":"tsc","test":"jest --env node --verbose --bail","lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs"},"_id":"get-uri@6.0.4","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"homepage":"https://github.com/TooTallNate/proxy-agents#readme","_integrity":"sha512-E1b1lFFLvLgak2whF2xDBcOy6NLVGZBqqjJjsIhvopKfWWEi64pLVTWWehV8KlLerZkfNTA95sTe2OdJKm1OzQ==","_resolved":"/tmp/71a9234f5a108c19761364602a4f0f7f/get-uri-6.0.4.tgz","_from":"file:get-uri-6.0.4.tgz","_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-E1b1lFFLvLgak2whF2xDBcOy6NLVGZBqqjJjsIhvopKfWWEi64pLVTWWehV8KlLerZkfNTA95sTe2OdJKm1OzQ==","shasum":"6daaee9e12f9759e19e55ba313956883ef50e0a7","tarball":"http://registry-npm.ywwl.com/get-uri/download/get-uri-6.0.4.tgz","fileCount":31,"unpackedSize":44148,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/OVH4OmqSkV297IUAPDyZ6L2InOeZEq6gCh8K2t0FowIgQs/sA8lCINc9KMuT3GpJok4YqQWK5bxeOKAhykTTG68="}],"size":13114,"noattachment":false,"key":"/get-uri/-/get-uri-6.0.4.tgz"},"_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/get-uri_6.0.4_1733268692288_0.5559644320227335"},"_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":1733268692556,"maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"_cnpm_publish_time":1733268692556,"dist-tags":{"latest":"8.0.2"}}