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

utilitarian

v1.0.8

Published

Low-level JavaScript utility functions that service many different needs in a front-end or back-end JavaScript application

Downloads

12

Readme

Utilitarian - Common, Low-Level JavaScript Utility & Helper Functions

This module contains low-level JavaScript functions that I find myself using frequently on NodeJS or React/Angular/Vue projects. I would often start a JavaScript project by dropping most of these functions into a utils.js file in the project root, however this was typically for monolithic UI projects that would occupy my time for nearly a year at a time (or more). Once I found myself working on handfuls of small NodeJS microservices and smaller UI applications, the need to place these utils into an npm module became obvious.

This package includes type-checkers, array & object mappers, http code constants, some of my favorite CSS colors, constants and mixins for responsive design, connect.js request parsing functions, random string/number generators, and event helpers. Most of these utils are so low level that you've undoubtedly written functions like these (especially those in the is.util.js file) but hopefully you'll find it useful to have them organized into one collection that can be injected and used piecemeal on a front-end or back-end JavaScript application.

During my time with Mentor I attempted to fully polish these APIs, splitting them up into multiple files so that you can import smaller portions of this library when your particular needs are minimal. Much of this package's organizational structure was influenced by what I learned while there, creating one NodeJS service, and then another, rinse-and-repeat.

Installation

Latest release:

$ npm install utilitarian

Dependencies

Usage

import {isEmpty} from 'utilitarian/is.util';

function fullName({first, last, middle} = {}) {
    if (!isEmpty(middle)) {
        return `${first} ${middle} ${last}`;
    }

    return `${first} ${last}`;
}

Or:

import utils from 'utilitarian';

function fullName({first, last, middle, title, suffix} = {}) {
    return utils.string.fullTrim(
        [title, first, middle, last, suffix].filter(name => name)
    ) || utils.string.randomString(5);
}

Overview

is utils

Functions that check data types and validate categories of string types (such as passwords, emails, urls, etc.)

obj utils

Helper functions for objects, for converting to other formats, for deep inspection of nested properties, etc.

string utils

Helper function for strings to convert to other formats, to format string in different manners, and for hashing.

logger

A simple wrapper around the console logging that allows for turning messages on or off.

req utils

Helper functions for Http request handling and code parsing (some helpers specific to the ExpressJS framework)

event utils

Helper functions for parsing native or React-wrapped event objects.

color utils

Helper functions for color conversion (hex to rgb, rgb to hex, hex to rgba, etc) and other helpers related to coloring.

css cards

Style constants for responsive Card design.

css mixins

CSS mixins for transitions, box shadow, text shadow and other complex styling.