ezobjects
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -115,6 +115,16 @@ const ezobjects = require('./index'); | ||
test(arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return this._test; | ||
this._test = arg; | ||
/** Setter */ | ||
else if ( typeof arg == 'string' ) | ||
this._test = arg; | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.test(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
} | ||
@@ -121,0 +131,0 @@ } |
11
index.js
/** | ||
* @module ezobjects | ||
* @copyright 2018 Rich Lowe | ||
* @license MIT | ||
* @description Easy, automatic object creation from simple templates with strict typing | ||
*/ | ||
@@ -23,2 +25,3 @@ module.exports = (obj) => { | ||
/** Initializer */ | ||
init(data = {}) { | ||
@@ -57,2 +60,3 @@ if ( typeof super.init === 'function' ) | ||
if ( col.type == 'int' ) { | ||
/** Create class method on prototype */ | ||
parent[obj.name].prototype[col.name] = function (arg) { | ||
@@ -78,2 +82,3 @@ /** Getter */ | ||
else if ( col.type == 'float' ) { | ||
/** Create class method on prototype */ | ||
parent[obj.name].prototype[col.name] = function (arg) { | ||
@@ -99,2 +104,3 @@ /** Getter */ | ||
else if ( col.type == 'boolean' ) { | ||
/** Create class method on prototype */ | ||
parent[obj.name].prototype[col.name] = function (arg) { | ||
@@ -120,2 +126,3 @@ /** Getter */ | ||
else if ( col.type == 'string' ) { | ||
/** Create class method on prototype */ | ||
parent[obj.name].prototype[col.name] = function (arg) { | ||
@@ -128,3 +135,3 @@ /** Getter */ | ||
else if ( typeof arg == 'string' ) | ||
this[`_${col.name}`] = arg.toString(); | ||
this[`_${col.name}`] = arg; | ||
@@ -142,2 +149,3 @@ /** Handle type errors */ | ||
else if ( col.type == 'Array' ) { | ||
/** Create class method on prototype */ | ||
parent[obj.name].prototype[col.name] = function (arg) { | ||
@@ -163,2 +171,3 @@ /** Getter */ | ||
else { | ||
/** Create class method on prototype */ | ||
parent[obj.name].prototype[col.name] = function (arg) { | ||
@@ -165,0 +174,0 @@ /** Getter */ |
{ | ||
"name": "ezobjects", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Easy dynamic object generation with strict typing and set chaining", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# EZ Objects v1.0.0 | ||
# EZ Objects v1.0.1 | ||
@@ -246,6 +246,16 @@ Fully operational! Please open an issue for any bug reports or feature requests. | ||
test(arg) { | ||
/** Getter */ | ||
if ( arg === undefined ) | ||
return this._test; | ||
this._test = arg; | ||
/** Setter */ | ||
else if ( typeof arg == 'string' ) | ||
this._test = arg.toString(); | ||
/** Handle type errors */ | ||
else | ||
throw new TypeError(`${this.constructor.name}.test(${typeof arg}): Invalid signature.`); | ||
/** Return this object for set call chaining */ | ||
return this; | ||
} | ||
@@ -252,0 +262,0 @@ } |
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
17118
260
275