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

js.utils

v0.2.11

Published

General JavaScript Utilities

Downloads

236

Readme

js.utils

  • Object

    • copy/clone an object
    • contains - Validates if an object contains a given value
    • empty - Validates is the object empty
  • NPM

    • info - Get information about the list of installed packages
    • installed - Check if a package has already been installed
  • Template

    • Load and compile a template with underscore
  • Task

    • Lint, concat and/or minify a set of resources (currently JS file type supported)

Usage

Initial settings

  • Set the log on/off (by default set to on)

Object

  • Copy the 'srcobj' to the 'destobj'

srcobj = {foo: 'foo'}; require("js.utils").Object.copy(srcobj, destobj);

  • Validates if 'foo' exists in a given array

  • Validates if an object is empty

NPM

  • get all local packages information

  • check if the package 'bower' was installed

Template

  • Compile a given template as a file or string value using underscore (Mustache Style).

Task

  • Prepare your resources for Development (dev api) and/or Production (prod api) with JSHint & UglifyJS

  • Or use separate API minify/jshint/concat

Browser Support

Usage

  • AMD

    • See jsutilswebRequire-min.js file, as an example of requirejs project style

      define([], function() {

        var jsutilsOnReady = function(obj, arr, tpl) {
                
            // use object, array or template 
                
        };
              
        return jsutilsOnReady;

      });

  • None AMD

    • js.utils global variables for the web:
      • jsutilsObject;
      • jsutilsArray;
      • jsutilsTemplate;

Download

Reference

Object

  • copy(srcobj, destobj, override)
    • srcobj {Object} The source object
    • destobj {Object} The destination object
    • override {Object} Override the existing property (deault to false)
  • contains(obj, value)
    • obj {Object} The referenced object
    • value {Object} The value to be searched
  • empty(srcobj)
    • srcobj {Object} The object reference returns {boolean} If the object is [null || undefined || has no values {}] return true or else false
  • resolve(srcobj)
    • srcobj {Object} The object reference

NPM

  • info(config, callback)

    • config properties:
      • global {Boolean} the packages are global, optional values are true/false (defaults to false)
      • details {Boolean} Whether to display the full details or just the basic details. (defaults to false)
      • list {Array} specific list of packages names (or else result all)
      • depth {string} npm argument for how deep the rabbit hole goes (defaults to 10)
        • -1 for unlimited (Not recommended, NPM will might throw an error about "max depth reached")
    • callback {Function} callback function for collecting the results. (get the data: this.data)
      • err {String} In case an error occurred this variable will contain the error data or else 'undefined'
      • this.data {Object} Array object containing the information about the packages that was found. Array item - instance of Package class
  • installed(config, callback)

    • config properties:
      • global {Boolean} the packages are global, optional values are true/false
      • list {Array} specific list of packages names (or else result all)
      • depth {string} npm argument for how deep the rabbit hole goes.
        • -1 for unlimited (Not recommended, NPM will might throw an error about "max depth reached")
    • callback {Function} callback function for collecting the results. (get the data: this.data)
      • err {String} In case an error occurred this variable will contain the error data or else 'undefined'
      • this.data {Object} An object containing the packages names with a true/false value indicating if the package installed.
  • Package class

    • getDetails Get the full details if the 'details' flag was set to true
    • getName Get the package name
    • get(key) Get the property by its key
      • opt keys 'name', 'dependencies', 'detail', etc.. (see package.json for more information)

Template

  • template(config)
    • Config properties:
      • name {String} The name of the template e.g. /scraps/test (optional in case content exists)
      • path {String} The full path where the templates exists (optional) e.g. /home/../test.tpl
      • content {String} The string content instead of the file content (optional in case name exists & overrides the file content)
      • data {Object} The data object properties (see underscore template)

Task

Behavior

  • NPM List

For more information see the NPM docs