Comparing version 0.1.20 to 0.1.21
@@ -10,11 +10,9 @@ import {Constructor} from './types'; | ||
/** | ||
* https://www.typescriptlang.org/docs/handbook/mixins.html | ||
* @param targetConstructor Target constructor of which the prototype will be | ||
* applied with properties from other constructors. | ||
* Mixin class decorator, applies properties from other class to the decorator | ||
* target. You still need to use declaration merging to merge mixin interface | ||
* with the target class. | ||
* | ||
* @param constructors Constructors of which the properties will be applied to | ||
* the target constructor. | ||
*/ | ||
export function mixin( | ||
targetConstructor: Constructor, | ||
constructors: Constructor[], | ||
): void; | ||
export function mixin(constructors: Function[]): ClassDecorator; |
@@ -10,16 +10,19 @@ /* eslint-disable @magicspace/scoped-modules */ | ||
/** | ||
* @param targetConstructor {Constructor} | ||
* @param constructors {Constructor[]} | ||
* @returns {ClassDecorator} | ||
*/ | ||
exports.mixin = function mixin(targetConstructor, constructors) { | ||
let targetPrototype = targetConstructor.prototype; | ||
exports.mixin = function mixin(constructors) { | ||
return targetConstructor => { | ||
let targetPrototype = targetConstructor.prototype; | ||
for (let constructor of constructors) { | ||
let prototype = constructor.prototype; | ||
for (let constructor of constructors) { | ||
let prototype = constructor.prototype; | ||
Object.defineProperties( | ||
targetPrototype, | ||
Object.getOwnPropertyDescriptors(prototype), | ||
); | ||
} | ||
let descriptors = Object.getOwnPropertyDescriptors(prototype); | ||
delete descriptors.constructor; | ||
Object.defineProperties(targetPrototype, descriptors); | ||
} | ||
}; | ||
}; |
{ | ||
"name": "tslang", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"description": "TypeScript Language Type Utilities.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
11941
341