New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@skbkontur/simple-container

Package Overview
Dependencies
Maintainers
9
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skbkontur/simple-container

Zero deps container

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

simple-container

Zero deps container

Usage

import SimpleContainer from '@skbkontur/SimpleContainer'

const hebrewFactory = ({ httpClient, log }) => ({
  async brew() {
    try {
      await httpClient('/api/brew')
    } catch (ex) {
      log.error(ex)
    }
  }
})

const container = new SimpleContainer()
  .registerFactory('hebrew', hebrewFactory)
  .registerValue('httpClient', fetch.bind(global))
  .registerValue('log', console)

const hebrew = container.resolve('hebrew')

hebrew.brew()

Api

SimpleContainer — class instantiates container

Instance methods

.registerValue(name, value) — registers value in container

.registerClass(name, klass) — registers class in container. When resolves, instance would be created with cradle to constructor

.registerFactory(name, factory) — registers factory function in container. When resolves, function would be called with cradle passed to arguments

.resolve(name) — resolves registered item

Instance properties

.cradle — Proxy, which resolves items on property get. For example:

const hebrew = container.cradle.hebrew
// is the same as
const hebrew = cotainer.resolve('hebrew')

FAQs

Package last updated on 18 Jul 2018

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