New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

easy-dependency-loader

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-dependency-loader

A simple way to manage your dependencies and use require with no problems with relative paths. It is very useful to complex project structures and when it is needed to change some file from it's place.

Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Installation

EDL requires Node.js v4+ to run.

$ npm install --save easy-dependency-loader

Usage

Make sure you have a dependencies list in the following format:

{
...
    "dependency1": "path/to/dependency1",
    "dependency2": "path/to/dependency2",
    "dependency3": "path/to/dependency3",
...
}

It can be described in a JSON file or in a object. The EDL works exactly in the same way of require, so, every load that works with require also works with EDL.

EDL.setDependencies(dependencies); //As an object descriptor
EDL.setDependencies('./path/to/dependencies.json'); //Path to dependencies file

var myDependencies = require('./path/to/dependencies.json');
EDL.setDependencies(myDependencies); //Using an JSON module with require

Then, you just need to call the name of module using the load() method. Is no necessary to use the relative path.

var Module = EDL.load('moduleName');
Module.doSomething();

Example

var EDL = require('easy-dependency-loader');

//Passing a JSON path
EDL.setDependencies('./path/to/jsonfile/dependencies.json');

//Passing a JSON module with require
var myDependencies = require('./configs/confgis.json');
EDL.setDependencies(myDependencies);

//Passing an object
EDL.setDependencies({
  "Dog": "./models/Dog.js",
  "Falcon": "./models/birds/Falcon.js",
  "Chicken": "./models/birds/Chicken.js",
  "Worm": "./models/birds/insects/Worm.js"
});

//Finally, you can call the module in other place of project
var EDL = require('easy-dependency-loader')
var Dog = EDL.load('Dog');
var Worm = EDL.load('Worm');
Dog.bark(); 
Worm.crawl();

Contributions

Pull requests are welcome!

Errors

In general, problems with using this module maybe are problems with require, such wrong relative path or file type. But if not, you can open an issue and make a pull request!

Todos

  • Tests
  • Using other types of config files, such xml.

License

MIT

FAQs

Package last updated on 19 Dec 2016

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