Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
parameller
Advanced tools
Readme
Parameller makes parsing url query strings in JS simple.
Parameller is easy to install, simply run:
yarn add parameller
or
npm install parameller
Simply import the functions you wish to use in your project as follows:
import { getParam, getParams, removeParam, setParam, setParams, toQueryString, pushParam, pushParams, popParams } from "parameller";
type Params = { [s: string]: string }
const obj = {
"test": "example",
"name": "Samuel"
}
toQueryString(obj)
Output: test=example&name=Samuel
If the base property is set then it will prepend the base onto the query string.
Example url: http://test.com/?test=hello&example=wow
getParam("test") // returns "hello"
getParam("example") // returns "wow"
getParam("something") // returns undefined
getParam()
takes an optional callback that is only called if the parameter returns a value.
getParam("test", value => {
console.log(value) // logs "Hello"
})
Example url: http://test.com/?test=hello&example=wow
getParams() // returns { test: "hello", example: "wow" }
The following methods will replace the currently url state, history will not be preserved.
Example url: http://test.com/?test=hello&example=wow
setParam("test", "goodbye")
Output: http://test.com/?test=goodbye&example=wow
Example url: http://test.com/?test=hello&example=wow
setParams({ test: "goodbye" })
Output: http://test.com/?test=goodbye
Example url: http://test.com/?test=hello&example=wow
removeParam("test")
Output: http://test.com/?example=wow
The following methods will push the state onto the browser history stack, useful if you want to maintain back/forwards functionality.
Example url: http://test.com/?test=hello&example=wow
pushParam("test", "goodbye")
Output: http://test.com/?test=goodbye&example=wow
Example url: http://test.com/?test=hello&example=wow
pushParams({ test: "goodbye" })
Output: http://test.com/?test=goodbye
Example url: http://test.com/?test=hello&example=wow
popParam("test")
Output: http://test.com/?example=wow
FAQs
Easily parse, edit and add url query paramaters with JS, has TypeScript support
The npm package parameller receives a total of 124 weekly downloads. As such, parameller popularity was classified as not popular.
We found that parameller demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.