diff --git a/README.md b/README.md index 9d06168..f0aa4be 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## About -This package is for the Modifiers class orinally created for the Reldens project, but now it can be used anywhere. +This package is for the Modifiers class originally created for the Reldens project, but now it can be used anywhere. By implementing this package you will get: - The Modifier class which is a helper to apply and revert values into an specific target properties. - The Conditions class which is a helper to avoid an action only if the condition is satisfied. diff --git a/lib/condition.js b/lib/condition.js index b1225be..659886b 100644 --- a/lib/condition.js +++ b/lib/condition.js @@ -28,7 +28,7 @@ class Condition this.key = props.key; this.propertyKey = props.propertyKey; this.conditional = props.conditional; - this.type = sc.hasOwn(props, 'type') ? props.type : ModifierConst.TYPES.INT; + this.type = sc.get(props, 'type', ModifierConst.TYPES.INT); this.value = this.parseValue(props.value); this.propertyManager = new PropertyManager(); } diff --git a/lib/modifier.js b/lib/modifier.js index 0d49ecf..5d5a072 100644 --- a/lib/modifier.js +++ b/lib/modifier.js @@ -27,21 +27,20 @@ class Modifier ]); } this.key = props.key; - this.propertyKey = props.propertyKey ? props.propertyKey : props.property_key; - this.basePropertyKey = props.basePropertyKey ? props.basePropertyKey : this.propertyKey; + this.propertyKey = sc.get(props, 'propertyKey', props.property_key); + this.basePropertyKey = sc.get(props, 'basePropertyKey', this.propertyKey); this.operation = props.operation; - this.type = sc.hasOwn(props, 'type') ? props.type : ModifierConst.TYPES.INT; + this.type = sc.get(props, 'type', ModifierConst.TYPES.INT); this.value = this.parseValue(props.value); this.originalValue = props.value; - this.target = sc.hasOwn(props, 'target') ? props.target : false; + this.target = sc.get(props, 'target', false); this.minValue = sc.hasOwn(props, 'minValue') ? this.parseValue(props.minValue) : false; this.maxValue = sc.hasOwn(props, 'maxValue') ? this.parseValue(props.maxValue) : false; - this.minProperty = sc.getDef(props, 'minProperty', false); - this.maxProperty = sc.getDef(props, 'maxProperty', false); + this.minProperty = sc.get(props, 'minProperty', false); + this.maxProperty = sc.get(props, 'maxProperty', false); // array of conditions objects: - this.conditions = sc.hasOwn(props, 'conditions') ? props.conditions : []; - this.conditionsOnRevert = sc.hasOwn(props, 'conditionsOnRevert') - ? props.conditionsOnRevert : false; + this.conditions = sc.get(props, 'conditions', []); + this.conditionsOnRevert = sc.get(props, 'conditionsOnRevert', false); this.state = false; this.calculator = new Calculator(); this.propertyManager = new PropertyManager(); @@ -73,7 +72,7 @@ class Modifier * Here you have two specific attributes for special features, useBasePropertyToGetValue and applyOnBaseProperty. * When useBasePropertyToGetValue is true then the modifier will use the basePropertyKey to calculate the modified * value. - * Beside that, no matter from which value your start the calculations then you can use the applyOnBaseProperty + * Besides, no matter from which value your start the calculations then you can use the applyOnBaseProperty * property to specify if you want to apply the new calculated value to the propertyKey or to the basePropertyKey. * */ diff --git a/package.json b/package.json index 587d836..dce1b38 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@reldens/modifiers", "scope": "@reldens", - "version": "0.4.7", + "version": "0.11.0", "description": "Reldens - Modifiers", "author": "Damian A. Pastorini", "license": "MIT", @@ -33,6 +33,6 @@ "url": "https://github.com/damian-pastorini/reldens-modifiers/issues" }, "dependencies": { - "@reldens/utils": "^0.4.3" + "@reldens/utils": "^0.11.0" } }