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

@warren-bank/url

v3.2.1

Published

URL class library that does not perform any encoding or decoding

Downloads

139

Readme

jsURL

Javascript drop-in replacement URL class library for Node.js and the browser.

The important difference is that this library does not perform any encoding or decoding. Further reading: 1

Class Import

  • in Node.js:

      npm install --save @warren-bank/url
      const {URL, parse} = require('@warren-bank/url')
    
      {
        const gh = new URL('https://github.com/warren-bank')
        const qs = gh.searchParams
    
        gh.username = 'user'
        gh.password = 'pass'
        gh.port     = 443
        gh.hash     = '#language-options'
    
        qs.set('tab', 'repositories')
    
        console.log('URL.href = '         + gh.href)
        console.log('parse(URL.href) = '  + JSON.stringify(parse(gh.href),  null, 2))
        console.log('parse(URL) = '       + JSON.stringify(parse(gh),       null, 2))
        console.log('parse(URL, true) = ' + JSON.stringify(parse(gh, true), null, 2))
      }
  • in the browser:

      <html>
      <head>
        <script src="https://cdn.jsdelivr.net/gh/warren-bank/js-url/es5-browser/jsURL.js"></script>
        <script>
          {
            // temporarily override global URL class with external implementation within scope of block
            const {URL, parse} = window.jsURL
    
            const gh = new URL('https://github.com/warren-bank')
            const qs = gh.searchParams
    
            gh.username = 'user'
            gh.password = 'pass'
            gh.port     = 443
            gh.hash     = '#language-options'
    
            qs.set('tab', 'repositories')
    
            window.alert('URL.href = '         + gh.href)
            window.alert('parse(URL.href) = '  + JSON.stringify(parse(gh.href),  null, 2))
            window.alert('parse(URL) = '       + JSON.stringify(parse(gh),       null, 2))
            window.alert('parse(URL, true) = ' + JSON.stringify(parse(gh, true), null, 2))
          }
    
          {
            const {parse, format} = window.jsURL
    
            const run_test_1 = () => {
              const url_1 = format({
                protocol: 'https:',
                hostname: 'example.com',
                port: 80,
                pathname: '/some/path',
                search: 'page=1&format=json'
              })
    
              const url_2 = format({
                protocol: 'https',
                host: 'example.com:80',
                pathname: 'some/path',
                query: {
                  page: 1,
                  format: 'json'
                }
              })
    
              const is_equal = (url_1 === url_2)
    
              window.alert(
                JSON.stringify({url_1, url_2, is_equal}, null, 2)
              )
            }
    
            const run_test_2 = (url_1) => {
              const urlObject = parse(url_1)
              const url_2     = format(urlObject)
    
              const is_equal = (url_1 === url_2)
    
              window.alert(
                JSON.stringify({url_1, url_2, is_equal}, null, 2)
              )
            }
    
            run_test_1()
            run_test_2('http://login:[email protected]:80/demo/example.cgi?lang=de&foo=bar#position')
          }
        </script>
      </head>
      </html>

Limitations

The following methods are not implemented:


Requirements:

Legal