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

easy-code-url

v1.0.6

Published

encodeURIComponent decodeURIComponent

Downloads

21

Readme

easy-code-url

为便利浏览器传参转换而设立。

设计思路:####

1.可将JSON对象直接转换成传参地址拼接字符,默认拼接符号"&"可设置新符号 2.可将地址与参数便捷的组合成传参地址,通过设置可启用encodeURIComponent对拼接后的地址进行安全符处理,也可通过携带参数的地址或者安全符地址,便捷的将参数转换为JSON对象 3.传参分割符号"?"可设置

install

npm安装命令

npm install --save easy-code-url

Usage

引入包

import ECU from "easy-code-url"

范例

import easyCodeURL from "easy-code-url";
//全局设置
easyCodeURL.setConfig({break:"?",jpin:"&",encode:true});
//获取全局设置
easyCodeURL.getConfig();
//拼装Data
let data={
    name:"MOD",
    age:12,
    gender:"male",
    hobby:["videogame","tree",{new:"keep"}],
}
var strData = easyCodeURL.encodeData(data)
console.log(strData);
console.log(easyCodeURL.decodeData(strData))
var URL = easyCodeURL.encodeURL("www.baidu.com",data,{encode:true})
var URL2 = easyCodeURL.encodeURL("www.baidu.com",data,{encode:false})
console.log(URL,URL2);
console.log(easyCodeURL.decodeURL(URL,{encode:true}))
var sss = easyCodeURL.decodeURL(URL,{encode:true});
console.log(sss);

//通过以上输出测试,可看到具体的使用方式与结果

API

setConfig(config)

设置全局配置参数 config:{ break:String,// 地址与参数分割符号,默认为"?"; join:String,// 参数拼接符 默认"&" encode:Boolean,//是否将拼接后的地址进行 encodeURIComponent 编码 ,默认true }

getConfig()

获取全局配置参数 return config

encodeURL(baseURL,data,config)

将地址拼接参数 baseURL:String,//需要拼接参数的地址 data:JSON Object,//参数JSON格式 config:Object,//同全局配置属性,可每次调用该方法时,灵活设置,如空则默认全局配置。

easyCodeURL.encodeURL('www.baiduc.com',{name:"foo",age:"22"},{break:"?",join:"!",encode:false});

decodeURL(locationURL,config)

可将携参地址的参数解析成对象 locationURL:String,//携参地址 config:Object,//同全局配置属性,可每次调用该方法时,灵活设置,如空则默认全局配置方式进行解析。

easyCodeURL.decodeURL('www.baiduc.com',{break:"?",join:"!",encode:false});