tiniocc

0.0.4 • Public • Published

tiniocc

npm version Node.js CI JavaScript Style Guide

A dead simple IoC container, with lazyload support.

Installation

yarn add tiniocc

or

npm i tiniocc

Usage

// import the exported function
// you can also require it when using CommonJS
// const { createContainer } = require('tiniocc')
import { createContainer } from 'tiniocc'

// create a container
const container = createContainer()
// register a module named 'module' with plain text content 'content'
container.register('module', 'content')

// access the module via dot notation
// will print 'content'
console.log(container.module)
import { createContainer } from 'tiniocc'

const container = createContainer()
container.register('moduleA', 'content')
// register another module which depends on moduleA
container.register('moduleB', container => container.moduleA + ' content')

console.log(container.moduleA) // will print 'content'
console.log(container.moduleB) // will print 'content content'

note: when using with snowpack, you should import the module as follow:

import tiniocc from 'tiniocc'

const container = tiniocc.createContainer()

Readme

Keywords

Package Sidebar

Install

npm i tiniocc

Weekly Downloads

3

Version

0.0.4

License

MIT

Unpacked Size

4.51 kB

Total Files

4

Last publish

Collaborators

  • zoron