-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"}
-in your command promp type:
npm install param-handler
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!
Well its easy.
You can just use
ph.set("name_of_the_variable", "the_new_value")
You have two choises:
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".
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")}`)
console.log(`the fancy object ${ph.params}`)
console.log(`does name_of_the_variable exists?`)
console.log(ph.exists("name_of_the_variable")?"YES":"no :(")