npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

url-resolver-fs

v8.0.6

Published

resolves urls and provides fs like access

Downloads

181

Readme

npm License minified size downloads GitHub Issues Build Status codecov.io Coverage Status styled with prettier Commitizen friendly Known Vulnerabilities Greenkeeper semantic-release

url-resolver-fs

resolves urls and provides fs like access

API

Table of Contents

Resolver

Extends URLScheme

Holds a map of url-schemes and dispatches requests

Parameters

  • config Object (optional, default {})
  • predefinedConstructors Array<URLScheme> schemes to start with (optional, default [])
  • env Object environment variables as present in process.env (optional, default {})

Properties

registerScheme

Register a scheme for later lookup

Parameters

schemeForURL

Get URLScheme for a given url

Parameters

Returns URLScheme for a given url or undefined if nothing found

resolve

Resolve for a given url. Passes url to the registered scheme for remapping

Parameters

  • url URL to be resolved

Returns URL resolved url or original URL if no remapping found

createContext

Create a new context

Parameters

Returns Context newly created context

provideCredentials

Called when authorization is required. Forwards the request to the registered auth providers

Parameters

Returns Object credentials as given by one of the registered auth providers

Context

Holds context information

Parameters

Properties

base

Type: URL

resolve

Parameters

Returns URL

provideCredentials

Called when authorization is required for a given realm asks options.provideCredentials() and resolver.provideCredentials()

Parameters

  • realm Object requested (decoded) realm

Returns Promise<Object> credentials for the given realm

HTTPScheme

Extends URLScheme

URLScheme for http requests

Parameters

Properties

fetch

Parameters

Returns Promise fetch result

get

Execute a GET request

Parameters

Returns Promise body of the response

put

Execute a PUT request

Parameters

stat

Execute a HEAD request

Parameters

Returns Object response object

addAuthorizationHeader

inserts the authorization data into the reguest header

Parameters

  • headers Object http credentials will be inserted into
  • credentials Object

Returns boolean true if auth info has been written into headers

name

Returns string 'http'

defaultPort

Returns number 80 the http default port

optionsFromEnvironment

Extract options suitable for the constructor form the given set of environment variables

Parameters

Returns Object undefined if no suitable environment variables have been found

HTTPSScheme

Extends HTTPScheme

URLScheme for https requests

name

Returns string 'https'

defaultPort

Returns number 443 the https default port

isSecure

Returns boolean true

URLScheme

Parameters

Properties

name

Should be overwritten to reflect the scheme name

Returns string scheme name (defaults to the class name)

defaultPort

Returns number default from static defaultPort

isSecure

Returns boolean default from static isSecure

list

List collection (directory)

Parameters

Returns Promise resolves to iterable entries

get

Get content of a url

Parameters

Returns Promise resolves to the content

stat

Delivers meta information for a given url

Parameters

Returns Promise resolves to one entry

put

Put the content of a stream to a given url

Parameters

Returns Promise resolves if stream has ben put to the url

delete

Deletes object at a given url

Parameters

Returns Promise resolves to the history of the object at the given url

history

Deliver history information for a given url

Parameters

Returns Promise resolves to the history of the object at the given url

provideCredentials

Called when authorization is required for a given realm Tries provideCredentials() on the options object first and then calls provideCredentials() on the context.

Parameters

  • context Context execution context
  • realm Object requested (decoded) realm

Returns Promise<Object> holding the credentials

methods

supported methods

Returns Array<string> 'get', 'stat', 'put', 'delete', 'list', 'history'

isSecure

Returns boolean false

defaultPort

Returns mumber undefined by default

defaultOptions

Default configuration options

Returns Object

optionsFromEnvironment

Extract options suitable for the constructor form the given set of environment variables

Parameters

Returns Object undefined if no suitable environment variables have been found

options

Pepare configuration by mixing together defaultOptions with actual options

Parameters

Returns Object combined options

URLMapperScheme

Extends URLScheme

Remap url special:some/path -> https://myserver.com/repo/some/path name: special baseScheme: https prefix: https://myserver.com/repo/

Parameters

  • baseScheme URLScheme
  • name string of the newly created scheme
  • prefix string urls will be prefixed by this value
  • options

Properties

  • baseScheme URLScheme
  • name string of the newly created scheme
  • prefix string urls will be prefixed by this value

remap

Remapps url by separating scheme (and direct following '/') from suffix and appending the suffix (in front)

Parameters

  • url URL to be remapped

Returns URL remapped url

parseAuthenticate

  • See: rfc7235

Parse WWW-Authenticate header and provide parts as object. provides a two level structure 1st. the algorithm and then the algorithm attributes

Parameters

  • source string http header 'WWW-Authenticate'
  • result Object where to put result into (optional, default {})

Returns Object same as result

ResponseError

Extends Error

general fetch response error

install

With npm do:

npm install url-resolver-fs

license

BSD-2-Clause