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

@itentialopensource/app-utils

v2.0.0

Published

A set of commonly used utility functions

Readme

app-utils

app-utils provides some helpful utility functions.

Table of Contents

Installation

npm install --save @itentialopensource/app-utils

Usage

Require app-utils

const appUtils = require('@itentialopensource/app-utils');

Included functions

  • safeGet(object, path, defaultValue = null): Safely try to extract a property from an object. If the property cannot be found, return a default value.

    const shapes = {
      triangle: {
        numSides: 3,
        types: [
          { name: 'equilateral', numEqualSides: 3 },
          { name: 'isosceles',   numEqualSides: 2 },
          { name: '30-60-90',    numEqualSides: 0 }
        ]
      },
      quadrilateral: {
        numSides: 4,
        types: [
          { name: 'square' , numEqualSides: 4 }
        ]
      }
    };
    let numEqualSides = safeGet(shapes, ['triangle', 'types', 1, 'numEqualSides'], 0);
    // numEqualSides -> 2
    
    numEqualSides = safeGet(shapes, ['quadrilateral', 'types', 1, 'numEqualSides'], 0);
    // numEqualSides -> 0
    // Since there is no second element in the quadrilateral types array,
    // numEqualSides takes the default value of 0.
  • safePut(object, path, value): Put a value into an object at the specified path, creating the path along the way if it doesn't exist.

    // Continuing the shapes example
    const rhombus = { name: 'rhombus', numEqualSides: 4 };
    // Here the index -1 tells safePut to add the item to the end of the array
    const shapesWithRhombus = safePut(shapes, ['quadrilateral', 'types', -1], rhombus);
      
    numEqualSides = safeGet(shapesWithRhombus, ['quadrilateral', 'types', 1, 'numEqualSides'], 0);
    // numEqualSides -> 4
    
    
    // safePut can also be used for creating new objects
    const deeplyNested = safePut({}, ['a', 'b', 'c', 'd', 'e'], {});
    // -> deeplyNested -> {
    //      a: {
    //        b: {
    //          c: {
    //            d: {
    //              e: {}
    //            }
    //          }
    //        }
    //      }
    //    }
  • asyncFilter(arr, evalFn): Filter array elements according to an async evaluation function.

    const arr = [1, 2, 3, 4, 5];
    const evalFn = async (num) => {
          // 10 millisecond delay
          await (() => new Promise(resolve => setTimeout(resolve, 10)))();
          return num > 3;
    };
      
    const butTheArrayBuiltIn = await Promise.all(arr.filter(num => evalFn(num)));
    // butTheArrayBuiltIn -> [1, 2, 3, 4, 5]
    // Unfortunately, Array.prototype.filter is synchronous and doesn't return what you'd expect.
      
    const greaterThanThree = await asyncFilter(arr, evalFn);
    // greaterThanThree -> [4, 5]
  • promisesInChunks(promises, options): Perform Promise.all in chunks instead of all at once--great for not overwhelming a device with requests.

    const promises = [
        () => Promise.resolve(1),
        () => Promise.resolve(2),
        () => Promise.resolve(3),
        () => Promise.resolve(4)
    ];
    const options = { chunkSize: 2, waitTime: 500 };
    // Evaluate two promises at a time with a half second delay between evaluations.
    const resolvedPromises = await promisesInChunks(promises, options);
    // resolvedPromises -> [1, 2, 3, 4]
  • toCogFn(fn, callback, ...args): Wrap a function in the standard form necessary to expose it as a task or endpoint in IAP. Callbacks and error handling are taken care of for you, greatly reducing the size of cog.js.

    // cog.js
    
    const operations = require('./lib/operations');
    
    // Expose a library function as a Workflow Builder task
    const numerator = 6;
    const denominator = 3;
    const quotient = operations.divide(numerator, denominator);
    // quotient -> 2
    
    class AppMath {
      /**
      * @pronghornType method
      * @name divide
      * @summary Divide two numbers
      * @param {number} numerator
      * @param {number} denominator
      * @param {callback} callback
      * @return {number} quotient
      * @roles admin
      * @task true
      */
      divide(numerator, denominator, callback) {
        toCogFn(operations.divide, callback, numerator, denominator);
      }
    }
  • isObject(x): Determine if a variable is bound to an object (in the strict sense).

    isObject({}); // -> true
      
    [] instanceof Object;   // -> true
    typeof [] === 'object'; // -> true
    isObject([]);           // -> false
  • safeHasOwnProperty(object, property): Perform Object.hasOwnProperty safely according to https://eslint.org/docs/rules/no-prototype-builtins

    function safeHasOwnProperty(object, property) {
      return Object.prototype.hasOwnProperty.call(object, property);
    }
    
    const dog = { name: 'Fido' };
    safeHasOwnObject(dog, 'name');        // -> true
    safeHasOwnObject(dog, 'favoriteToy'); // -> false