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

dawuti-ts-utils

v0.4.9

Published

Dawuti is a package with different utils implemented by Workoholics development team. Here you can find individual utilities to resolve common funcionalities for different languages or technologies (Sass, JS, TS...).

Readme

Dawuti

Dawuti is a package with different utils implemented by Workoholics development team. Here you can find individual utilities to resolve common funcionalities for different languages or technologies (Sass, JS, TS...).

Dawuti TS Utils

This library, developed by Workoholics, provides a collection of TypeScript utilities designed to tackle common tasks in our projects. Each method is standalone, ensuring flexibility and ease of use.

Dawuti TS Utils is organized by use cases. For instance, all functionalities related to the DOM are grouped under the domUtils namespace and implemented in the dom.utils.ts file.

[[TOC]]

Develop (Only WKHS DevTeam)

If you'd like to contribute, develop, or publish a new utility, detailed instructions are available in the repository's Wiki.

Installation NPM

Dawuti is an npm package available on the public npm registry (https://www.npmjs.com/). You can install the package by running the following command:

npm i dawuti-ts-utils

Usage

To use a specific functionality from the library, you can either import it individually or access it through the appropriate namespace.

Individually

import { slugify } from "dawuti-ts-utils";

const title = "Este es el título del post";
const slug = slugify(title);

Namespace

import { urlUtils } from "dawuti-ts-utils";

const title = "Este es el título del post";
const slug = urlUtils.slugify(title);

URL Utils

Utilities for handling URL-related tasks, such as parsing, formatting, and generating URLs with ease.

slugify

The slugify method takes a string and converts it into a URL-friendly "slug."

import { slugify } from "dawuti-ts-utils";

const title = "Este es el título del post";
const slug = slugify(title);

DOM Utils

The DOM Utils section is designed to house methods that simplify and solve common tasks related to working with the Document Object Model (DOM). These utilities provide convenient, reusable functions to manipulate, query, or interact with DOM elements, streamlining front-end development and improving code maintainability.

classList

The classList method generates a single string of class names based on a provided object and an optional string. It is designed to simplify the dynamic assignment of CSS classes in your application. Here's how it works:

Parameters:

  • classes (object): A key-value pair where keys represent class names, and values are booleans. If the value is true, the corresponding class name will be included in the final string.
  • stringClasses (optional string): A string of additional class names to append to the final result.

How it Works:

Iterates over the classes object to include class names where the value is true. Combines the filtered class names with any additional classes provided in stringClasses. Ensures the resulting string is clean by trimming unnecessary whitespace or leading spaces.

Returns:

A single, trimmed string containing all valid class names, ready to be used in a className attribute.

Example (TypeScript)

import { classList } from "dawuti-ts-utils";

const isPrimary = true;
const isWrapper = false;
const bg = 'dark';

const classes = classList({
    'hero': true,
    'hero--primary': isPrimary,
    'hero--wrapped': isWrapped,
    [`hero--background-${bg}`]
}, 'extra-class')

console.log(classes);

// Output: 'hero hero--primary hero--background-dark extra-class'

Example (React)

import { classList } from "dawuti-ts-utils";

const Comp = ({isPrimary, isWrapper, bg}: {isPrimary: boolean; isWrapped: boolean; bg: 'light' | 'dark'}) => {

    const classes

    return (
        <header className={
            classList({
                'hero': true,
                'hero--primary': isPrimary,
                'hero--wrapped': isWrapped,
                [`hero--background-${bg}`]
            },'extra-class')
        }>
            <h1>Hero</h1>
        </header>
    )
}

Scroll Utils

This module provides utility functions for handling various scrolling behaviors in a webpage.

getScrollPosition(scrollElement?: HTMLElement | Window): { x: number; y: number }

Retrieves the current scroll position of the given element or window.

Parameters:

  • scrollElement (optional): The element or window to get the scroll position from (defaults to window).

Returns:

  • An object containing:
    • x: Horizontal scroll position.
    • y: Vertical scroll position.

Example:

import { getScrollPosition } from "dawuti-ts-utils";

const position = getScrollPosition();
console.log(position.x, position.y);

scrollToElement(element: HTMLElement, offset?: number, behavior?: ScrollBehavior, scrollElement?: HTMLElement | Window)

Scrolls the page or a specific scroll container to a given element.

Parameters:

  • element: The target element to scroll to.
  • offset (optional, default: 0): Additional offset from the top.
  • behavior (optional, default: "smooth"): Scroll behavior ("auto", "smooth", "instant").
  • scrollElement (optional, default: window): The scroll container.

Example:

import { scrollToElement } from "dawuti-ts-utils";

scrollToElement(document.getElementById("target"), 50, "smooth");

isScrollingDown(scrollElement?: HTMLElement | Window, lastScrollTop: number): { scrollingDown: boolean; lastScrollTop: number }

Checks if the user is currently scrolling down.

Parameters:

  • scrollElement (optional): The element or window to track scrolling (defaults to window).
  • lastScrollTop: The last known scroll position.

Returns:

  • An object containing:
    • scrollingDown: Boolean indicating whether scrolling is downward.
    • lastScrollTop: The updated scroll position.

Example:

import { isScrollingDown } from "dawuti-ts-utils";

let lastScrollTop = 0;
window.addEventListener("scroll", () => {
  const { scrollingDown, lastScrollTop: newScrollTop } = isScrollingDown(
    window,
    lastScrollTop
  );
  console.log(scrollingDown ? "Scrolling Down" : "Scrolling Up");
  lastScrollTop = newScrollTop;
});

getScrollProgress(scrollElement?: HTMLElement | Window): number

Calculates the scroll progress as a percentage.

Parameters:

  • scrollElement (optional): The element or window to track scrolling (defaults to window).

Returns:

  • A number representing the scroll progress percentage (0 to 100).

Example:

import { getScrollProgress } from "dawuti-ts-utils";

window.addEventListener("scroll", () => {
  console.log(`Scroll Progress: ${getScrollProgress()}%`);
});

Agent Utils

getBrowserAgent(): BrowserAgent

Detects the user's browser based on the navigator.userAgent string.

Returns:

  • A string representing the browser type, which can be one of the following: "safari", "firefox", "chrome", "edge", "opera", "ie", "unknown"

Example:

import { getBrowserAgent } from "dawuti-ts-utils";

const browser = getBrowserAgent();
console.log(`You are using: ${browser}`);

Count utils

startCounter(target: number, duration: number, setCount: (updateFn: (prev: number) => number) => void): number

Animates a counter from 0 to target over a specified duration.

Parameters:

  • target: The final count value.
  • duration: Duration in milliseconds for the count animation.
  • setCount: A function that updates the counter value.

Returns:

  • The interval ID, which can be used to clear the interval if needed.

Example (React):

const [count, setCount] = useState(0);
const interval = startCounter(100, 2000, setCount);

Example (TypeScript):

import { startCounter } from "dawuti-ts-utils";

let count = 0;

const setCount = (updateFn: (prev: number) => number) => {
  count = updateFn(count);
  console.log(Math.floor(count));
};

startCounter(100, 2000, setCount);

Date Utils

🚧 Under construction 🚧

Format Utils

🚧 Under construction 🚧