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

crazy-functions

v1.2.0

Published

Library of the functions for helping you in several situations.

Readme

Crazy Functions

Library of the functions for helping you in several situations.

Installation

Use the node package manager npm to install crazy-functions.

npm install crazy-functions

Usage

import cf from "crazy-functions";

const products = [
  { name: "Product 1", category: "Informatic" },
  { name: "Product 2", category: "Clothes" },
  { name: "Product 3", category: "Home appliances" },
  { name: "Product 4", category: "Informatic" },
];

cf.groupObjects(products, "category");

/** returns 
{
    Informatic: [{
            name: "Product 1",
            category: "Informatic"
        },
        {
            name: "Product 4",
            category: "Informatic"
        },
    ],
    Clothes: [{
        name: "Product 2",
        category: "Clothes"
    }, ],
    "Home appliances": [{
        name: "Product 3",
        category: "Home appliances"
    }, ],
}

*/

API

This function grouping objects of the array based on the property passed by parameter.

groupObjects(arr: any[], propertyName: string): object

 

import cf from "crazy-functions";

const candidates = [
  { name: "Candidate 1", occupation: "Backend Developer" },
  { name: "Candidate 2", occupation: "Designer UI/UX" },
  { name: "Candidate 3", occupation: "Software Tester" },
  { name: "Candidate 4", occupation: "Software Engineer" },
  { name: "Candidate 5", occupation: "Software Developer" },
  { name: "Candidate 6", occupation: "Designer UI/UX" },
  { name: "Candidate 7", occupation: "Frontend Developer" },
  { name: "Candidate 8", occupation: "Backend Developer" },
  { name: "Candidate 9" },
  { name: "Candidate 10" },
];

cf.getPropertyValues(candidates, "occupation");

/** returns 
[
      "Backend Developer",
      "Designer UI/UX",
      "Software Tester",
      "Software Engineer",
      "Software Developer",
      "Frontend Developer",
]
*/

API

This function returns an array with values ​​of the property passed as a parameter.

getPropertyValues(arr: any[], propertyName: string): any

 

import cf from "crazy-functions";

const candidates = [
  { name: "Candidate 1", occupation: "Backend Developer" },
  { name: "Candidate 2", occupation: "Designer UI/UX" },
  { name: "Candidate 3", occupation: "Software Tester" },
  { name: "Candidate 4", occupation: "Software Engineer" },
  { name: "Candidate 5", occupation: "Software Developer" },
  { name: "Candidate 6", occupation: "Designer UI/UX" },
  { name: "Candidate 7", occupation: "Frontend Developer" },
  { name: "Candidate 8", occupation: "Backend Developer" },
  { name: "Candidate 9" },
  { name: "Candidate 10" },
];

cf.splitObjectsByPropertyValues(candidates, "occupation");

/** returns
[
      [
        {
          name: "Candidate 1",
          occupation: "Backend Developer",
        },
        {
          name: "Candidate 8",
          occupation: "Backend Developer",
        },
      ],
      [
        {
          name: "Candidate 2",
          occupation: "Designer UI/UX",
        },
        {
          name: "Candidate 6",
          occupation: "Designer UI/UX",
        },
      ],
      [
        {
          name: "Candidate 3",
          occupation: "Software Tester",
        },
      ],
      [
        {
          name: "Candidate 4",
          occupation: "Software Engineer",
        },
      ],
      [
        {
          name: "Candidate 5",
          occupation: "Software Developer",
        },
      ],
      [
        {
          name: "Candidate 7",
          occupation: "Frontend Developer",
        },
      ],
      [
        {
          name: "Candidate 9",
        },
        {
          name: "Candidate 10",
        },
      ],
    ]
*/

API

This function returns an array of arrays of objects separated by the values ​​of a property passed as a parameter.

splitObjectsByPropertyValues(arr: any[], propertyName: string): Array<Array<any>>

 

import cf from "crazy-functions";

const userInfos = [
  {
    name: "User 1",
    email: "[email protected]",
  },
  {
    address: "street 1",
    phone: "123456789",
  },
  {
    role: "user",
  },
  {
    scopes: ["read", "write"],
  },
];

cf.createObjectFromObjectsArray({}, userInfos);

/** returns
{
      name: "User 1",
      email: "[email protected]",
      address: "street 1",
      phone: "123456789",
      role: "user",
      scopes: ["read", "write"],
}
*/

API

