manyfest 1.0.36 → 1.0.38

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.36",
3
+ "version": "1.0.38",
4
4
  "description": "JSON Object Manifest for Data Description and Parsing",
5
5
  "main": "source/Manyfest.js",
6
6
  "scripts": {
@@ -47,9 +47,19 @@ class ManyfestObjectAddressResolverGetValue
47
47
  getValueAtAddress (pObject, pAddress, pParentAddress, pRootObject)
48
48
  {
49
49
  // Make sure pObject (the object we are meant to be recursing) is an object (which could be an array or object)
50
- if (typeof(pObject) != 'object') return undefined;
50
+ if (typeof(pObject) != 'object')
51
+ {
52
+ return undefined;
53
+ }
54
+ if (pObject === null)
55
+ {
56
+ return undefined;
57
+ }
51
58
  // Make sure pAddress (the address we are resolving) is a string
52
- if (typeof(pAddress) != 'string') return undefined;
59
+ if (typeof(pAddress) != 'string')
60
+ {
61
+ return undefined;
62
+ }
53
63
  // Stash the parent address for later resolution
54
64
  let tmpParentAddress = "";
55
65
  if (typeof(pParentAddress) == 'string')
@@ -335,7 +345,7 @@ class ManyfestObjectAddressResolverGetValue
335
345
  }
336
346
  else
337
347
  {
338
- return undefined;
348
+ return null;
339
349
  }
340
350
  }
341
351
  }
@@ -332,6 +332,12 @@ class Manyfest extends libFableServiceProviderBase
332
332
  // Get the value of an element at an address
333
333
  getValueAtAddress (pObject, pAddress)
334
334
  {
335
+ let tmpLintedAddress = pAddress.trim();
336
+ if (tmpLintedAddress == '')
337
+ {
338
+ this.logError(`(${this.scope}) Error getting value at address; address is an empty string.`, pObject);
339
+ return undefined;
340
+ }
335
341
  let tmpValue = this.objectAddressGetValue.getValueAtAddress(pObject, pAddress);
336
342
 
337
343
  if (typeof(tmpValue) == 'undefined')
@@ -38,6 +38,26 @@ suite
38
38
  .to.equal('Franken Berry / Count Chocula : Tevevision Commercial 1971');
39
39
  Expect(tmpTitle)
40
40
  .to.equal(_SampleDataArchiveOrgFrankenberry.metadata.title);
41
+ let tmpNoAddress = _Manyfest.getValueAtAddress(_SampleDataArchiveOrgFrankenberry, '');
42
+ fTestComplete();
43
+ }
44
+ );
45
+ test
46
+ (
47
+ 'Javascript null values should not cause errors..',
48
+ (fTestComplete)=>
49
+ {
50
+ let _Manyfest = new libManyfest({ Scope:'Archive.org', Descriptors: {'metadata.creator': {Name:'Creator', Hash:'Creator'}}});
51
+ let tmpNullSampleData = JSON.parse(JSON.stringify(_SampleDataArchiveOrgFrankenberry));
52
+ tmpNullSampleData.Noel = null;
53
+ let tmpNullValue = _Manyfest.getValueAtAddress(tmpNullSampleData, 'Noel');
54
+ let tmpNullValueOneDeep = _Manyfest.getValueAtAddress(tmpNullSampleData, 'Noel.SomeChildValue');
55
+ let tmpNullValueTwoDeep = _Manyfest.getValueAtAddress(tmpNullSampleData, 'Noel.SomeChildValue.SecondTier');
56
+ let tmpNullValueTwoDeepObject = _Manyfest.getValueAtAddress(tmpNullSampleData, 'Noel.SomeChildValue[SecondTier]');
57
+ let tmpNullValueTwoDeepArray = _Manyfest.getValueAtAddress(tmpNullSampleData, 'Noel.SomeChildValue.SecondTier[0]');
58
+ Expect(tmpNullValue).to.equal(null);
59
+ Expect(tmpNullValueOneDeep).to.equal(undefined);
60
+ Expect(tmpNullValueTwoDeep).to.equal(undefined);
41
61
  fTestComplete();
42
62
  }
43
63
  );