@upsect/seeker v2.1.0
Seeker is a Node.js utility for effortlessly requiring one or many modules, whether they exist or not. Require a module and optionally fall back to another module if it's missing, or require a directory of modules and get all of their exports conveniently organized by file name. Perfect for local development in a team environment, and for projects that frequently require batches of modules.
Install
% npm install @upsect/seeker
API
index(path)
path
<string>
path to a directory of modules
Returns an object with module exports, otherwise returns null
. Supports CJS modules that export a function, array, plain object, or class. Index.js and dot files are ignored. Refer to the test folder for examples.
const Seeker = require('seeker');
const Index = Seeker.index('./my_modules');
list(path)
path
<string>
path to a directory of modules
Returns an array of module exports, otherwise returns null
. See index
method for supported exports.
const Seeker = require('seeker');
const List = Seeker.list('./my_modules');
module(paths)
refs
<string[]>
list of module names or paths
Returns the first module that resolves, otherwise returns null
.
const Seeker = require('seeker');
const Module = Seeker.module(['./module1', 'module2']);