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

@irmmr/hash.js

v1.7.8

Published

A simple and flexible JavaScript library that manages "window.location.hash". With the ability to support queries. (#value?query)

Downloads

120

Readme

Hash.js

It is better to use version 1.7.0 and above. Lower versions are not recommended at all.

Hash.js is a simple and flexible javascript library that manages the location.hash page. To change, add, set, check, get the hash value or query you can use this library. The page hash is a combination of 2 parts, "value" and "query". This value is set as follows: #value?query.

Install

You can install this package with ‍‍npm and use it.

npm install @irmmr/hash.js

Or use the built-in version of this library separately.

<script src="path/to/dist/hash.min.js"></script>

You can also use with: jsdelivr:

<script src="https://cdn.jsdelivr.net/npm/@irmmr/hash.js"></script>

Document

The document contains all the components included in the package.

view document ->

Test

You can test this library in the browser online. view ->

Otherwise, you must use the following commands to test the items:

# install test packages
npm run start

# test last published version
npm test

# test last changed file
npm test -- --dev

Structure

The components of this library are divided into 3 main sections, which include main, value and query. query itself includes the (str)string section so that query items can be implemented as a string.

import Hash from "@irmmr/hash.js";

// use Hash.js information
// Object { version: "1.7.5", name: "HashJs", module: "Hash" }
Hash.info();

// use Hash.js event
Hash.on(listener, (e, i) => {
  //...
});

Main: Items for general hash management. value?query

// set example
// => #string-for-me
Hash.set("string-for-me");

// replace example
// => #stringforme
Hash.replace(/-/g, "");

Value: Items for value hash management. value?query

// Hash.v == Hash.value
// set example
Hash.v.set("new-value");

// get example
console.log(Hash.value.get());

Query: Items for query hash management. value?query (objective)

// Hash.q == Hash.query
// set example
Hash.q.set("query-name", "query-val");

// get example
console.log(Hash.query.get("query-name"));

Query str: Items for query hash management as string. value?query (string)

// add example
Hash.q.str.add("q=v", "after:g");

// get example
console.log(Hash.q.str.get());

How to use?

These include a few simple examples.

Use it !

// set a value to location.hash (main component)
Hash.set("hello-babe"); // page's hash => '#hello-babe'

// get location.hash            (main component)
Hash.get(); // returns => 'hello-babe'

// set new value                (value component)
Hash.v.set("hey-value"); // page's hash => '#hey-value'

// set 'page' query             (query component)
Hash.q.set("page", 1); // page's hash => '#hey-value?page=1'

// set 'e' query                (query string component)
Hash.q.str.set("ev=12"); // page's hash => '#hey-value?ev=12'

ready() one-line usage

// #data-type?name=J
Hash.ready()?.set("data-type").q.set("name", "J");