This function returns an object with all properties of the objects array.

createObjectFromObjectsArray(initialObject: object = {}, arr: Array<{ [key: string]: any }): object

 

import cf from "crazy-functions";

cf.range(5, 10);

/** returns
  [5, 6, 7, 8, 9, 10]
*/

API

This function returns an array with defined range.

range(start: number, end: number): Array<number>

 

import cf from "crazy-functions";

cf.arrayDiff([1, 2, 3, 4, 5], [3, 4, 5, 6, 7]);

/** returns
  [1, 2]
*/

API

This function returns the difference between two arrays.

<T extends string | number>( arr1: T[], arr2: T[]): Array<T>

 

import cf from "crazy-functions";

cf.arrayIntersection([1, 2, 3], [3]);

/** returns
  [3]
*/

API

This function returns the intersection between two arrays.

<T extends string | number>( arr1: T[], arr2: T[]): Array<T>

 

import cf from "crazy-functions";

cf.arrayUnion([1, 2, 3], [4, 5, 6]);

/** returns
  [1, 2, 3, 4, 5, 6]
*/

API

This function returns the unios between two arrays.

<T extends string | number>( arr1: T[], arr2: T[]): Array<T>

 

import cf from "crazy-functions";

cf.capitalizeFirstLetter("hello world!");

/** returns
  Hello world!
*/

API

This function capitalize the first letter of word.

capitalizeFirstLetter(word: string): string

 

import cf from "crazy-functions";

cf.capitalizeAllFirstLetter(["hello", "world!"]);

/** returns
  ["Hello", "World!"]
*/

API

This function capitalize all the first letter of words.

capitalizeAllFirstLetter(words: Array<string>): Array<string>

 

import cf from "crazy-functions";

cf.formatCurrency(1000);

/** returns
    R$1,000.00
*/

API

This function formats numbers to currencies.

cf.formatCurrency(value: number, locale: string = "default", options: object = { style: "currency", currency: "BRL"}): string

 

import cf from "crazy-functions";

const project = {
  name: "Project 1",
  description: "Description Project 1",
  technologies: ["NodeJS", "ReactJS", "MongoDB"],
  status: "In progress",
  startDate: new Date("2021-01-01"),
  endDate: new Date("2021-12-31"),
  team: [
    {
      name: "User 1",
      email: "[email protected]",
      address: {
        street: "street 1",
        city: "city 1",
        country: "country 1",
      },
    },
  ],

  extra: {
    budget: 100000,
    expenses: 50000,
    lider: {
      name: "User 2",
      email: "",
    },
  },
};

cf.remove(project, "extra", "lider");

/** returns
   {
      name: "Project 1",
      description: "Description Project 1",
      technologies: ["NodeJS", "ReactJS", "MongoDB"],
      status: "In progress",
      startDate: new Date("2021-01-01"),
      endDate: new Date("2021-12-31"),
      team: [
        {
          name: "User 1",
          email: "[email protected]",
          address: {
            street: "street 1",
            city: "city 1",
            country: "country 1",
          },
        },
      ],
      extra: { budget: 100000, expenses: 50000 },
    }
*/

API

This function removes the last property of the object passed as a parameter.

function remove(obj: object, ...args: any[]): object;

 

import cf from "crazy-functions";

const project = {
  name: "Project 1",
  description: "Description Project 1",
  technologies: ["NodeJS", "ReactJS", "MongoDB"],
  status: "In progress",
  startDate: new Date("2021-01-01"),
  endDate: new Date("2021-12-31"),
  team: [
    {
      name: "User 1",
      email: "[email protected]",
      address: {
        street: "street 1",
        city: "city 1",
        country: "country 1",
      },
    },
  ],

  extra: {
    budget: 100000,
    expenses: 50000,
    lider: {
      name: "User 2",
      email: "",
    },
  },
};

cf.pluck(project, "technologies");

/** returns
   [
      "NodeJS",
      "ReactJS",
      "MongoDB",
    ]
*/

API

This function returns the value of the last property passed as a parameter.

pluck(obj: object, ...keys: NonEmptyArray<string>): any;

 

import cf from "crazy-functions";

 const arr = [1, 2, 3, 4, 5]

cf.shuffle(arr);

/** return could be
   [5, 2, 4, 1, 3]
*/

API

Shuffle an array

shuffle(arr: any[], fn: (() => number) | undefined = undefined): any[]

License

MIT