manyfest 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "manyfest",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "JSON Object Manifest for Data Description and Parsing",
5
5
  "main": "source/Manyfest.js",
6
6
  "scripts": {
@@ -62,7 +62,7 @@ class ManyfestHashTranslation
62
62
 
63
63
  removeTranslationHash(pTranslationHash)
64
64
  {
65
- if (this.translationTable.hasOwnProperty(pTranslationHash))
65
+ if (pTranslationHash in this.translationTable)
66
66
  {
67
67
  delete this.translationTable[pTranslationHash];
68
68
  }
@@ -103,7 +103,7 @@ class ManyfestHashTranslation
103
103
 
104
104
  translate(pTranslation)
105
105
  {
106
- if (this.translationTable.hasOwnProperty(pTranslation))
106
+ if (pTranslation in this.translationTable)
107
107
  {
108
108
  return this.translationTable[pTranslation];
109
109
  }
@@ -82,7 +82,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
82
82
  {
83
83
  let tmpFunctionAddress = pAddress.substring(0, tmpFunctionStartIndex).trim();
84
84
 
85
- if ((pObject.hasOwnProperty(tmpFunctionAddress)) && (typeof(pObject[tmpFunctionAddress]) == 'function'))
85
+ if (((tmpFunctionAddress in pObject)) && (typeof(pObject[tmpFunctionAddress]) == 'function'))
86
86
  {
87
87
  return true;
88
88
  }
@@ -143,7 +143,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
143
143
  tmpBoxedPropertyReference = this.cleanWrapCharacters("'", tmpBoxedPropertyReference);
144
144
 
145
145
  // Check if the property exists.
146
- return pObject[tmpBoxedPropertyName].hasOwnProperty(tmpBoxedPropertyReference);
146
+ return (tmpBoxedPropertyReference in pObject[tmpBoxedPropertyName]);
147
147
  }
148
148
  else
149
149
  {
@@ -154,7 +154,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
154
154
  else
155
155
  {
156
156
  // Check if the property exists
157
- return pObject.hasOwnProperty(pAddress);
157
+ return (pAddress in pObject);
158
158
  }
159
159
  }
160
160
  else
@@ -284,11 +284,11 @@ class ManyfestObjectAddressResolverCheckAddressExists
284
284
 
285
285
  // If there is an object property already named for the sub object, but it isn't an object
286
286
  // then the system can't set the value in there. Error and abort!
287
- if (pObject.hasOwnProperty(tmpSubObjectName) && typeof(pObject[tmpSubObjectName]) !== 'object')
287
+ if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
288
288
  {
289
289
  return false;
290
290
  }
291
- else if (pObject.hasOwnProperty(tmpSubObjectName))
291
+ else if (tmpSubObjectName in pObject)
292
292
  {
293
293
  // If there is already a subobject pass that to the recursive thingy
294
294
  return this.checkAddressExists(pObject[tmpSubObjectName], tmpNewAddress, tmpRootObject);
@@ -329,11 +329,11 @@ class ManyfestObjectAddressResolverDeleteValue
329
329
 
330
330
  // If there is an object property already named for the sub object, but it isn't an object
331
331
  // then the system can't set the value in there. Error and abort!
332
- if (pObject.hasOwnProperty(tmpSubObjectName) && typeof(pObject[tmpSubObjectName]) !== 'object')
332
+ if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
333
333
  {
334
334
  return undefined;
335
335
  }
336
- else if (pObject.hasOwnProperty(tmpSubObjectName))
336
+ else if (tmpSubObjectName in pObject)
337
337
  {
338
338
  // If there is already a subobject pass that to the recursive thingy
339
339
  // Continue to manage the parent address for recursion
@@ -163,20 +163,24 @@ class ManyfestObjectAddressResolverGetValue
163
163
  // Now get the value for each argument
164
164
  for (let i = 0; i < tmpFunctionArguments.length; i++)
165
165
  {
166
- if(tmpFunctionArguments[i][0] == "'" && tmpFunctionArguments[i][tmpFunctionArguments[i].length - 1] == "'")
167
- {
168
- tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length - 1));
169
- }
170
- else if(tmpFunctionArguments[i][0] == '"' && tmpFunctionArguments[i][tmpFunctionArguments[i].length - 1] == '"')
171
- {
172
- tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length - 1));
173
- }
174
- else if(tmpFunctionArguments[i][0] == "`" && tmpFunctionArguments[i][tmpFunctionArguments[i].length - 1] == "`")
166
+ // Resolve the values for each subsequent entry
167
+ // Check if the argument value is a string literal or a reference to an address
168
+ if ((tmpFunctionArguments[i].length >= 2)
169
+ &&
170
+ ((tmpFunctionArguments[i].charAt(0) == '"')
171
+ || (tmpFunctionArguments[i].charAt(0) == "'")
172
+ || (tmpFunctionArguments[i].charAt(0) == "`"))
173
+ &&
174
+ ((tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == '"')
175
+ || (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "'")
176
+ || (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "`")))
175
177
  {
176
- tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length - 1));
178
+ // This is a string literal
179
+ tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length-1));
177
180
  }
