Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decorateMember(decorators: (PropertyDecorator | MethodDecorator)[], target: object, propertyKey: PropertyKey, descriptor?: PropertyDescriptor): PropertyDescriptor | undefined {
if (typeof propertyKey !== "symbol") propertyKey = "" + propertyKey;
for (let i = decorators.length - 1; i >= 0; i--) {
const decorator = decorators[i];
const decorated = decorator(target, propertyKey, descriptor!);
if (isDefined(decorated)) {
if (!isObject(decorated)) throw new TypeError();
descriptor = decorated;
}
}
return descriptor;
}
export function hasInstance(value: unknown): value is Disposable {
return isObject(value)
&& dispose in value;
}
export function hasInstance(value: unknown): value is AsyncLockable {
return isObject(value)
&& AsyncLockable.lock in value
&& AsyncLockable.unlock in value;
}
}
export function hasInstance(value: unknown): value is Lockable {
return isObject(value)
&& Lockable.lock in value
&& Lockable.unlock in value
&& (!(Lockable.tryLock in value) || !isDefined(Lockable.tryLock) || isFunction(Lockable.tryLock));
}
}