@knowark/injectarkjs
Advanced tools
Comparing version 0.6.0 to 0.7.0
// Base Factory Interface | ||
export class Factory { | ||
/** @param {Object} config */ | ||
constructor(config = {}) { | ||
constructor (config = {}) { | ||
this.config = config | ||
this.allowed = [] | ||
} | ||
@@ -7,0 +8,0 @@ |
@@ -17,4 +17,12 @@ import { Factory } from './factory.js' // eslint-disable-line | ||
get (resource) { | ||
const allowed = this.factory.allowed | ||
if (allowed?.length && !allowed.includes(resource)) { | ||
throw new Error(`Direct access to "${resource}" is not allowed.`) | ||
} | ||
return this.resolve(resource, true) | ||
} | ||
/** @param {string} resource */ | ||
resolve (resource) { | ||
resolve (resource, strict = false) { | ||
const fetched = this._registryFetch(resource) | ||
@@ -29,2 +37,6 @@ if (fetched) { | ||
if (strict && !instance) { | ||
throw new Error(`The "${resource}" resource could not be resolved.`) | ||
} | ||
return instance | ||
@@ -63,3 +75,3 @@ } | ||
let extract = this.factory.extract.bind(this.factory) | ||
const extract = this.factory.extract.bind(this.factory) | ||
const builder = extract(rule.method) | ||
@@ -94,4 +106,4 @@ | ||
_parseDependencies (builder) { | ||
const stripComments = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; | ||
const argumentNames = /([^\s,]+)/g; | ||
const stripComments = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg | ||
const argumentNames = /([^\s,]+)/g | ||
const functionString = builder.toString().replace(stripComments, '') | ||
@@ -98,0 +110,0 @@ const result = functionString.slice(functionString.indexOf( |
{ | ||
"name": "@knowark/injectarkjs", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Dependency Injector for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
16082
9
434
1