Gathering detailed insights and metrics for get-uri
Gathering detailed insights and metrics for get-uri
Gathering detailed insights and metrics for get-uri
Gathering detailed insights and metrics for get-uri
npm install get-uri
Typescript
Module System
Min. Node Version
Node Version
NPM Version
pac-proxy-agent@7.2.0
Updated on Feb 18, 2025
agent-base@7.1.3
Updated on Dec 08, 2024
socks-proxy-agent@8.0.5
Updated on Dec 07, 2024
proxy-agent@6.5.0
Updated on Dec 07, 2024
pac-proxy-agent@7.1.0
Updated on Dec 07, 2024
https-proxy-agent@7.0.6
Updated on Dec 07, 2024
TypeScript (93.57%)
JavaScript (6.43%)
Total Downloads
1,611,058,924
Last Day
1,860,963
Last Week
11,482,063
Last Month
48,231,967
Last Year
483,626,011
1,037 Stars
298 Commits
254 Forks
19 Watchers
3 Branches
40 Contributors
Updated on May 09, 2025
Latest Version
6.0.4
Package Id
get-uri@6.0.4
Unpacked Size
43.11 kB
Size
12.81 kB
File Count
31
NPM Version
10.8.2
Node Version
20.18.1
Published on
Dec 03, 2024
Cumulative downloads
Total Downloads
3
stream.Readable
from a URI stringThis high-level module accepts a URI string and returns a Readable
stream
instance. There is built-in support for a variety of "protocols", and it's
easily extensible with more:
Protocol | Description | Example |
---|---|---|
data | Data URIs | data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D |
file | File URIs | file:///c:/windows/example.ini |
ftp | FTP URIs | ftp://ftp.kernel.org/pub/site/README |
http | HTTP URIs | http://www.example.com/path/to/name |
https | HTTPS URIs | https://www.example.com/path/to/name |
To simply get a stream.Readable
instance from a file:
URI, try something like:
1import { getUri } from 'get-uri'; 2 3// `file:` maps to a `fs.ReadStream` instance… 4const stream = await getUri('file:///Users/nrajlich/wat.json'); 5stream.pipe(process.stdout);
When you pass in a URI in which the resource referenced does not exist on the
destination server, then a NotFoundError
will be thrown. The code
of the
error instance is set to "ENOTFOUND"
, so you can check for that value
to detect when a bad filename is requested:
1try {
2 await getUri('http://example.com/resource.json');
3} catch (err) {
4 if (err.code === 'ENOTFOUND') {
5 // bad file path requested
6 } else {
7 // something else bad happened...
8 throw err;
9 }
10}
When calling getUri()
with the same URI multiple times, the get-uri
module
supports sending an indicator that the remote resource has not been modified
since the last time it has been retrieved from that node process.
To do this, define a cache
property on the "options object" argument
with the value set to the stream.Readable
instance that was previously
returned. If the remote resource has not been changed since the last call for
that same URI, then a NotModifiedError
instance will be thrown with its
code
property set to "ENOTMODIFIED"
.
When the "ENOTMODIFIED"
error occurs, then you can safely re-use the
results from the previous getUri()
call for that same URI:
1// First time fetches for real
2const stream = await getUri('http://example.com/resource.json');
3
4try {
5 // … some time later, if you need to get this same URI again, pass in the
6 // previous `stream.Readable` instance as `cache` option to potentially
7 // have an "ENOTMODIFIED" error thrown:
8 await getUri('http://example.com/resource.json', { cache: stream });
9} catch (err) {
10 if (err.code === 'ENOTMODIFIED') {
11 // source file has not been modified since last time it was requested,
12 // so you are expected to re-use results from a previous call to `getUri()`
13 } else {
14 // something else bad happened...
15 throw err;
16 }
17}
A uri
is required. An optional options
object may be passed in:
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 thrownAny other options passed in to the options
object will be passed through
to the low-level connection creation functions (http.get()
, ftp.connect()
,
etc).
Returns a stream.Readable
instance to read the resource at the given uri
.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 13/23 approved changesets -- score normalized to 5
Reason
3 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 4
Reason
8 existing vulnerabilities detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
11.2%
1,860,963
Compared to previous day
Last Week
7.7%
11,482,063
Compared to previous week
Last Month
-4.6%
48,231,967
Compared to previous month
Last Year
31.1%
483,626,011
Compared to previous year