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

helper-box

v1.0.3

Published

A set of js/ts core utility functions

Downloads

56

Readme

Open Source? Yes! Maintained npm bundle size npm

API

Here are some of the utility functions available in this library: helper-box

| Name | Description | | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | removeDuplicates | Remove duplicate values from an array, string, or object. | | arrayToObject | Convert an array into an object using a specified key. | | omitKeys | Omit specified keys from an object. | | difference | Find the difference between arrays, strings, or objects. | | formatCurrency | Convert any number to a formatted currency. | | getQueryParams | Parse query parameters from a URL into an object. | | cloneDeep | Deeply clones an object or array, creating a new instance with the same values. | | isImageUrl | Checks if a URL points to an image based on its file extension. | | toCamelCase | Converts a string from kebab-case or snake_case to camelCase. | | objectToArray | Converts an object to an array of its key-value pairs. | | getFileExtension | Extracts the file extension from a file path or URL. | | validEmail | Validates if a given string is in a proper email format. | | formatBytes | Converts a number of bytes into a human-readable string with units (e.g., KB, MB, GB). | | isUrl | Checks if a given string is a valid URL. | | arrSort | Sorts an array of objects by a specific field in ascending ("asc") or descending ("desc") order, with optional data transformation. | | convertValueToHoursMinutesFormat | Converts a given value to hours and minutes format. | | convertHoursToDaysHoursMinutes | Converts a value representing hours into days, hours, and minutes format. | | generateUUID | Generates a universally unique identifier (UUID). | | flattenDeep | Recursively flattens a nested array into a single-level array. | | convertHtmlContentToPlainText | Converts HTML content to plain text by removing HTML tags. |

Examples

removeDuplicates

import { removeDuplicates } from "helper-box";

// Array Example
const numbersArray = [1, 2, 2, 3, 4, 4, 5];
const uniqueNumbers = removeDuplicates(numbersArray);
console.log(uniqueNumbers);
// Output: [1, 2, 3, 4, 5]

// String Example
const text = "aabbccddeeff";
const uniqueText = removeDuplicates(text);
console.log(uniqueText);
// Output: "abcdef"

// Object Example
const object = { a: 1, b: 2, c: 2, d: 3, e: 1 };
const uniqueObject = removeDuplicates(object);
console.log(uniqueObject);
// Output: { a: 1, b: 2, d: 3 }

arrayToObject

import { arrayToObject } from "helper-box";

const users = [
  { id: 1, name: "Alice", age: 25 },
  { id: 2, name: "Bob", age: 30 },
  { id: 3, name: "Charlie", age: 35 },
];

const usersObject = arrayToObject(users, "id");

console.log(usersObject);
// Output:
// {
//   "1": { id: 1, name: "Alice", age: 25 },
//   "2": { id: 2, name: "Bob", age: 30 },
//   "3": { id: 3, name: "Charlie", age: 35 }
// }

omitKeys

import { omitKeys } from "helper-box";

const user: User = {
  id: 1,
  name: "Alice",
  age: 25,
  email: "[email protected]",
};

// Omit 'email' and 'age' keys from the user object
const userWithoutEmailAndAge = omitKeys(user, ["email", "age"]);
console.log(userWithoutEmailAndAge);
// Output: { id: 1, name: "Alice" }

difference

import { difference } from "helper-box";

const array1 = [1, 2, 3, 4, 5];
const array2 = [4, 5, 6, 7];

// Get the difference between array1 and array2
const arrayDiff = difference(array1, array2);
console.log(arrayDiff);
// Output: [1, 2, 3] (Items from array1 not in array2)

const string1 = "hello";
const string2 = "world";

// Get the difference between string1 and string2
const stringDiff = difference(string1, string2);
console.log(stringDiff);
// Output: "he" (Characters in string1 not in string2)

const user1 = {
  id: 1,
  name: "Alice",
  email: "[email protected]",
};

const user2 = {
  id: 1,
  name: "Alice",
};

// Get the difference between user1 and user2
const objectDiff = difference(user1, user2);
console.log(objectDiff);
// Output: { email: "[email protected]" } (Keys in user1 not in user2)

formatCurrency

import { formatCurrency } from "helper-box";

const amount1 = 1000;
const formattedAmount1 = formatCurrency(amount1, "en-US", "USD");
console.log(formattedAmount1);
// Output: "$1,000.00" (Formatted currency for USD in en-US locale)

const amount2 = 1500;
const formattedAmount2 = formatCurrency(amount2, "de-DE", "EUR");
console.log(formattedAmount2);
// Output: "1.500,00 €" (Formatted currency for EUR in de-DE locale)

const amount3 = 2500;
const formattedAmount3 = formatCurrency(amount3);
// Output: "$2,500.00" (Formatted currency for USD in the default en-US locale)
console.log(formattedAmount3);

getQueryParams

import { getQueryParams } from "helper-box";

import { getQueryParams } from "helper-box";

// Example URL
const url1 = "https://example.com/?name=Alice&age=25&country=USA";

// Get query parameters from the URL
const params1 = getQueryParams(url1);
console.log(params1);
// Output: { name: "Alice", age: "25", country: "USA" }

const url2 = "https://example.com/?search=book&page=2&sort=asc";

// Get query parameters from the URL
const params2 = getQueryParams(url2);
console.log(params2);
// Output: { search: "book", page: "2", sort: "asc" }

🤔 How to contribute

Have an idea? Found a bug? Please raise to ISSUES. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

💖 Support my projects

I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like 🚀
  • If you're feeling especially charitable, please follow avisek123 on GitHub.

About me

WhatsApp Image 2024-09-19 at 7 49 24 PM