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 🙏

© 2025 – Pkg Stats / Ryan Hefner

base-resolver

v0.3.4

Published

'base-methods' plugin for resolving and loading globally installed npm modules.

Readme

base-resolver NPM version Build Status

'base-methods' plugin for resolving and loading globally installed npm modules.

Install

Install with npm

$ npm i base-resolver --save

Usage

var resolver = require('base-resolver');

Example

In two steps, the following example shows how we would use base-resolver with a custom Generate application that is built on top of [base-methods][].

Step 1: Setup

The following example shows how we might begin creating a basic project generator from [base-methods][]. More specifically, this shows how we might register and cache generators.

var resolver = require('base-resolver');
var Generate = require('base-methods');

// register a "global" plugin, to initialize the `generators` 
// object, and decorate a `register` method (as an alternative 
// to inheriting base-methods or other more complicated approaches)
Generate.use(function(app) {
  app.generators = {};
  app.define('register', function(key, config) {
    this.generators[key] = config;
    return this;
  });
});

// register `resolver` as a global plugin
Generate.use(resolver('generate'));

Step 2

Intantiate the custom application we just created, and search for generators!

var generate = new Generate();

// setup a listener that will register generators (
// `config`s) as they're emitted
generate.on('config', function(config) {
  console.log('registered:', config.alias);
  generate.register(config.alias, config);
});

// find configs!
generate
  .resolve('generate-*/generator.js', {
    cwd: require('global-modules')
  });
  .resolve('generate-*/generator.js', {
    cwd: process.cwd()
  });

API

Params

  • name {String}: Optionally specify a namespace for storing resolved configs.
  • options {Object}: Options to pass to matched
  • option.patterns {String|Array}: Glob patterns to search
  • option.cwd {String}: The starting directory to search from
  • returns {Object}

Example

resolver.on('config', function(config) {
  // do stuff with "config"
});

resolver
  .resolve('foo', {pattern: 'generator.js', cwd: 'foo'})
  .resolve('bar', {pattern: 'generator.js', cwd: 'bar'})
  .resolve('baz', {pattern: 'generator.js', cwd: 'baz'})

Related projects

  • global-modules: The directory used by npm for globally installed npm modules. | homepage
  • matched: Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and… more | homepage
  • npm-paths: Returns an array of unique "npm" directories based on the user's platform and environment. | homepage
  • resolve-modules: Resolves local and global npm modules that match specified patterns, and returns a configuration object… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb on December 14, 2015.