ezobjects
Advanced tools
Comparing version 5.2.3 to 5.3.0
@@ -47,2 +47,3 @@ const ezobjects = require('./index'); | ||
{ name: 'exampleSet', type: 'set' }, | ||
{ name: 'examplePlainObject', type: 'object' }, | ||
{ name: 'exampleOtherObj', type: 'BasicExample' }, | ||
@@ -58,2 +59,3 @@ | ||
{ name: 'exampleSetArray', type: 'array', arrayOf: { type: 'set' } }, | ||
{ name: 'examplePlainObjectArray', type: 'array', arrayOf: { type: 'object' } }, | ||
{ name: 'exampleOtherObjArray', type: 'array', arrayOf: { type: 'BasicExample' } } | ||
@@ -77,2 +79,3 @@ ] | ||
exampleSet: new Set(['14', 3, false]), | ||
examplePlainObject: { a: 'I am A', 14: 'Plain Object' }, | ||
exampleOtherObj: basicExample1, | ||
@@ -88,2 +91,3 @@ | ||
exampleSetArray: [new Set(['14', 3, false]), new Set([-14, true, 'pool'])], | ||
examplePlainObjectArray: [{ a: 'I am A', 14: 'Plain Object' }, { and: 'So am I too a', 930: 'Plain Object' }], | ||
exampleOtherObjArray: [basicExample1, basicExample2] | ||
@@ -90,0 +94,0 @@ }); |
const docket = require(`docket-parser`); | ||
docket.title(`EZ Objects v5.2.3`); | ||
docket.title(`EZ Objects v5.3.0`); | ||
docket.linkClass(`text-success`); | ||
docket.parseFiles([`index.js`]); | ||
docket.generateDocs(`docs`); |
@@ -36,2 +36,4 @@ /** | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Set value passed to '${property.type}' setter.`); | ||
else if ( x && property.ezobjectType.jsType == 'Object' && ( typeof x !== 'object' || x.constructor.type == 'Object' ) ) | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Object value passed to '${property.type}' setter.`); | ||
else if ( x && property.ezobjectType.jsType == 'object' && ( typeof x !== 'object' || ( typeof property.type == 'string' && x.constructor.name != property.originalType ) || ( typeof property.instanceOf === 'string' && !module.exports.instanceOf(x, property.instanceOf) ) ) ) | ||
@@ -75,2 +77,4 @@ throw new TypeError(`${property.className}.${property.name}(): Invalid value passed to '${typeof property.type === 'string' ? property.originalType : property.instanceOf}' setter.`); | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Set value passed as element of Array[${property.arrayOf.type}] setter.`); | ||
else if ( property.ezobjectType.jsType == 'Object' && x && x.some(y => ( typeof y !== 'object' || y.constructor.name != 'Object' ) && y !== null) ) | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Object value passed as element of Array[${property.arrayOf.type}] setter.`); | ||
else if ( property.ezobjectType.jsType == 'object' && x && x.some(y => y !== null && (typeof y !== 'object' || ( typeof property.arrayOf.type == 'string' && y.constructor.name != property.arrayOf.type ) || ( typeof property.arrayOf.instanceOf === 'string' && !module.exports.instanceOf(y, property.arrayOf.instanceOf) ))) ) | ||
@@ -116,2 +120,3 @@ throw new TypeError(`${property.className}.${property.name}(): Invalid value passed as element of Array[${typeof property.arrayOf.type === 'string' ? property.arrayOf.type : property.arrayOf.instanceOf}] setter.`); | ||
{ type: `set`, jsType: 'Set', default: new Set(), setTransform: setTransform }, | ||
{ type: `object`, jsType: `Object`, default: {}, setTransform: setTransform }, | ||
{ type: `other`, jsType: 'object', default: null, setTransform: setTransform }, | ||
@@ -127,2 +132,3 @@ | ||
{ type: `array`, jsType: 'Array', default: [], arrayOfType: `set`, setTransform: setArrayTransform }, | ||
{ type: `array`, jsType: 'Array', default: [], arrayOfType: `object`, setTransform: setArrayTransform }, | ||
{ type: `array`, jsType: `Array`, default: [], arrayOfType: `other`, setTransform: setArrayTransform } | ||
@@ -129,0 +135,0 @@ ]; |
{ | ||
"name": "ezobjects", | ||
"version": "5.2.3", | ||
"version": "5.3.0", | ||
"description": "Easy Auto-Generated Strictly-Typed JavaScript Class Objects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# EZ Objects v5.2.3 | ||
# EZ Objects v5.3.0 | ||
@@ -73,2 +73,3 @@ EZ Objects is a Node.js module (that can also be usefully browserify'd) that aims to save you lots of time | ||
{ name: 'exampleSet', type: 'set' }, | ||
{ name: 'examplePlainObject', type: 'object' }, | ||
{ name: 'exampleOtherObj', type: 'BasicExample' }, | ||
@@ -84,2 +85,3 @@ | ||
{ name: 'exampleSetArray', type: 'array', arrayOf: { type: 'set' } }, | ||
{ name: 'examplePlainObjectArray', type: 'array', arrayOf: { type: 'object' } }, | ||
{ name: 'exampleOtherObjArray', type: 'array', arrayOf: { type: 'BasicExample' } } | ||
@@ -103,2 +105,3 @@ ] | ||
exampleSet: new Set(['14', 3, false]), | ||
examplePlainObject: { a: 'I am A', 14: 'Plain Object' }, | ||
exampleOtherObj: basicExample1, | ||
@@ -114,2 +117,3 @@ | ||
exampleSetArray: [new Set(['14', 3, false]), new Set([-14, true, 'pool'])], | ||
examplePlainObjectArray: [{ a: 'I am A', 14: 'Plain Object' }, { and: 'So am I too a', 930: 'Plain Object' }], | ||
exampleOtherObjArray: [basicExample1, basicExample2] | ||
@@ -144,3 +148,3 @@ }); | ||
_exampleInt: 293, | ||
_exampleFloat: 194.13489, | ||
_exampleFloat: 194, | ||
_exampleString: 'What\'s up, doc?', | ||
@@ -152,5 +156,6 @@ _exampleBoolean: true, | ||
_exampleSet: Set { '14', 3, false }, | ||
_examplePlainObject: { '14': 'Plain Object', a: 'I am A' }, | ||
_exampleOtherObj: BasicExample { _name: 'Basic Example 1' }, | ||
_exampleIntArray: [ 293, -178, 492 ], | ||
_exampleFloatArray: [ 194.13489, -2890.25, -0.04281 ], | ||
_exampleFloatArray: [ 194, -2890, 0 ], | ||
_exampleStringArray: [ 'What\'s up, doc?', 'Shiver me timbers' ], | ||
@@ -163,3 +168,6 @@ _exampleBooleanArray: [ true, false, true ], | ||
<Buffer 41 20 73 74 72 69 6e 67 20 69 6e 73 74 65 61 64> ], | ||
_exampleSetArray: [ [ [Set], [Set] ], [ [Set], [Set] ] ], | ||
_exampleSetArray: [ Set { '14', 3, false }, Set { -14, true, 'pool' } ], | ||
_examplePlainObjectArray: | ||
[ { '14': 'Plain Object', a: 'I am A' }, | ||
{ '930': 'Plain Object', and: 'So am I too a' } ], | ||
_exampleOtherObjArray: | ||
@@ -224,7 +232,7 @@ [ BasicExample { _name: 'Basic Example 1' }, | ||
* **name** - `string` - (required) Name of the property, must conform to JavaScript rules | ||
* **type** - `string` - (optional) EZ Object type that the property must be equal to -- types can be `int`, `float`, `string`, `boolean`, `date`, `buffer`, `set`, `function`, any other valid object constructor name, or `array` where `arrayOf` is provided with information about the array element types. \[either **type** or **instanceOf** is required] | ||
* **type** - `string` - (optional) EZ Object type that the property must be equal to -- types can be `int`, `float`, `string`, `boolean`, `date`, `buffer`, `set`, `function`, `object`, any other valid object constructor name, or `array` where `arrayOf` is provided with information about the array element types. \[either **type** or **instanceOf** is required] | ||
* **instanceOf** - `string` - (optional) JavaScript class constructor name, that the property must be an instance of \[either **type** or **instanceOf** is required] | ||
* **default** - `mixed` - (optional) Sets the default value for the property in the class object | ||
* **allowNull** - `boolean` - (optional) Indicates the property can be null, default is that only plain objects and custom object types are nullable | ||
* **arrayOf** - `object` - (required for type `array`) A plain object containing he EZ Object `type` or `instanceOf` of the elements of the array -- types can be `int`, `float`, `string`, `boolean`, `date`, `buffer`, `set`, `function`, or any other valid object constructor name (which can alternatively be used with `instanceOf` instead). \[either **type** or **instanceOf** is required] | ||
* **arrayOf** - `object` - (required for type `array`) A plain object containing he EZ Object `type` or `instanceOf` of the elements of the array -- types can be `int`, `float`, `string`, `boolean`, `date`, `buffer`, `set`, `function`, `object`, or any other valid object constructor name (which can alternatively be used with `instanceOf` instead). \[either **type** or **instanceOf** is required] | ||
* **setTransform(x, propertyConfig)** - `function` - (optional) Function that transforms and returns the property value prior to setting | ||
@@ -242,2 +250,3 @@ | ||
* `set` - `new Set()` | ||
* `object` - `{}` | ||
* `array` - `[]` | ||
@@ -244,0 +253,0 @@ * others - `null` |
Sorry, the diff of this file is not supported yet
340279
1591
254