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

path-rooter

v1.0.0

Published

Set of utilities that combine glob patterns and node (fresh) imports from a root path.

Readme

path-rooter

Set of utilities that combine glob patterns and node (fresh) imports from a root path.

Explanation

This tool can do 6 things via 6 methods:

  • rooter.resolve: Build paths from a root path and the parts.
  • rooter.require: Import files from a root path and the parts.
  • rooter.execute: Execute files from a root path and the parts.
  • rooter.find: Find files from a root path and a set of glob patterns.
  • rooter.findAndRequire: Import files from a root path and a set of glob patterns.
  • rooter.findAndExecute: Execute files from a root path and a set of glob patterns.

Installation

$ npm i -s path-rooter

Usage

Import the module and create an instance:
const Rooter = require("path-rooter");
const rooter = Rooter.create(__dirname+"/..");
Build 1 route:
const route = rooter.resolve("/subpath/to/somewhere", "and/using", "parts.js");
Import using cache:
const data = rooter.require("/subpath", "to", "somefile.js");
Import avoiding cache:
const freshData = rooter.execute("/subpath", "to", "somefile.js");
Build routes from glob patterns:
const routes = rooter.find(["/subpath", "/each/string/is/a/pattern"], "/all/the/args/are/flatten");
Import using cache from glob patterns:
const dataSet = rooter.findAndRequire("/subpath/to/somefile.js");
Import avoiding cache from glob patterns:
const freshDataSet = rooter.findAndExecute("/subpath/to/somefile.js");

API Reference

Rooter = require("rooter")

Class of rooter.


rooter = new Rooter($directory)

Constructor of rooter instances.

Defines the rooter.ROOT path from which the other routes will be built.

Accepts a string.


Rooter.create($directory)

The same as the constructor.


rooter.resolve(...$routes)

Method that builds a route from its parts and starting from the rooter.ROOT path.

It accepts a list of strings that will be merged and appended to rooter.ROOT.

Returns a string with the resultant file.


rooter.find(...$patterns)

Method that returns the paths of the files found from the provided glob patterns and starting from the rooter.ROOT path.

It accepts a list of strings and arrays. Each string will be used as globby pattern and appended to rooter.ROOT to make the search.

Returns a list of strings with the files found.


rooter.require(...$route)

Method that imports one module (using the usual cache of node) from the parts of its path and from the rooter.ROOT path.

It accepts a list of strings. Each string will be merged and appended to rooter.ROOT to create the new path, and that path is imported.

Returns the module.


rooter.execute(...$route)

Method that imports one module (avoiding the usual cache of node) from the parts of its path and from the rooter.ROOT path.

It works the same as require, but it will avoid nodejs default caching.


rooter.findAndRequire(...$patterns)

Method that first finds all the files matching the glob patterns provided from the rooter.ROOT path, and then imports them (using the usual cache of node).

It works the same as find and require combined. So, it returns a list (with what modules returned).


rooter.findAndExecute(...$patterns)

Method that first finds all the files matching the glob patterns provided from the rooter.ROOT path, and then imports them (avoiding the usual cache of node).

It works the same as find and execute combined. So, it returns a list (with what modules returned).

Test

$ npm run test

Documentation

$ npm run docs

Issues

Here.

License

WTFPL. 100% free.