Installations
npm install require-context-arr
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
9.4.0
NPM Version
5.6.0
Score
66
Supply Chain
83.1
Quality
75.3
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
robbiemu
Download Statistics
Total Downloads
1,704
Last Day
1
Last Week
6
Last Month
14
Last Year
100
GitHub Statistics
15 Commits
2 Watching
2 Branches
1 Contributors
Bundle Size
15.89 kB
Minified
5.88 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.4
Package Id
require-context-arr@1.1.4
Size
1.87 kB
NPM Version
5.6.0
Node Version
9.4.0
Total Downloads
Cumulative downloads
Total Downloads
1,704
Last day
0%
1
Compared to previous day
Last week
-14.3%
6
Compared to previous week
Last month
366.7%
14
Compared to previous month
Last year
-36.3%
100
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
require-context v1.1.4
changes: this version supports a directory or an array of directories (which, yes, is dangerous because of collisions. but useful for submodules in some contexts)
Installation
Using npm:
1$ npm i -g npm 2$ npm i --save require-context
In Node.js:
1// Load globally into all modules. 2require('require-context/register') 3 4// Load locally as a function. 5var requireContext = require('require-context');
Usage
It allows you to pass in a directory to search, a flag indicating whether subdirectories should be searched too, and a regular expression to match files against.
The syntax is as follows:
1require.context(directory, useSubdirectories = false, regExp = /^\.\//)
Examples
1require.context("./test", false, /\.test\.js$/); 2// a context with files from the test directory that can be required with a request endings with `.test.js`.
1require.context("../", true, /\.stories\.js$/); 2// a context with all files in the parent folder and descending folders ending with `.stories.js`.
Context API
A context module exports a (require) function that takes one argument: the request.
The exported function has 3 properties: resolve, keys, id.
resolve
is a function and returns the module id of the parsed request.keys
is a function that returns an array of all possible requests that the context module can handle.
This can be useful if you want to require all files in a directory or matching a pattern, Example:
1function importAll (r) {
2 r.keys().forEach(r);
3}
4
5importAll(require.context('../components/', true, /\.js$/));
Why require-context?
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/15 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More