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

systemic

Package Overview
Dependencies
Maintainers
4
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

systemic - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

16

.eslintrc.json
{
"extends": ["prettier"],
"plugins": ["prettier"],
"extends": ["eslint-config-airbnb-base", "prettier"],
"env": {

@@ -10,3 +9,14 @@ "node": true

},
"rules": {}
"rules": {
"consistent-return": 0,
"func-names": 0,
"prefer-object-spread": 0,
"no-param-reassign": 0,
"no-plusplus": 0,
"no-prototype-builtins": 0,
"no-shadow": ["error", { "allow": ["err", "cb"] }],
"no-underscore-dangle": 0,
"no-unused-expressions": 0,
"no-use-before-define": 0
}
}

2

.prettierrc.json
{
"singleQuote": true,
"printWidth": 300
"printWidth": 120
}
# Changelog
## 4.1.1
- Use eslint-config-airbnb-base
- Move debug to prod dependency
## 4.1.0

@@ -4,0 +9,0 @@

const Systemic = require('../../../..');
const Mongo = require('./mongo');
module.exports = () => Systemic({ name: 'mongo' }).add('mongo.primary', Mongo()).dependsOn('config', 'logger').add('mongo.secondary', Mongo()).dependsOn('config', 'logger');
module.exports = () =>
Systemic({ name: 'mongo' })
.add('mongo.primary', Mongo())
.dependsOn('config', 'logger')
.add('mongo.secondary', Mongo())
.dependsOn('config', 'logger');

@@ -6,2 +6,10 @@ const Systemic = require('../..');

module.exports = () => Systemic().add('config', Config(), { scoped: true }).add('logger', Logger()).dependsOn('config').add('mongo.primary', Mongo()).dependsOn('config', 'logger').add('mongo.secondary', Mongo()).dependsOn('config', 'logger');
module.exports = () =>
Systemic()
.add('config', Config(), { scoped: true })
.add('logger', Logger())
.dependsOn('config')
.add('mongo.primary', Mongo())
.dependsOn('config', 'logger')
.add('mongo.secondary', Mongo())
.dependsOn('config', 'logger');

@@ -16,3 +16,6 @@ type RequiredKeys<T> = {

type MissingDependencies<TDependencies extends Record<string, unknown>, TNames extends unknown[]> = TNames extends [infer Name, ...infer Rest]
type MissingDependencies<TDependencies extends Record<string, unknown>, TNames extends unknown[]> = TNames extends [
infer Name,
...infer Rest
]
? NameToDestination<Name> extends keyof TDependencies

@@ -55,3 +58,5 @@ ? MissingDependencies<Omit<TDependencies, NameToDestination<Name>>, Rest>

};
type DependsOnOption<TDependencyKeys, TSystemic> = SimpleDependsOnOption<TSystemic> | MappingDependsOnOption<TDependencyKeys, TSystemic>;
type DependsOnOption<TDependencyKeys, TSystemic> =
| SimpleDependsOnOption<TSystemic>
| MappingDependsOnOption<TDependencyKeys, TSystemic>;

@@ -64,6 +69,12 @@ type DependsOn<TSystemic extends Record<string, unknown>, TDependencies extends Record<string, unknown>> = {

*/
dependsOn: <TNames extends DependsOnOption<keyof TDependencies, TSystemic>[]>(...names: TNames) => SystemicBuild<TSystemic, MissingDependencies<TDependencies, TNames>>;
dependsOn: <TNames extends DependsOnOption<keyof TDependencies, TSystemic>[]>(
...names: TNames
) => SystemicBuild<TSystemic, MissingDependencies<TDependencies, TNames>>;
};
type SystemicBuild<TSystemic extends Record<string, unknown>, TDependencies extends Record<string, unknown>> = [RequiredKeys<TDependencies>] extends [never] ? Systemic<TSystemic> & DependsOn<TSystemic, TDependencies> : DependsOn<TSystemic, TDependencies>;
type SystemicBuild<TSystemic extends Record<string, unknown>, TDependencies extends Record<string, unknown>> = [
RequiredKeys<TDependencies>
] extends [never]
? Systemic<TSystemic> & DependsOn<TSystemic, TDependencies>
: DependsOn<TSystemic, TDependencies>;

@@ -116,3 +127,5 @@ /**

*/
configure: <TComponent, TDependencies extends Record<string, unknown> = {}>(component: Component<TComponent, TDependencies> | TComponent) => SystemicBuild<T & { config: TComponent }, TDependencies>;
configure: <TComponent, TDependencies extends Record<string, unknown> = {}>(
component: Component<TComponent, TDependencies> | TComponent
) => SystemicBuild<T & { config: TComponent }, TDependencies>;

@@ -119,0 +132,0 @@ /**

const async = require('async');
const debug = require('debug')('systemic:index');
const format = require('util').format;
const { format } = require('util');
const Toposort = require('toposort-class');

@@ -88,3 +88,4 @@ const requireAll = require('require-all');

: Object.assign({}, { destination: arg.component }, arg);
if (!record.component) throw new Error(format('Component %s has an invalid dependency %s', currentDefinition.name, JSON.stringify(arg)));
if (!record.component)
throw new Error(format('Component %s has an invalid dependency %s', currentDefinition.name, JSON.stringify(arg)));
if (currentDefinition.dependencies.find((dep) => dep.destination === record.destination)) {

@@ -128,6 +129,6 @@ throw new Error(format('Component %s has a duplicate dependency %s', currentDefinition.name, record.destination));

started.push(name);
const component = definitions[name].component;
const onStarted = function (err, started) {
const { component } = definitions[name];
const onStarted = (err, c) => {
if (err) return cb(err);
setProp(system, name, started);
setProp(system, name, c);
debug('Component %s started', name);

@@ -165,4 +166,4 @@ setImmediate(() => {

debug('Stopping component %s', name);
const stop = definitions[name].component.stop || noop;
const onStopped = function (err) {
const stopFn = definitions[name].component.stop || noop;
const onStopped = (err) => {
if (err) return cb(err);

@@ -172,3 +173,3 @@ debug('Component %s stopped', name);

};
const p = stop(onStopped);
const p = stopFn(onStopped);
if (p && p.then) {

@@ -205,3 +206,4 @@ p.then(immediateCallback(onStopped)).catch(immediateError(cb));

(accumulator, dependency, cb) => {
if (!hasProp(definitions, dependency.component) && !dependency.optional) return cb(new Error(format('Component %s has an unsatisfied dependency on %s', name, dependency.component)));
if (!hasProp(definitions, dependency.component) && !dependency.optional)
return cb(new Error(format('Component %s has an unsatisfied dependency on %s', name, dependency.component)));
if (!hasProp(definitions, dependency.component)) {

@@ -212,5 +214,17 @@ debug('Skipping unsatisfied optional dependency %s for component %s', dependency.component, name);

if (!dependency.hasOwnProperty('source') && definitions[dependency.component].scoped) dependency.source = name;
dependency.source ? debug('Injecting dependency %s.%s as %s into %s', dependency.component, dependency.source, dependency.destination, name) : debug('Injecting dependency %s as %s into %s', dependency.component, dependency.destination, name);
dependency.source
? debug(
'Injecting dependency %s.%s as %s into %s',
dependency.component,
dependency.source,
dependency.destination,
name
)
: debug('Injecting dependency %s as %s into %s', dependency.component, dependency.destination, name);
const component = getProp(system, dependency.component);
setProp(accumulator, dependency.destination, dependency.source ? getProp(component, dependency.source) : component);
setProp(
accumulator,
dependency.destination,
dependency.source ? getProp(component, dependency.source) : component
);
cb(null, accumulator);

@@ -242,3 +256,3 @@ },

function immediateCallback(cb) {
return function (resolved) {
return (resolved) => {
setImmediate(() => {

@@ -251,3 +265,3 @@ cb(null, resolved);

function immediateError(cb, resolved) {
return function (err) {
return (err) => {
setImmediate(() => {

@@ -254,0 +268,0 @@ resolved ? cb(err, resolved) : cb(err);

{
"name": "systemic",
"version": "4.1.0",
"version": "4.1.1",
"description": "A minimal dependency injection library for node",

@@ -8,11 +8,9 @@ "main": "index.js",

"scripts": {
"qa": "npm run lint && npm test",
"lint": "lint-staged .",
"test": "node test",
"coverage": "nyc --report html --reporter lcov --reporter text-summary node test",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prettier": "prettier . --check",
"prettier:fix": "prettier . --write",
"test": "zUnit",
"coverage": "nyc --report html --reporter lcov --reporter text-summary zUnit",
"prepare": "husky install",
"release": "standard-version",
"release:major": "npm run release -- --release-as major",
"release:minor": "npm run release -- --release-as minor",
"release:patch": "npm run release -- --release-as patch",
"release:prerelease": "npm run release -- prerelease"

@@ -34,5 +32,6 @@ },

"devDependencies": {
"debug": "^4.3.3",
"eslint": "^8.11.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",

@@ -47,2 +46,3 @@ "husky": "^7.0.4",

"async": "^3.2.3",
"debug": "^4.3.4",
"require-all": "^3.0.0",

@@ -58,3 +58,4 @@ "toposort-class": "^1.0.1"

"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
"**/*": "prettier --write --ignore-unknown",
"**/*.js": "eslint --fix"
},

@@ -73,3 +74,6 @@ "repository": {

}
},
"zUnit": {
"pollute": true
}
}

@@ -15,3 +15,3 @@ <div style="display:flex; align-items:center; justify-content:center">

<a href="https://github.com/guidesmiths/systemic/actions?query=workflow%3A%22Node.js+CI%22" target="_blank"><img src="https://github.com/guidesmiths/systemic/workflows/Node.js%20CI/badge.svg" alt="Node.js CI" /></a>
<a href="https://snyk.io/advisor/npm-package/rascal" target="_blank"><img src="https://snyk.io/advisor/npm-package/systemic/badge.svg" alt="Systemic" /></a>
<a href="https://snyk.io/advisor/npm-package/systemic" target="_blank"><img src="https://snyk.io/advisor/npm-package/systemic/badge.svg" alt="Systemic" /></a>
<a href="https://codeclimate.com/github/guidesmiths/systemic" target="_blank"><img src="https://codeclimate.com/github/guidesmiths/systemic/badges/gpa.svg" alt="Code Climate" /></a>

@@ -466,3 +466,2 @@ <a href="https://codeclimate.com/github/guidesmiths/systemic/coverage" target="_blank"><img src="https://codeclimate.com/github/guidesmiths/systemic/badges/coverage.svg" alt="Test Coverage" /></a>

```
<!-- prettier-ignore-end -->
DEBUG='systemic:*' node system

@@ -488,3 +487,1 @@ systemic:index Adding component routes.admin to system routes +0ms

```
<!-- prettier-ignore-end -->

@@ -27,3 +27,6 @@ function randomName() {

const keyParts = key.split('.');
return !!obj && (keyParts.length > 1 ? hasProp(obj[key.split('.')[0]], keyParts.slice(1).join('.')) : obj.hasOwnProperty(key));
return (
!!obj &&
(keyParts.length > 1 ? hasProp(obj[key.split('.')[0]], keyParts.slice(1).join('.')) : obj.hasOwnProperty(key))
);
}

@@ -30,0 +33,0 @@

Sorry, the diff of this file is not supported yet

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