@olchyk98/walker
v1.0.2
Published
My way to create scalable programs
Downloads
1
Readme
Walker
My way of creating scalable programs
Table of Contents
Installation
Install the package with Yarn:
yarn add @olchyk98/walker
Or with NPM:
npm i @olchyk98/walker
Usage
The idea is to go through all modules in the project,
and import them. By passing a matches
array as an argument, you specifically can
decide what files should be imported.
import walkFiles from '@olchyk98/walker'
async function loadHandlers () {
const handlers = await walkFiles('.', [ '-handler.js' ])
console.log(handlers[0]) // .../my-project/src/handlers/my-handler.js
}
The function may also return an array of imported modules if argument doRequire
is set to true
:
const handlers = await walkFiles('.', [ '-handler.js' ], true)
console.log(handlers[0]) // {}