• Version 6.0.3
  • Published
  • 44.3 kB
  • 4 dependencies
  • MIT license


npm i get-uri
yarn add get-uri
pnpm add get-uri


Returns a `stream.Readable` from a URI string



variable protocols

const protocols: {
data: GetUriProtocol<import('./data').DataOptions>;
file: GetUriProtocol<import('./file').FileOptions>;
ftp: GetUriProtocol<import('./ftp').FTPOptions>;
http: GetUriProtocol<import('./http').HttpOptions>;
https: GetUriProtocol<import('./http').HttpOptions>;


    function getUri

    getUri: <Uri extends string>(
    uri: Uri | URL,
    opts?: ProtocolOpts<Uri>
    ) => Promise<Readable>;
    • Async function that returns a stream.Readable instance that will output the contents of the given URI.

      For caching purposes, you can pass in a stream instance from a previous getUri() call as a cache: stream option, and if the destination has not changed since the last time the endpoint was retreived then the callback will be invoked with an Error object with code set to "ENOTMODIFIED" and null for the "stream" instance argument. In this case, you can skip retreiving the file again and continue to use the previous payload.

      Parameter uri

      URI to retrieve

      Parameter opts

      optional "options" object public

    function isValidProtocol

    isValidProtocol: (p: string) => p is 'data' | 'file' | 'ftp' | 'http' | 'https';

      Type Aliases

      type GetUriProtocol

      type GetUriProtocol<T> = (parsed: URL, opts?: T) => Promise<Readable>;

        type ProtocolOpts

        type ProtocolOpts<T> = {
        [P in keyof ProtocolsOptions]: Protocol<T> extends P
        ? ProtocolsOptions[P]
        : never;
        }[keyof Protocols];

          type Protocols

          type Protocols = typeof protocols;

            type ProtocolsOptions

            type ProtocolsOptions = {
            [P in keyof Protocols]: NonNullable<Parameters<Protocols[P]>[1]>;

              Package Files (1)

              Dependencies (4)

              Dev Dependencies (12)

              Peer Dependencies (0)

              No peer dependencies.


              To add a badge like this badgeto your package's README, use the codes available below.

              You may also use to create a custom badge linking to

              • Markdown
              • HTML
                <a href=""><img src="" alt=""></a>