Socket
Socket
Sign inDemoInstall

pdi

Package Overview
Dependencies
2
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pdi

Minimal Promise based dependency injection framework


Version published
Maintainers
1
Created

Readme

Source

PDI - Minimal Promise based Dependency Injection framework

Simple API:

  • pdi.add(name, deps, fn) Adds a module by name and with depedencies
  • pdi.start(deps, fn)
  • pdi.clear used when testing to reset the DI

Extra utils for testing:

  • pdi._test.clear()
  • pdi._test.

While being small this library is powerful enough to be used for async flow control, for example:

const flow = pdi()
flow.add("body", req.body)
flow.add("userId", ["body"], prop("userId"))
flow.add("user", ["userId"], getUser)
flow.add("friends", ["user"], getFriends)
flow.add("result", ["friends", "user"], assoc("friends"))
flow.start(["result"])
.then((result) => res.send(result))
.catch((err) => res.sendStatus(500))

FAQs

Last updated on 09 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc