Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@specla/autoloader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@specla/autoloader

Autoload modules and json files in Node.js

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Specla Autoloader

npm version Build Status Coverage Status Dependency Status Standard - JavaScript Style Guide

Autoload modules and json files with ease. This packages constructs an object that reflects your folder structure and requires the files within the specified path.

Install

npm install --save @specla/autoloader

Usage

const path = require('path')
const Autoloader = require('specla-autoloader')

const modules = new Autoloader(path.resolve('./modules'))

An example of the path ./modules could look like this.

┬ modules
├── some-file.js
├── data.json
├─┬ sub-modules
  ├── other-file.js

This will create the following js object when the path is autoloaded.

const modules = {
  'some-file': require('./modules/some-file.js'),
  data: require('./modules/data.json'),
  'sub-modules': {
    'other-file': require('./modules/sub-modules/other-file.js')
  }
}

Options

const modules = new Autoloader(__dirname, {
  include: ['js', 'json'], // specifies which file types to include
  ignore: [
    'node_modules', // ignore folders
    'some-file.js' // ignore specific file
  ]
})

Keywords

FAQs

Package last updated on 28 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc