ezobjects
Advanced tools
Comparing version 2.10.6 to 2.11.0
const docket = require(`docket-parser`); | ||
docket.title(`EZ Objects v2.10.6`); | ||
docket.title(`EZ Objects v2.11.0`); | ||
docket.linkClass(`text-success`); | ||
docket.parseFiles([`index.js`, `mysql-connection.js`]); | ||
docket.generateDocs(`docs`); |
166
index.js
@@ -69,3 +69,3 @@ /** Require external modules */ | ||
throw new Error(`Property of type VARBINARY used without required length.`); | ||
else if ( mysqlTypesWithLengthRequiringDecimals.includes(property.type) && !isNaN(property.length) && isNaN(property.decimals) ) | ||
else if ( mysqlTypesWithLengthRequiringDecimals.includes(property.mysqlType) && !isNaN(property.length) && isNaN(property.decimals) ) | ||
throw new Error(`Property of type REAL, DOUBLE, or FLOAT used with length, but without decimals.`); | ||
@@ -293,19 +293,19 @@ | ||
/** Initialize 'number' types to zero */ | ||
if ( property.type == `number` ) | ||
if ( property.type && property.type.split(`|`).includes(`number`) ) | ||
this[property.name](property.initTransform(data[property.name]) || property.default || 0); | ||
/** Initialize 'boolean' types to false */ | ||
else if ( property.type == `boolean` ) | ||
else if ( property.type && property.type.split(`|`).includes(`boolean`) ) | ||
this[property.name](property.initTransform(data[property.name]) || property.default || false); | ||
/** Initialize 'string' types to empty */ | ||
else if ( property.type == `string` ) | ||
else if ( property.type && property.type.split(`|`).includes(`string`) ) | ||
this[property.name](property.initTransform(data[property.name]) || property.default || ``); | ||
/** Initialize 'function' types to empty function */ | ||
else if ( property.type == `function` ) | ||
else if ( property.type && property.type.split(`|`).includes(`function`) ) | ||
this[property.name](property.initTransform(data[property.name]) || property.default || emptyFunction); | ||
/** Initialize 'Array' types to empty */ | ||
else if ( property.type == `Array` ) | ||
else if ( property.type && property.type.split(`|`).includes(`Array`) ) | ||
this[property.name](property.initTransform(data[property.name]) || property.default || []); | ||
@@ -338,128 +338,42 @@ | ||
/** For `number` type properties */ | ||
if ( property.type == `number` ) { | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Setter */ | ||
else if ( typeof arg == `number` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Setters */ | ||
/** For `number` type properties */ | ||
else if ( property.type && property.type.split(`|`).includes(`number`) && typeof arg == `number` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** For `boolean` type properties */ | ||
else if ( property.type && property.type.split(`|`).includes(`boolean`) && typeof arg == `boolean` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** For `string` type properties */ | ||
else if ( property.type && property.type.split(`|`).includes(`string`) && typeof arg == `string` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** For `function` type properties */ | ||
else if ( property.type && property.type.split(`|`).includes(`function`) && typeof arg == `function` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** For `Array` type propeties */ | ||
else if ( property.type && property.type.split(`|`).includes(`Array`) && typeof arg == `object` && arg.constructor.name == `Array` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
} | ||
/** For all other property types */ | ||
else if ( arg === null || ( typeof arg == `object` && property.type && property.type.split(`|`).includes(arg.constructor.name) ) || ( typeof property.instanceOf == `string` && property.instanceOf.split(`|`).some(x => module.exports.instanceOf(arg, x)) ) ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** For `boolean` type properties */ | ||
else if ( property.type == `boolean` ) { | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** Setter */ | ||
else if ( typeof arg == `boolean` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
} | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
/** For `string` type properties */ | ||
else if ( property.type == `string` ) { | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Setter */ | ||
else if ( typeof arg == `string` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
} | ||
/** For `function` type properties */ | ||
else if ( property.type == `function` ) { | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Setter */ | ||
else if ( typeof arg == `function` ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
} | ||
/** For `Array` type properties */ | ||
else if ( property.type == `Array` ) { | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Setter */ | ||
else if ( typeof arg == `object` && arg.constructor.name == property.type ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
} | ||
/** For all other property types */ | ||
else { | ||
/** Create class method on prototype */ | ||
parent[obj.className].prototype[property.name] = function (arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return property.getTransform(this[`_${property.name}`]); | ||
/** Setter */ | ||
else if ( arg === null || ( typeof arg == `object` && arg.constructor.name == property.type ) || ( typeof property.instanceOf == `string` && module.exports.instanceOf(arg, property.instanceOf) ) ) | ||
this[`_${property.name}`] = property.setTransform(arg); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.${property.name}(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
}; | ||
} | ||
if ( typeof obj.tableName == `string` ) { | ||
@@ -466,0 +380,0 @@ /** Create MySQL delete method on prototype */ |
{ | ||
"name": "ezobjects", | ||
"version": "2.10.6", | ||
"version": "2.11.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.10.6 | ||
# EZ Objects v2.11.0 | ||
@@ -3,0 +3,0 @@ EZ Objects is a Node.js module (that can also be usefully browserify'd) that aims to save you lots of time |
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
389513
2415