Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const deco = (target: DependencyCtor & { inject?: any }) => {
if (!target.hasOwnProperty('inject')) {
target.inject = (
(metadata.getOwn(metadata.paramTypes, target) as Array) ||
_emptyParameters
).slice();
if (target.inject && target.inject.length > 0) {
// TypeScript 3.0 metadata for "...rest" gives type "Object"
// if last parameter is "Object", assume it's a ...rest and remove that
// metadata.
if (target.inject[target.inject.length - 1] === Object) {
target.inject.splice(-1, 1);
}
}
}
};
let deco = function(target) {
if (!target.hasOwnProperty('inject')) {
target.inject = (metadata.getOwn(metadata.paramTypes, target) || _emptyParameters).slice();
// TypeScript 3.0 metadata for "...rest" gives type "Object"
// if last parameter is "Object", assume it's a ...rest and remove that metadata.
if (target.inject.length > 0 &&
target.inject[target.inject.length - 1] === Object) {
target.inject.pop();
}
}
};
_createInvocationHandler(fn) {
let dependencies;
if (fn.inject === undefined) {
dependencies =
metadata.getOwn(metadata.paramTypes, fn) || _emptyParameters;
}
else {
dependencies = [];
let ctor = fn;
while (typeof ctor === 'function') {
dependencies.push(...getDependencies(ctor));
ctor = Object.getPrototypeOf(ctor);
}
}
const invoker = metadata.getOwn(metadata.invoker, fn) || classInvoker;
const handler = new InvocationHandler(fn, invoker, dependencies);
return this._onHandlerCreated !== undefined
? this._onHandlerCreated(handler)
: handler;
}
}
_createInvocationHandler(fn: Function & { inject?: any }): InvocationHandler {
let dependencies;
if (fn.inject === undefined) {
dependencies = metadata.getOwn(metadata.paramTypes, fn) || _emptyParameters;
} else {
dependencies = [];
let ctor = fn;
while (typeof ctor === 'function') {
dependencies.push(...getDependencies(ctor));
ctor = Object.getPrototypeOf(ctor);
}
}
let invoker = metadata.getOwn(metadata.invoker, fn)
|| classInvokers[dependencies.length] || classInvokers.fallback;
let handler = new InvocationHandler(fn, invoker, dependencies);
return this._onHandlerCreated !== undefined ? this._onHandlerCreated(handler) : handler;
}
}
let deco = function(target) {
target.inject = metadata.getOwn(metadata.paramTypes, target) || _emptyParameters;
};
export function getDecoratorDependencies(target, name) {
if (!target.hasOwnProperty('inject')) {
Object.defineProperty(target, 'inject', {value: undefined, writable: true});
}
let dependencies = target.inject;
if (typeof dependencies === 'function') {
throw new Error('Decorator ' + name + ' cannot be used with "inject()". Please use an array instead.');
}
if (!dependencies) {
dependencies = metadata.getOwn(metadata.paramTypes, target).slice();
target.inject = dependencies;
}
return dependencies;
}
Container.prototype._createInvocationHandler = function (fn) {
var dependencies;
if (fn.inject === undefined) {
dependencies =
metadata.getOwn(metadata.paramTypes, fn) || _emptyParameters;
}
else {
dependencies = [];
var ctor = fn;
while (typeof ctor === 'function') {
dependencies.push.apply(dependencies, getDependencies(ctor));
ctor = Object.getPrototypeOf(ctor);
}
}
var invoker = metadata.getOwn(metadata.invoker, fn) || classInvoker;
var handler = new InvocationHandler(fn, invoker, dependencies);
return this._onHandlerCreated !== undefined
? this._onHandlerCreated(handler)
: handler;
};
return Container;
_copyInheritedProperties(container, target) {
let behavior;
let derived = target;
while (true) {
let proto = Object.getPrototypeOf(target.prototype);
target = proto && proto.constructor;
if (!target) {
return;
}
behavior = metadata.getOwn(metadata.resource, target);
if (behavior) {
break;
}
}
behavior.initialize(container, target);
for (let i = 0, ii = behavior.properties.length; i < ii; ++i) {
let prop = behavior.properties[i];
if (this.properties.some(p => p.name === prop.name)) {
continue;
}
new BindableProperty(prop).registerWith(derived, this);
}
}
};
const deco = (target) => {
if (!target.hasOwnProperty('inject')) {
target.inject = (metadata.getOwn(metadata.paramTypes, target) ||
_emptyParameters).slice();
if (target.inject && target.inject.length > 0) {
if (target.inject[target.inject.length - 1] === Object) {
target.inject.splice(-1, 1);
}
}
}
};
if (isInjectable(potentialTarget)) {