lodash-decorators
Advanced tools
Comparing version 4.3.2 to 4.3.3
@@ -5,2 +5,3 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var factory_1 = require("./factory"); | ||
/** | ||
@@ -55,2 +56,10 @@ * Binds methods of an object to the object itself, overwriting the existing method. | ||
if (include && key !== 'constructor' && !instance.hasOwnProperty(key)) { | ||
// If this property is a getter and it's NOT an instance decorated | ||
// method, ignore it. Instance decorators are getters until first accessed. | ||
if (descriptor.get) { | ||
var chainData = factory_1.InstanceChainMap.get([proto, key]); | ||
if (!chainData || !chainData.isMethod) { | ||
continue; | ||
} | ||
} | ||
var value = instance[key]; | ||
@@ -57,0 +66,0 @@ if (isFunction(value)) { |
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="4.3.3"></a> | ||
## [4.3.3](https://github.com/steelsojka/lodash-decorators/compare/v4.3.2...v4.3.3) (2017-05-19) | ||
### Bug Fixes | ||
* **bindAll:** fix bind all should only apply to methods ([4b86629](https://github.com/steelsojka/lodash-decorators/commit/4b86629)) | ||
<a name="4.3.2"></a> | ||
@@ -7,0 +17,0 @@ ## [4.3.2](https://github.com/steelsojka/lodash-decorators/compare/v4.3.1...v4.3.2) (2017-05-19) |
@@ -16,2 +16,10 @@ import { Applicator } from '../applicators'; | ||
} | ||
export declare const InstanceChainMap: CompositeKeyWeakMap<Function[]>; | ||
export interface InstanceChainData { | ||
properties: string[]; | ||
fns: Function[]; | ||
isGetter: boolean; | ||
isSetter: boolean; | ||
isMethod: boolean; | ||
isProperty: boolean; | ||
} | ||
export declare const InstanceChainMap: CompositeKeyWeakMap<InstanceChainData>; |
@@ -49,3 +49,3 @@ "use strict"; | ||
var isFirstInstance = !common_1.InstanceChainMap.has([target, name]); | ||
var fnChain = common_1.InstanceChainMap.get([target, name]) || []; | ||
var chainData = common_1.InstanceChainMap.get([target, name]) || { fns: [], properties: [] }; | ||
var isGetter = isFirstInstance && isFunction(get); | ||
@@ -55,3 +55,4 @@ var isSetter = isFirstInstance && isFunction(set); | ||
var isProperty = isFirstInstance && !isGetter && !isSetter && !isMethod; | ||
fnChain.push(function (fn, instance, context) { | ||
chainData.properties.push(name); | ||
chainData.fns.push(function (fn, instance, context) { | ||
if (!_this._isApplicable(context, config)) { | ||
@@ -65,8 +66,12 @@ return fn; | ||
}); | ||
common_1.InstanceChainMap.set([target, name], fnChain); | ||
common_1.InstanceChainMap.set([target, name], chainData); | ||
if (!isFirstInstance) { | ||
return descriptor; | ||
} | ||
chainData.isSetter = isSetter; | ||
chainData.isGetter = isGetter; | ||
chainData.isMethod = isMethod; | ||
chainData.isProperty = isProperty; | ||
var applyChain = function (fn, context, instance) { | ||
return fnChain.reduce(function (result, next) { return next(result, instance, context); }, fn); | ||
return chainData.fns.reduce(function (result, next) { return next(result, instance, context); }, fn); | ||
}; | ||
@@ -73,0 +78,0 @@ var applyDecorator = function (instance) { |
@@ -5,3 +5,3 @@ { | ||
"description": "A collection of decorators using lodash at it's core.", | ||
"version": "4.3.2", | ||
"version": "4.3.3", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">=0.12.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
137766
2455