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

@nivinjoseph/n-util

v3.2.0

Published

Utility functions

Readme

n-util

A comprehensive collection of utility functions and decorators for TypeScript/JavaScript applications. This package provides a robust set of utilities for handling asynchronous operations, type conversions, method decorators, and more.

Features

Core Utilities

  • Make - Collection of essential utility functions
    • Retry logic with configurable attempts
    • Async/sync operation conversion
    • Error handling utilities
    • Random value generation

Type System

  • TypeHelper - Type conversion and validation
    • Boolean parsing with strict validation
    • Number parsing with type safety
    • Enum type conversion to tuples
    • Type safety assertions
  • Utility Types - Common TypeScript utility types
    • Type transformations
    • Conditional types
    • Type guards

Date and Time

  • DateTime - Date and time manipulation
    • Date parsing and formatting
    • Time zone handling
    • Date arithmetic
  • Duration - Time duration handling
    • Duration creation and conversion
    • Time unit manipulation
    • Duration arithmetic
  • Time - Time-specific utilities
    • Time parsing and formatting
    • Time zone conversions
    • Time comparisons

Method Decorators

  • Method Decorators - Collection of method decorators
    • @debounce - Prevents rapid-fire method calls
    • @dedupe - Ensures single execution within time window
    • @synchronize - Prevents concurrent execution
    • @throttle - Limits execution frequency

Concurrency and Synchronization

  • Mutex - Mutual exclusion locking
    • Resource locking
    • Deadlock prevention
    • Lock timeouts
  • Background Processor - Background task processing
    • Queue management
    • Task prioritization
    • Error handling

Asynchronous Operations

  • Deferred - Deferred promise pattern
    • Promise creation and control
    • Resolution handling
    • Error propagation
  • Delay - Delay and timeout utilities
    • Timeout creation
    • Delay execution
    • Cancellation support

Data Handling

  • Serializable - Class serialization system
    • Property-level control
    • Metadata support
    • Nested object handling
  • DtoFactory - Data Transfer Object creation
    • Automatic DTO generation
    • Property mapping
    • Transform functions

UI and Content

  • HtmlSanitizer - HTML content processing
    • XSS prevention
    • Safe attribute handling
    • Content security
  • Templator - Template processing
    • Template parsing
    • Variable substitution
    • Conditional rendering
  • ImageHelper - Image processing utilities
    • Image validation
    • Format conversion
    • Size manipulation

System and Monitoring

  • Profiler - Performance profiling
    • Execution timing
    • Memory usage tracking
    • Performance metrics
  • Observer - Observer pattern implementation
    • Event subscription
    • State monitoring
    • Change notification

Resource Management

  • Disposable - Resource cleanup
    • Resource disposal
    • Cleanup scheduling
    • Memory management

Identification and Versioning

  • UUID - Unique identifier generation
    • UUID v4 generation
    • ID validation
    • ID comparison
  • Version - Version number handling
    • Version parsing
    • Version comparison
    • Semantic versioning

Documentation

Each feature has its own detailed documentation in the docs directory. The documentation includes:

  • Usage examples
  • API reference
  • Best practices
  • Common patterns

Installation

npm install @nivinjoseph/n-util

# or

yarn add @nivinjoseph/n-util

Quick Start

import { Duration } from '@nivinjoseph/n-util';

// Create durations in different units
const fiveMinutes = Duration.fromMinutes(5);
const twoHours = Duration.fromHours(2);
const thirtySeconds = Duration.fromSeconds(30);

// Convert between units
console.log(fiveMinutes.toSeconds()); // 300
console.log(twoHours.toMinutes()); // 120
console.log(thirtySeconds.toMilliSeconds()); // 30000

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.