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

url-query-manager

v1.0.3

Published

Helper for managing url params from different application modules separately and safe

Downloads

8

Readme

URL-QUERY-MANAGER

An npm package that provides a safe and efficient solution for manipulating URL query parameters from different app modules separately. Designed to prevent query parameter conflicts and ensure the integrity of your data. Allows to easily add, update, or remove query parameters without worrying about unexpected results or unintended consequences.

url-query-manager built with a focus on safety and security, making it a reliable choice for any project that requires URL query parameter manipulation. With its intuitive API, it is easy to use and can be integrated seamlessly into your existing codebase.

Features:

  • Safe manipulation of URL query parameters from different app modules
  • Prevention of query parameter conflicts (automatically applied prefix)
  • Efficient addition, update, or removal of query parameters
  • Intuitive and easy-to-use API

Installation

npm install url-query-manager

Usage

The package exports UrlQueryManager class, which provides a general API for the package through static methods. When the object is instantiated, it provides an API for connection the application module and the parameters storage.

Inside the module, there is a shared property that stores module data and parameters, so no additional initialization is needed in the app to start using the package.

Example

import UrlQueryManager from 'url-query-manager';

// create a manager object for the module
const module = new UrlQueryManager('page');
// push some params
module.push({page_id: 'home'});
// apply params to URL...
UrlQueryManager.applyQuery();
// ...OR get the query to apply with any other way (some custom router for example)
UrlQueryManager.getQueryString();

examples folder contains some simple apps that uses this package To see it in action go to the specific example folder, install deps with npm i, run the app npm run start

API

UrlQueryManager constructor params

| Name | Type | Description | |---------------------|----------|-------------------------------------------------------------------------------------------------------------------------| | name | string | Represents module name. | | usePrefix | boolean| If true, the module name will be applied as a prefix to module parameters with an underscore (e.g., name: page; params: id; -> page_id). |

UrlQueryManager instance properties

| Name | Type | Description | |---------------|----------|----------------------------------------------------------------------------------------------------| | name | string | Module name. | | deleted | boolean| Returns true if the module was destroyed (by .destroy() method). |

UrlQueryManager static methods

| Name | Description | |---------------------------|-----------------------------------------------------------------------------------------------------| | getAllQueryParams() | Returns all params from all modules (with applied prefix if module has it). | | getQueryString() | Returns query string with applied params from all modules (with applied prefix if module has it). | | getModulesList() | Returns list of all modules names. | | applyQuery() | Applies query string through window.history.pushState. |

UrlQueryManager instance methods

| Name | Description | |--------------------------|--------------------------------------------------------------------------------------------------| | isParamAvailable(key)| Checks for availability (no conflict with other modules params) of specific param by name. key - param key. | | push(params) | Pushes params to module params collection (overwrites all previous params in the module). params - object with query params where key is param name, and value is param value. | | getQueryParams() | Returns params applied to the module. | | destroy() | Destroying module (removing all the module params and prevents from future updates). |