ezobjects
Advanced tools
Comparing version 2.9.1 to 2.10.0
const docket = require(`docket-parser`); | ||
docket.title(`EZ Objects v2.9.1`); | ||
docket.title(`EZ Objects v2.10.0`); | ||
docket.linkClass(`text-success`); | ||
docket.parseFiles([`index.js`, `mysql-connection.js`]); | ||
docket.generateDocs(`docs`); |
18
index.js
@@ -283,25 +283,29 @@ /** Require external modules */ | ||
obj.properties.forEach((property) => { | ||
/** If there is no init transform, set to default */ | ||
if ( typeof property.initTransform !== `function` ) | ||
property.initTransform = defaultTransform; | ||
/** Initialize 'number' types to zero */ | ||
if ( property.type == `number` ) | ||
this[property.name](data[property.name] || property.default || 0); | ||
this[property.name](property.initTransform(data[property.name]) || property.default || 0); | ||
/** Initialize 'boolean' types to false */ | ||
else if ( property.type == `boolean` ) | ||
this[property.name](data[property.name] || property.default || false); | ||
this[property.name](property.initTransform(data[property.name]) || property.default || false); | ||
/** Initialize 'string' types to empty */ | ||
else if ( property.type == `string` ) | ||
this[property.name](data[property.name] || property.default || ``); | ||
this[property.name](property.initTransform(data[property.name]) || property.default || ``); | ||
/** Initialize 'function' types to empty function */ | ||
else if ( property.type == `function` ) | ||
this[property.name](data[property.name] || property.default || emptyFunction); | ||
this[property.name](property.initTransform(data[property.name]) || property.default || emptyFunction); | ||
/** Initialize 'Array' types to empty */ | ||
else if ( property.type == `Array` ) | ||
this[property.name](data[property.name] || property.default || []); | ||
this[property.name](property.initTransform(data[property.name]) || property.default || []); | ||
/** Initialize all other types to null */ | ||
else | ||
this[property.name](data[property.name] || property.default || null); | ||
this[property.name](property.initTransform(data[property.name]) || property.default || null); | ||
}); | ||
@@ -312,3 +316,3 @@ } | ||
/** Loop through each property in the obj */ | ||
obj.properties.forEach((property) => { | ||
obj.properties.forEach((property) => { | ||
/** If there is no getter transform, set to default */ | ||
@@ -315,0 +319,0 @@ if ( typeof property.getTransform !== `function` ) |
{ | ||
"name": "ezobjects", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"description": "Easy dynamic object generation with optional MySQL table linking", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# EZ Objects v2.9.1 | ||
# EZ Objects v2.10.0 | ||
@@ -366,2 +366,3 @@ EZ Objects is a Node.js module (that can also be usefully browserify'd) that aims to save you lots of time | ||
* **default** - `mixed` - (optional) Sets the default value for the property in the class object | ||
* **initTransform** - `function` - (optional) Function that transforms and returns the property value prior to initializing (does not affect ezobjects or custom defaults) | ||
* **getTransform** - `function` - (optional) Function that transforms and returns the property value prior to getting | ||
@@ -368,0 +369,0 @@ * **setTransform** - `function` - (optional) Function that transforms and returns the property value prior to setting |
Sorry, the diff of this file is not supported yet
391511
2484
415