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

async-resolve

v0.3.5

Published

An asynchronous and configurable implementation of require.resolve(), like node-resolve or enhanced-resolve.

Downloads

7

Readme

Build Status Dependency Status

async-resolve

This module a fastest async and configurable requre.resolve() implementation.

Installation

$ npm install async-resolve

Usage

Resolve absolute path for given [file|directory|module] in given basedir in asynchronous manner.

var Resolver = require('async-resolve');
var resolver_obj = new Resolver();
resolver_obj.resolve('module', __dirname, function(err, filename) {
  return console.log(filename);
});

Methods

var Resolver = require('async-resolve');

new Resolver(opts)

The resolver object may be configured on creation time:

options = {
  // default: ['.js', '.json', '.node'] - specify allowed filetypes, note that the
  // order matters. in this example index.js is prioritized over index.coffee
  extensions: ['.js', '.coffee', '.eco'],
  // default : false - make searching verbose for debug and tests
  log: true
  // default : 'node_modules' - its 'node_modules' directory names, may be changed
  modules : 'other_modules'
};
resolver_obj = new Resolver(options);

resolve(pkg, basedir, cb)

Resolve pkg in basedir on node.js-based algorithm

resolver_obj.resolve('module', __dirname, function(err, filename) {
  return console.log(filename);
});

addExtensions(exts)

also resolver object may be configured after creation:

resolver_obj.addExtensions('.jade');

getState()

All options may be inspected (for testing and debug):

resolver_obj.getState();
/*
{
  log: true,
  modules : 'other_modules',
  extensions: [ '.js', '.coffee', '.eco', '.jade' ],
  dir_load_steps: [
   'package.json',
   'index.js',
   'index.coffee',
   'index.eco',
   'index.jade' 
   ] 
}
*/

isCoreModule()

Return true if filename is node.js core module or false otherwise.

resolver_obj.isCoreModule('util'); // -> true

This method use internal module names table for fast lookup, not IO.

Similar modules

Test

$ cake test

Benchmark

In short async-resolve 2.4 times as fast as enhanced-resolve.

My benchmark results.

Build you own in 2 steps:

  1. do $ npm install at root module folder
  2. run $ coffee ./bench/async-resolve_vs_other.coffee from root module folder

License

Copyright (c) 2013 Dmitrii Karpich

MIT (https://raw.github.com/Meettya/async-resolve/master/LICENSE)