1.8.15 • Published 2 years ago

async-require-context v1.8.15

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

async-require-context

Checks

  • Build
  • Code Style Analysis
  • Test CI

npm.io npm.io npm.io

A rewritten version of @wilsonlewis' require-context package that utilizes modern technologies.

This module is not a drop in replacement for require-context.

Getting started

npm install --save async-require-context
import asyncRequireContext from "async-require-context";

Arguments

asyncRequireContext(path, recursive, pattern);
// In TypeScript, you can specify the type that each module is expected to be.
// asyncRequireContext<Type>(path, recursive, pattern);
NameTypeDefaultDescription
pathStringnone (required)Specifies the path to look for modules in.
recursiveBooleantrueIf true, will recurse through subdirectorys in path.
patternRegExp/\.js$/Specifies a filter that files must match.

Returns

asyncRequireContext will always return Promise<Context[]>, if your using type annotations, it will be Promise<Context<Type>[]>

The Context structure is:

{
	name: string, // Name of the module.
	path: string, // Full path of the module.
	module: require(path) // The module as if it was required with `require`. This may be any shape depending on if you use type annotations.
}
1.8.14

2 years ago

1.8.15

2 years ago

1.8.12

2 years ago

1.8.13

2 years ago

1.8.11

3 years ago

1.8.10

3 years ago

1.8.9

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago