2.1.0 • Published 2 years ago

@upsect/seeker v2.1.0

Weekly downloads
46
License
BSD-3-Clause
Repository
github
Last release
2 years ago

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

2 years ago

2.0.0

2 years ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.0

3 years ago