178
181
  else
179
182
  {
183
+ // This is a hash address
180
184
  tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
181
185
  }
182
186
  }
@@ -358,7 +362,25 @@ class ManyfestObjectAddressResolverGetValue
358
362
  for (let i = 0; i < tmpFunctionArguments.length; i++)
359
363
  {
360
364
  // Resolve the values for each subsequent entry
361
- tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
365
+ // Check if the argument value is a string literal or a reference to an address
366
+ if ((tmpFunctionArguments[i].length >= 2)
367
+ &&
368
+ ((tmpFunctionArguments[i].charAt(0) == '"')
369
+ || (tmpFunctionArguments[i].charAt(0) == "'")
370
+ || (tmpFunctionArguments[i].charAt(0) == "`"))
371
+ &&
372
+ ((tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == '"')
373
+ || (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "'")
374
+ || (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "`")))
375
+ {
376
+ // This is a string literal
377
+ tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length-1));
378
+ }
379
+ else
380
+ {
381
+ // This is a hash address
382
+ tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
383
+ }
362
384
  }
363
385
 
364
386
  return this.getValueAtAddress(pObject[tmpFunctionAddress].apply(pObject, tmpArgumentValues), tmpNewAddress, tmpParentAddress, tmpRootObject);
@@ -504,11 +526,11 @@ class ManyfestObjectAddressResolverGetValue
504
526
 
505
527
  // If there is an object property already named for the sub object, but it isn't an object
506
528
  // then the system can't set the value in there. Error and abort!
507
- if (pObject.hasOwnProperty(tmpSubObjectName) && typeof(pObject[tmpSubObjectName]) !== 'object')
529
+ if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
508
530
  {
509
531
  return undefined;
510
532
  }
