1.0.2 • Published 3 years ago

@olchyk98/walker v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Walker

My way of creating scalable programs

Table of Contents

  1. Installation
  2. Usage

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]) // {}