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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-uri

v0.1.8

Published

simple uri manipulation tool

Readme

uri

Simple uri manipulation tool

Uri(String uri)

创建一个Uri

var u = new Uri("http://example.com:5000/user?name=alex&age=10");

u.protocol // http
u.host // example.com
u.pathname // /user
u.query // name=alex&age=10
u.port // 5000

如果不传入uri参数,则以当前的访问路径为准,例如我在浏览器中的访问路径为 https://google.com/search

var u = new Uri();
u.str(); // https://google.com/search

Methods 方法

setParams(Object obj)

设置参数

var u = new Uri("http://example.com?name=alex");
u.setParams({'name': 'mary'}).str() //http://example.com?name=mary
u.setParams({ 'email': '[email protected]', 'sex': 'female' }).str(); // http://example.com?name=mary&[email protected]&sex=female

removeParams(Array keys)

移除参数

let u = new Uri("http://example.com/api?a=1&b=2&c=3&d=4");
u.removeParams(['a', 'c']).str(); //http://example.com/api?b=2&d=4

path(String pathname)

修改path , 使用绝对路径和相对路径都可以

var u = new Uri("http://example.com/index");
u.path('/new/path').str(); // http://example.com/new/path
u.path('../test').str();   // http://example.com/new/test

str()

生成uri字符串

Uri.config(Object options) static

全局配置

通过配置params, 可以让每个连接都带上这些配置好的全局参数

Uri.config({
    params: {
        "company": "ex"
    }
});

var u = new Uri("http://example.com");
u.str(); //http://example.com?company=ex;

Release

  • 0.1.6 2016-01-07 Polyfill Object.assign
  • 0.1.5 2016-01-06 remove extend dependency and update document.
  • 0.1.4 2016-01-05 1. change api params to setParams 2. params use to get query params;
  • 0.1.3 2016-01-04 bugfix module problem
  • 0.1.2 2016-01-04 bugfix import problem
  • 0.1.1 2016-01-04 umd
  • 0.1.0 2016-01-04 initial version