511
- else if (pObject.hasOwnProperty(tmpSubObjectName))
533
+ else if (tmpSubObjectName in pObject)
512
534
  {
513
535
  // If there is already a subobject pass that to the recursive thingy
514
536
  // Continue to manage the parent address for recursion
@@ -46,13 +46,13 @@ module.exports = {
46
46
  tmpSegmentCount++;
47
47
  }
48
48
  // IF This is the start of an enclosure
49
- else if (tmpEnclosureStartSymbolMap.hasOwnProperty(tmpString[i]))
49
+ else if (tmpString[i] in tmpEnclosureStartSymbolMap)
50
50
  {
51
51
  // Add it to the stack!
52
52
  tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
53
53
  }
54
54
  // IF This is the end of an enclosure
55
- else if (tmpEnclosureEndSymbolMap.hasOwnProperty(tmpString[i])
55
+ else if ((tmpString[i] in tmpEnclosureEndSymbolMap)
56
56
  // AND it matches the current nest level symbol
57
57
  && tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1])
58
58
  {
@@ -100,13 +100,13 @@ module.exports = {
100
100
  return tmpString.substring(0, i);
101
101
  }
102
102
  // IF This is the start of an enclosure
103
- else if (tmpEnclosureStartSymbolMap.hasOwnProperty(tmpString[i]))
103
+ else if (tmpString[i] in tmpEnclosureStartSymbolMap)
104
104
  {
105
105
  // Add it to the stack!
106
106
  tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
107
107
  }
108
108
  // IF This is the end of an enclosure
109
- else if (tmpEnclosureEndSymbolMap.hasOwnProperty(tmpString[i])
109
+ else if ((tmpString[i] in tmpEnclosureEndSymbolMap)
110
110
  // AND it matches the current nest level symbol
111
111
  && tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1])
112
112
  {
@@ -158,13 +158,13 @@ module.exports = {
158
158
  tmpCurrentSegmentStart = i+1;
159
159
  }
160
160
  // IF This is the start of an enclosure
161
- else if (tmpEnclosureStartSymbolMap.hasOwnProperty(tmpString[i]))
161
+ else if (tmpString[i] in tmpEnclosureStartSymbolMap)
162
162
  {
163
163
  // Add it to the stack!
164
164
  tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
165
165
  }
166
166
  // IF This is the end of an enclosure
167
- else if (tmpEnclosureEndSymbolMap.hasOwnProperty(tmpString[i])
167
+ else if ((tmpString[i] in tmpEnclosureEndSymbolMap)
168
168
  // AND it matches the current nest level symbol
169
169
  && tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1])
170
170
  {
@@ -186,15 +186,15 @@ class ManyfestObjectAddressSetValue
186
186
 
187
187
  // If there is an object property already named for the sub object, but it isn't an object
188
188
  // then the system can't set the value in there. Error and abort!
189
- if (pObject.hasOwnProperty(tmpSubObjectName) && typeof(pObject[tmpSubObjectName]) !== 'object')
189
+ if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
190
190
  {
191
- if (!pObject.hasOwnProperty('__ERROR'))
191
+ if (!('__ERROR' in pObject))
192
192
  pObject['__ERROR'] = {};
193
193
  // Put it in an error object so data isn't lost
194
194
  pObject['__ERROR'][pAddress] = pValue;
195
195
  return false;
196
196
  }
197
- else if (pObject.hasOwnProperty(tmpSubObjectName))
197
+ else if (tmpSubObjectName in pObject)
198
198
  {
199
199
  // If there is already a subobject pass that to the recursive thingy
200
200
  return this.setValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress, pValue);
@@ -55,7 +55,7 @@ class ManyfestSchemaManipulation
55
55
  tmpManyfestAddresses.forEach(
56
56
  (pAddress) =>
57
57
  {
58
- if (pManyfestSchemaDescriptors[pAddress].hasOwnProperty('Hash'))
58
+ if ('Hash' in pManyfestSchemaDescriptors[pAddress])
59
59
  {
60
60
  tmpHashMapping[pManyfestSchemaDescriptors[pAddress].Hash] = pAddress;
61
61
  }
@@ -71,11 +71,11 @@ class ManyfestSchemaManipulation
71
71
  let tmpDescriptor = false;
72
72
 
73
73
  // See if there is a matching descriptor either by Address directly or Hash
74
- if (pManyfestSchemaDescriptors.hasOwnProperty(pInputAddress))
74
+ if (pInputAddress in pManyfestSchemaDescriptors)
75
75
  {
76
76
  tmpOldDescriptorAddress = pInputAddress;
77
77
  }
78
- else if (tmpHashMapping.hasOwnProperty(pInputAddress))
78
+ else if (pInputAddress in tmpHashMapping)
79
79
  {
80
80
  tmpOldDescriptorAddress = tmpHashMapping[pInputAddress];
81
81
  }
@@ -124,7 +124,7 @@ class ManyfestSchemaManipulation
124
124
  tmpDescriptorAddresses.forEach(
125
125
  (pDescriptorAddress) =>
126
126
  {
127
- if (!tmpNewManyfestSchemaDescriptors.hasOwnProperty(pDescriptorAddress))
127
+ if (!(pDescriptorAddress in tmpNewManyfestSchemaDescriptors))
128
128
  {
129
129
  tmpNewManyfestSchemaDescriptors[pDescriptorAddress] = tmpSource[pDescriptorAddress];
130
130
  }
@@ -45,7 +45,7 @@ class Manyfest extends libFableServiceProviderBase
45
45
  this.objectAddressSetValue = new libObjectAddressSetValue(this.logInfo, this.logError);
46
46
  this.objectAddressDeleteValue = new libObjectAddressDeleteValue(this.logInfo, this.logError);
47
47
 
48
- if (!this.options.hasOwnProperty('defaultValues'))
48
+ if (!('defaultValues' in this.options))
49
49
  {
50
50
  this.options.defaultValues = (
51
51
  {
@@ -61,7 +61,7 @@ class Manyfest extends libFableServiceProviderBase
61
61
  "Null": null
62
62
  });
63
63
  }
64
- if (!this.options.hasOwnProperty('strict'))
64
+ if (!('strict' in this.options))
65
65
  {
66
66
  this.options.strict = false;
67
67
  }
@@ -131,13 +131,13 @@ class Manyfest extends libFableServiceProviderBase
131
131
 
132
132
  for (let i = 0; i < tmpDescriptorKeys.length; i++)
133
133
  {
134
- if (!tmpManifest.hasOwnProperty(tmpDescriptorKeys[i]))
134
+ if (!(tmpDescriptorKeys[i] in tmpManifest))
135
135
  {
136
136
  tmpManifest[tmpDescriptorKeys[i]] = JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]]));
137
137
  }
138
138
  }
139
139
 
140
- if (tmpManifest.hasOwnProperty('Scope'))
140
+ if ('Scope' in tmpManifest)
141
141
  {
142
142
  if (typeof(tmpManifest.Scope) === 'string')
143
143
  {
@@ -153,7 +153,7 @@ class Manyfest extends libFableServiceProviderBase
153
153
  this.logError(`(${this.scope}) Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.`, tmpManifest);
154
154
  }
155
155
 
156
- if (tmpManifest.hasOwnProperty('Descriptors'))
156
+ if ('Descriptors' in tmpManifest)
157
157
  {
158
158
  if (typeof(tmpManifest.Descriptors) === 'object')
159
159
  {
@@ -173,7 +173,7 @@ class Manyfest extends libFableServiceProviderBase
173
173
  this.logError(`(${this.scope}) Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.`, tmpManifest);
174
174
  }
175
175
 
176
- if (tmpManifest.hasOwnProperty('HashTranslations'))
176
+ if ('HashTranslations' in tmpManifest)
177
177
  {
178
178
  if (typeof(tmpManifest.HashTranslations) === 'object')
179
179
  {
@@ -207,12 +207,12 @@ class Manyfest extends libFableServiceProviderBase
207
207
  if (typeof(pDescriptor) === 'object')
208
208
  {
209
209
  // Add the Address into the Descriptor if it doesn't exist:
210
- if (!pDescriptor.hasOwnProperty('Address'))
210
+ if (!('Address' in pDescriptor))
211
211
  {
212
212
  pDescriptor.Address = pAddress;
213
213
  }
214
214
 
215
- if (!this.elementDescriptors.hasOwnProperty(pAddress))
215
+ if (!(pAddress in this.elementDescriptors))
216
216
  {
217
217
  this.elementAddresses.push(pAddress);
218
218
  }
@@ -223,7 +223,7 @@ class Manyfest extends libFableServiceProviderBase
223
223
  // Always add the address as a hash
224
224
  this.elementHashes[pAddress] = pAddress;
225
225
 
226
- if (pDescriptor.hasOwnProperty('Hash'))
226
+ if ('Hash' in pDescriptor)
227
227
  {
228
228
  // TODO: Check if this is a good idea or not..
229
229
  // Collisions are bound to happen with both representations of the address/hash in here and developers being able to create their own hashes.
@@ -284,8 +284,8 @@ class Manyfest extends libFableServiceProviderBase
284
284
  {
285
285
  let tmpAddress = undefined;
286
286
 
287
- let tmpInElementHashTable = this.elementHashes.hasOwnProperty(pHash);
288
- let tmpInTranslationTable = this.hashTranslations.translationTable.hasOwnProperty(pHash);
287
+ let tmpInElementHashTable = (pHash in this.elementHashes);
288
+ let tmpInTranslationTable = (pHash in this.hashTranslations.translationTable);
289
289
 
290
290
  // The most straightforward: the hash exists, no translations.
291
291
  if (tmpInElementHashTable && !tmpInTranslationTable)
@@ -293,7 +293,7 @@ class Manyfest extends libFableServiceProviderBase
293
293
  tmpAddress = this.elementHashes[pHash];
294
294
  }
295
295
  // There is a translation from one hash to another, and, the elementHashes contains the pointer end
296
- else if (tmpInTranslationTable && this.elementHashes.hasOwnProperty(this.hashTranslations.translate(pHash)))
296
+ else if (tmpInTranslationTable && (this.hashTranslations.translate(pHash) in this.elementHashes))
297
297
  {
298
298
  tmpAddress = this.elementHashes[this.hashTranslations.translate(pHash)];
299
299
  }
@@ -477,7 +477,7 @@ class Manyfest extends libFableServiceProviderBase
477
477
  return undefined;
478
478
  }
479
479
 
480
- if (pDescriptor.hasOwnProperty('Default'))
480
+ if ('Default' in pDescriptor)
481
481
  {
482
482
  return pDescriptor.Default;
483
483
  }
@@ -485,8 +485,8 @@ class Manyfest extends libFableServiceProviderBase
485
485
  {
486
486
  // Default to a null if it doesn't have a type specified.
487
487
  // This will ensure a placeholder is created but isn't misinterpreted.
488
- let tmpDataType = (pDescriptor.hasOwnProperty('DataType')) ? pDescriptor.DataType : 'String';
489
- if (this.options.defaultValues.hasOwnProperty(tmpDataType))
488
+ let tmpDataType = ('DataType' in pDescriptor) ? pDescriptor.DataType : 'String';
489
+ if (tmpDataType in this.options.defaultValues)
490
490
  {
491
491
  return this.options.defaultValues[tmpDataType];
492
492
  }
@@ -505,7 +505,7 @@ class Manyfest extends libFableServiceProviderBase
505
505
  // This just sets up a simple filter to see if there is a default set.
506
506
  (pDescriptor) =>
507
507
  {
508
- return pDescriptor.hasOwnProperty('Default');
508
+ return ('Default' in pDescriptor);
509
509
  });
510
510
  }
511
511