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

ldr-utils

v1.0.15

Published

Unlimited utility packpage for you

Downloads

33

Readme

🔰 Ldr-utils package

Ldr-utils is an unlimited utility package designed to provide a wide range of helpful functions for your projects.

✅Installation

To install this package, you can use npm or yarn:

yarn add ldr-utils
npm i ldr-utils

❓ Usage

The package offers several functions:

🎈 abbreviate(number)

This function takes a large number and abbreviates it to make it more readable. It returns a string containing the abbreviated number.

Example usage:

const { abbreviate } = require('ldr-utils');

console.log(abbreviate(1500)); // Output: "1.5K"
console.log(abbreviate(2000000)); // Output: "2M"
console.log(abbreviate(5000000000)); // Output: "5B"

🎈 unabbreviate(number)

This function takes an abbreviated number string and expands it to its full numeric value.

Example usage:

const { unabbreviate } = require('ldr-utils');

console.log(unabbreviate('1.5K')); // Output: 1500
console.log(unabbreviate('100k', { format: true }));  // Output: '100.000'
console.log(unabbreviate('5B'));   // Output: 5000000000

🎈 average(...numbers)

The average function calculates the average of a set of numbers passed as arguments. It returns the arithmetic mean of the provided numbers.

Example Usage:

const { average } = require('ldr-utils');

console.log(average(5, 10, 15)); // Output: 10 (average of 5, 10, and 15)
console.log(average(12, 24, 36, 64)); // Output: 34 (average of 12, 24, 36 and 64)

🎈 ms(duration, options)

This function takes a duration string and formats it into a human-readable format. It supports various units such as 'w' (weeks), 'd' (days), 'h' (hours), 'm' (minutes), 's' (seconds), and 'y' (years).

Example Usage:

const { ms } = require('ldr-utils');

console.log(ms('5d')); // Output: 432000000
console.log(ms('2w', { detailed: true })); // Output: "2 weeks"
console.log(ms('40d', { detailed: true })); // Output: "5 weeks, 5 days"

🎈 formatTime(milliseconds)

This function takes a duration in milliseconds and formats it into a human-readable format with days, hours, minutes, and seconds.

Example Usage:

const { formatTime } = require('ldr-utils');

console.log(formatTime(86400000)); // Output: "1d"
console.log(formatTime(3600000)); // Output: "1h"
console.log(formatTime(179191000)); // Output: "2d, 1h, 59m, 51s"