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

ultan

v1.0.1

Published

This JavaScript library provides a collection of utility functions that can be used in various types of JavaScript projects. These functions are designed to provide convenient, reusable code that accomplishes tasks such as string manipulation, array manip

Downloads

4

Readme

Why use Ultan?

Ultan provides a collection of utility functions that can be used in various types of JavaScript projects. These functions are designed to provide convenient, reusable code that accomplishes tasks such as string manipulation, array manipulation, object manipulation, and more.

Table of Contents

Installation

  npm install ultan

Usage

const { stringFormat, greet, mergeArrays, isEmpty, regexes } = require('ultan');

// String Manipulation
const formattedString = stringFormat('Hello, {0}! Welcome to {1}.', 'John', 'Ultan');
console.log(formattedString); // Output: "Hello, John! Welcome to Ultan."

// Greeting
greet({ name: 'Alice', age: 30 }); // Output: "Hello, Alice! You are 30 years old."
greet(); // Output: "Hello, User! You are unknown years old."

// Array Utils
const array1 = [1, 2, 3];
const array2 = [3, 4, 5];
const mergedArray = mergeArrays(array1, array2);
console.log(mergedArray); // Output: [1, 2, 3, 4, 5]

// Object Utils
const obj = { name: 'John', age: 25 };
console.log(isEmpty(obj)); // Output: false

// Regular Expressions
const emailRegex = regexes.email;
const isValidEmail = emailRegex.test('[email protected]');
console.log(isValidEmail); // Output: true

String Manipulation

  • stringFormat: This function replaces placeholders in a given string with supplied arguments.
  • toTitleCase: Converts a string to title case.
  • sanitizeString: Sanitizes a string by replacing special characters with their HTML entities.
  • fromBase64 and toBase64: Functions for base64 encoding and decoding.
  • countOccurrences: Counts the number of occurrences of a substring in a string.

Greeting

  • greet: Greets a user with their name and age. If no name or age is supplied, defaults to "User" and "unknown" respectively.

Object Utils

  • isEmpty: Checks if an object is empty.
  • deepClone: Creates a deep clone of an object.
  • setNestedProperty: Sets a nested property of an object, given a 'dot notation' path.
  • getNestedProperty: Retrieves a nested property of an object, given a 'dot notation' path.
  • objectToArray: Converts an object to an array of key-value pairs.

Array Utils

  • mergeArrays: Merges two arrays, removing duplicates.
  • sumArray: Calculates the sum of an array of numbers.
  • averageArray: Calculates the average of an array of numbers.
  • arrayDifference: Returns the difference between two arrays.
  • arrayToObject: Converts an array of key-value pairs to an object.
  • groupBy: Groups an array of objects by a specified key.
  • removeFalsyValues: Removes all falsy values from an array.

Regular Expressions

  • regexes: A collection of regular expressions for matching email, phone number and URL.

Miscellaneous

  • getRandomInRange: Returns a random number within a given range.
  • getType: Returns the data type of a variable.
  • formatDate: Formats a date according to a specified format.
  • round: Rounds a number to a specified number of decimal places.
  • generateUUID: Generates a universally unique identifier (UUID).
  • reqFlow: Sends an HTTP request and returns the response as JSON, or throws an error if the request fails.
  • debounce: Debounce function to limit the rate at which a function can fire.
  • throttle: Throttle function to ensure that a function does not run more often than the interval of time.

Constants

  • DaysOfWeek: An enumeration of the days of the week.
  • HttpStatus: An enumeration of common HTTP status codes.