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-lib

v3.0.3

Published

A simple, lightweight string utility for Node and browsers that supports serializing and parsing URLs and query strings.

Downloads

7,604

Readme

url-lib

version downloads module formats: esm & cjs semantic-release license

Maintenance Status Build Status Tested with jest Coverage Status Dependencies status Dev Dependencies status Greenkeeper badge PRs Welcome

Watch on GitHub Star on GitHub Tweet

A simple, lightweight string utility for Node and browsers that supports serializing and parsing URLs and query strings.

The primary use case is for building string URLs with query parameters for the Fetch API that is polyfilled in the browser via fetch and in Node via node-fetch libraries. isomorphic-fetch combines the two.

url-lib is derived from the Uize.Url module that is a part of the open-source UIZE JavaScript Framework. It is stable, dependency-free, heavily-tested and well-documented.

Installation

Install via npm:

npm install --save url-lib

Install via Yarn:

yarn add url-lib

Use with Node, webpack or browserify:

import * as urllib from 'url-lib'; // ES6+
var urllib = require('url-lib'); // ES5-

Usage

import {formatUrl} from 'url-lib'

const url = formatUrl('http://www.benmvp.com/search?sort=recent&results=20&pg=1', {
    sort: 'popular',        // overwrites existing `sort` param in URL
    category: 'holiday',
    type: 'all',
    results: 100,            // overwrites existing `results` param in URL
})

With the above code, url will be 'http://www.benmvp.com/search?sort=popular&results=100&pg=1&category=holiday&type=all'

Check out the docs for more usage examples or try out url-lib in your browser!

API Docs

  • formatQuery - Serializes the properties of a params object to produce a URL query string.
  • formatUrl - Serializes the specified URL path with properties of a params object to produce a URL.
  • parseQuery - Parses query parameters from a string, returning the query parameters as an object.
  • getCacheDefeatStr - Returns a string value (generated using the time and a random number) that can be used as a query parameter value to cause a URL to be unique in order to defeat caching.
  • parseUrl - Parses the specified URL string into an object containing properties for the various logical segments.

Contributing

Contributions are welcome! See CONTRIBUTING for more details.

Project philosophy

We take the stability of this utility package very seriously. url-lib follows the SemVer standard for versioning.

All updates must pass the CI build while maintaining 100% code coverage.

License

MIT. Copyright (c) 2016- Ben Ilegbodu.