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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@alexsab-ru/scripts

v0.17.0

Published

common libs for websites

Readme

@alexsab-ru/scripts

Русский

common libs for websites

Installation

pnpm i @alexsab-ru/scripts

Analytics module

reachGoal and pageView functions push to dataLayer some data with goal name

reachGoal("goalName");
pageView(goalName);

In GTM you can use them for send goals to your analytic system

{
	event: "reachGoal-goalName",
	eventAction: "goalName"
}

Use example:

import { reachGoal } from '@alexsab-ru/scripts';

// automatic assign from module
reachGoal("phone_click");
reachGoal("phone_copy");
reachGoal("phone_contextmenu");
reachGoal("email_click");
reachGoal("email_copy");
reachGoal("email_contextmenu");

For form's analytics you may use these goals

reachGoal("form_open");
reachGoal("form_click"); // automatic assign from module
reachGoal("form_change"); // automatic assign from module
reachGoal("form_submit");
reachGoal("form_required");
reachGoal("form_error");
reachGoal("form_success");
reachGoal("form_attention");

getFormDataObject is needed for Calltouch request tag.

import { getFormDataObject } from '@alexsab-ru/scripts';

document.querySelectorAll("form").forEach((form) => {
	form.onsubmit = async (event) => {

		var formData = new FormData(form);
		// ...
		var formDataObj = getFormDataObject(formData, form.id);

		await fetch("https://example.com/api/lead/", {
			// ...
		})
			.then((res) => res.json())
			.then((data) => {
				if (data.answer == "required") {
					reachGoal("form_required");
					return;
				} else if (data.answer == "error") {
					reachGoal("form_error");
					return;
				} else {
					if (data.attention === true) {
						reachGoal("form_attention");
					} else {
						reachGoal("form_success", formDataObj);
					}
				}
				form.reset();
			})
			.catch((error) => {
				reachGoal("form_error");
			});
	};
});

Goals can be achieved as follows

Interaction with the form

  • form_open – opened the form
  • form_click – clicked on the form
  • form_change – changes in the form
  • form_submit – pressed the Submit button
  • form_required – incomplete form filling
  • form_error – error, data did not send for some reason
  • form_success – received a positive response from the server, i.e., data was sent
  • form_attention – server flagged the submission as suspicious (antispam), success goal is skipped
  • form_close – closed the form

Interaction with the phone

  • phone_click — clicked on it with the mouse
  • phone_contextmenu — opening the context menu on it with the right mouse button
  • phone_copy — copying the selected text

If there is a clickable email on the page, goals will be triggered on it

  • email_click — clicked on it with the mouse
  • email_contextmenu — opening the context menu on it with the right mouse button
  • email_copy — copying the selected text

Cookie module

import { getCookie, setCookie, deleteCookie, cookiecook } from './cookie';

getCookie('cookie_name');
setCookie('cookie_name');
deleteCookie('cookie_name');
cookiecook(days);

Calltouch module

import { createRequest } from '@alexsab-ru/scripts';

// Sending a callback request to CallTouch
createRequest("ct_callback", "+7 (987) 654-32-10");

// to display the log, the third parameter must be used
createRequest("ct_callback", "+7 (987) 654-32-10", true);

Form module

import { connectForms, cookiecook } from '@alexsab-ru/scripts';

cookiecook();
connectForms('https://alexsab.ru/lead/test/', function() {
	console.log("sucess lead");
});