Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

param-handler

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

param-handler

this is a library that allowes you to control query params location search

  • 1.1.52
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

The point of this project?

-it also allows you to change it without reloading the page. useful for virtual doms like (react, svelte, angular .. etc).

-it has callback when each variable changes (you have to use the same package for it to work).

-made with typescript!.

-it can return an object with these variable instead of a boaring string, for example: "?a=5&b=dad" => {a:5,b:"dad"}

How can i use this?

How to install:

Using npm:

-in your command promp type:

npm install param-handler

How can i test it:

Major Update changed the class name:

Its easy, you will need jsdom if you don't have a dom(plain nodejs),

first of all you need to import the package:

const _PH = require("param-handler"), 
    {PH} = require("param-handler") 
// or
import _PH, {PH} from "param-handler" 

// _PH and PH are the same thing

Then

let ph = new PH(window) // pass the window from the virtual dom

Then you can start using it!

How can i update a specific variable in the query search location:

Well its easy.

You can just use

ph.set("name_of_the_variable", "the_new_value")

How can i read a specific variable from the query search location:

You have two choises:

1- keep track of the changes of a specific variable:

ph.on("change", "name_of_the_variable", (new_value)=>{
    console.log(`name_of_the_variable has changed to ${new_value}!`)
})

note that you can use the second argument inside the callbackfunction to call "this".

2- Or you can just get the value of that specific variable:

ph.get("name_of_the_variable", "default_value", "reverse_if_boolean")

console.log(`
    name_of_the_variable has the value of 
    ${ph.get("name_of_the_variable")}`)

How can i get that fancy object thingy:

console.log(`the fancy object ${ph.params}`)

How can i check if a variable exists:

console.log(`does name_of_the_variable exists?`)

console.log(ph.exists("name_of_the_variable")?"YES":"no :(")

Keywords

FAQs

Package last updated on 05 Jun 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc