@exodus/module
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "@exodus/module", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Exodus base module implementation.", | ||
@@ -30,3 +30,3 @@ "author": "diegomura <diegomuracciole@gmail.com>", | ||
"@exodus/basic-utils": "^1.0.0", | ||
"events": "^1.1.1", | ||
"events": "^3.3.0", | ||
"lodash": "^4.17.11", | ||
@@ -36,5 +36,6 @@ "proxy-freeze": "^1.0.0" | ||
"devDependencies": { | ||
"eslint": "^8.33.0", | ||
"jest": "^29.1.2" | ||
}, | ||
"gitHead": "d293d2fc68887f11bd7a925cda043a2a01cc2899" | ||
"gitHead": "1a38fcc193bcc0fda4fb13b6025bc61470f5306d" | ||
} |
@@ -1,5 +0,4 @@ | ||
import EventEmitter from 'events/' // '/' forces it to use the module from node_modules | ||
import EventEmitter from 'events/' | ||
import { bindAll, clone, functions } from 'lodash' | ||
import { pick } from '@exodus/basic-utils' | ||
import { bindAll, functions } from 'lodash' | ||
import proxyFreeze from 'proxy-freeze' | ||
@@ -12,5 +11,3 @@ import { InvalidModuleError } from './errors' | ||
const dependencyInjectionFields = ['id', 'dependencies'] | ||
export default class ExodusModule extends EventEmitter { | ||
class ExodusModule extends EventEmitter { | ||
_name | ||
@@ -44,21 +41,2 @@ _logger | ||
const defineDependencyInjectionField = (target, field, value) => | ||
Object.defineProperty(target, field, { | ||
writable: false, | ||
value: Object.freeze(clone(value)), | ||
}) | ||
export const exportModuleFactoryFromConstructor = (Clazz) => { | ||
validateModule(Clazz) | ||
const factory = (opts) => new Clazz(pick(opts, Clazz.dependencies)) | ||
const dependencyInjectionFieldValues = pick(Clazz, dependencyInjectionFields) | ||
setDependencyInjectionFields(factory, dependencyInjectionFieldValues) | ||
validateModule(factory) | ||
return factory | ||
} | ||
// e.g. setDependencyInjectionFields(factory, { id, dependencies }) | ||
export const setDependencyInjectionFields = (factory, dependencyInjectionFieldValues) => | ||
dependencyInjectionFields.forEach((field) => | ||
defineDependencyInjectionField(factory, field, dependencyInjectionFieldValues[field]) | ||
) | ||
export default ExodusModule |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
3291
2
42
+ Addedevents@3.3.0(transitive)
- Removedevents@1.1.1(transitive)
Updatedevents@^3.3.0