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

@produck/kit

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@produck/kit

A useful dependency injection module.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
73
increased by508.33%
Maintainers
2
Weekly downloads
 
Created
Source

@produck/kit

GitHub Workflow Status Coveralls npm (scoped) npm lerna NPM

A module to create a injection for implemention of DI, IoC. It can easily build injection prototype chain. Each injection represents a job space, a problem scope. Child injection can access dependencis of its prototype injection.

It has been published as a "Dual CommonJS/ES module" package but ESM first. It can work in "node.js" and browsers. It is also very friendly with "tree shaking", using "Rollup".

A Kit, the injection is IMMUTABLE.

Installation

$ npm install @produck/kit

Usage

Import / require

As esModule,

import * as Kit from '@produck/kit';

As CommonJs,

const Kit = require('@produck/kit');

Prepare / Inject / Spread

The chain is like [Child] --|> [Base] --|> [Global].

  • Inject [Child] to FooProvider().
  • Inject [Base] to BarProvider().
import * as Kit from '@produck/kit';

function BarProvider(Kit) {
	console.log(Kit.Kit); // => Child Kit
	console.log(Kit.version); // => @produck/kit version
	console.log(Kit.foo); // => 'bar'
	console.log(Kit.baz); // => 'qux'
}

function FooProvider({ Kit, version, foo }) {
	// Spread
	console.log(version); // => @produck/kit version.
	console.log(foo); // => 'bar'

	// Create a child Kit by `Base Kit`
	const child = Kit('Child');

	child.baz = 'qux';

	// Inject
	BarProvider(child);
}

// Prepare
const base = Kit.global('Base');

base.foo = 'bar';

// Inject
AnyProvider(base);

API

.global

.global.version

.Kit([name: string]): Kit

License

MIT

Keywords

FAQs

Package last updated on 01 Oct 2022

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