@upsect/seeker

Node.js utility for effortlessly requiring one or many modules, whether they exist or not.


Keywords
dependencies, dotenv, environments, failover, fallback, node, require
License
BSD-3-Clause
Install
npm install @upsect/seeker@2.1.0

Documentation


seeker

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

module([ refs ])

  • 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']);

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');