Giter Site home page Giter Site logo

urls-tool's Introduction

urls-tool

A little script that will help you work with the url path / params / hash without reloading the page.

Installing

Using npm:

$ npm install urls-tool

Using yarn:

$ yarn add urls-tool

Example

Easily get or change url pathname.

import Url from "urls-tool";

const { pathname } = Url;
// Variable `pathname` will be have the pathname value in string.

Url.pathname = "your path name";
// Pathname will be changed.

Effortlessly get or set (just one or all at once) params

import Url from "urls-tool";

const { params } = Url;
// Variable `params` will be have the object with all params in shape `{ "paramsName": "paramsValue" }`.

const {
  array, // Array of all params. [{ name: "paramsName", value: "paramsValue" }]
  object, // The same object as in the previous method 
  string // String of params without "?".
} = Url.getParams();

Url.params = ["paramsName", "paramsValue"];
// Use to set only one params item. Also it will be removed in the absence or FALSE value of "paramsValue".

Url.params = { "paramsName": "paramsValue" };
// Use to set all params at once. All params will be cleared in case of an empty object.

No problem get or set the hash

import Url from "urls-tool";

const { hash } = Url;
// Variable `hash` will be have the hash value in string without "#".

Url.pathname = "your path name";
// Hash will be changed. And you don't need to add "#"

License

ISC

urls-tool's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.