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

yadi

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yadi

Yet Another Dependency Injector

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

YADI (Yet Another Dependency injector)

NPM Version Build Coverage Status

NPM

Usage

require the file

const di = require('yadi');

add some stuff to the container

let something = () => 'hello potato';
di.add(something, 'custom name');

adds the class or function to the container, the optional custom name is recommended to manage the dependencies.

var obj = {
  'dependencies': 'custom name'
};
di.inject(obj)

injects the object with whatever was in the custom name, warns if the name don't exist but continues anyway

class Potato {
  get dependencies() {
    return ['custom name 1', 'custom name 2']
  }
}
di.inject(Potato);

injects the class potato with two dependencies, the dependencies are at the definition of the class, meaning they are accessible using static methods

var obj = {
  'dependencies': {
    'custom name': 'potato'
  }
}
di.inject(obj)

injects the object with the object in custom name, it's available in the object as potato

di.inject([obj1, obj2]);

injects several objects at the same time

di.inject('/some/directory/path');

let potato = require('/some/directory/path/potato');
console.log(potato['custom name']());
-> 'hello potato'

injects all the files in the path with whatever they need, also a single file can be passed

TODO

  • Improve this file
  • Add failure tests

FAQs

Package last updated on 31 Oct 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