Comparing version 1.0.23 to 1.0.24
{ | ||
"name": "manyfest", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "JSON Object Manifest for Data Description and Parsing", | ||
@@ -66,2 +66,3 @@ "main": "source/Manyfest.js", | ||
"dependencies": { | ||
"fable-serviceproviderbase": "^3.0.4" | ||
}, | ||
@@ -68,0 +69,0 @@ "author": "steven velozo <steven@velozo.com>", |
/** | ||
* @author <steven@velozo.com> | ||
*/ | ||
const libFableServiceProviderBase = require('fable-serviceproviderbase'); | ||
let libSimpleLog = require('./Manyfest-LogToConsole.js'); | ||
@@ -14,5 +16,4 @@ | ||
const _DefaultConfiguration = { Scope:'Default', Descriptors: {} } | ||
const _DefaultConfiguration = { Scope:'DEFAULT', Descriptors: {} } | ||
/** | ||
@@ -23,9 +24,20 @@ * Manyfest object address-based descriptions and manipulations. | ||
*/ | ||
class Manyfest | ||
class Manyfest extends libFableServiceProviderBase | ||
{ | ||
constructor(pManifest, pInfoLog, pErrorLog, pOptions) | ||
constructor(pFable, pManifest, pServiceHash) | ||
{ | ||
if (pFable === undefined) | ||
{ | ||
super({}); | ||
} | ||
else | ||
{ | ||
super(pFable, pManifest, pServiceHash); | ||
} | ||
this.serviceType = 'Manifest'; | ||
// Wire in logging | ||
this.logInfo = (typeof(pInfoLog) === 'function') ? pInfoLog : libSimpleLog; | ||
this.logError = (typeof(pErrorLog) === 'function') ? pErrorLog : libSimpleLog; | ||
this.logInfo = libSimpleLog; | ||
this.logError = libSimpleLog; | ||
@@ -38,19 +50,22 @@ // Create an object address resolver and map in the functions | ||
this.options = ( | ||
{ | ||
strict: false, | ||
defaultValues: | ||
{ | ||
"String": "", | ||
"Number": 0, | ||
"Float": 0.0, | ||
"Integer": 0, | ||
"Boolean": false, | ||
"Binary": 0, | ||
"DateTime": 0, | ||
"Array": [], | ||
"Object": {}, | ||
"Null": null | ||
} | ||
}); | ||
if (!this.options.hasOwnProperty('defaultValues')) | ||
{ | ||
this.options.defaultValues = ( | ||
{ | ||
"String": "", | ||
"Number": 0, | ||
"Float": 0.0, | ||
"Integer": 0, | ||
"Boolean": false, | ||
"Binary": 0, | ||
"DateTime": 0, | ||
"Array": [], | ||
"Object": {}, | ||
"Null": null | ||
}); | ||
} | ||
if (!this.options.hasOwnProperty('strict')) | ||
{ | ||
this.options.strict = false; | ||
} | ||
@@ -68,5 +83,5 @@ this.scope = undefined; | ||
if (typeof(pManifest) === 'object') | ||
if (typeof(this.options) === 'object') | ||
{ | ||
this.loadManifest(pManifest); | ||
this.loadManifest(this.options); | ||
} | ||
@@ -125,2 +140,12 @@ | ||
let tmpDescriptorKeys = Object.keys(_DefaultConfiguration); | ||
for (let i = 0; i < tmpDescriptorKeys.length; i++) | ||
{ | ||
if (!tmpManifest.hasOwnProperty(tmpDescriptorKeys[i])) | ||
{ | ||
tmpManifest[tmpDescriptorKeys[i]] = JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]])); | ||
} | ||
} | ||
if (tmpManifest.hasOwnProperty('Scope')) | ||
@@ -127,0 +152,0 @@ { |
@@ -74,27 +74,2 @@ /** | ||
); | ||
test | ||
( | ||
'Pass in a custom logger.', | ||
(fTestComplete)=> | ||
{ | ||
let tmpLogState = []; | ||
let fWriteLog = (pLogLine, pLogObject) => | ||
{ | ||
tmpLogState.push(pLogLine); | ||
}; | ||
let _Manyfest = new libManyfest(undefined, fWriteLog, fWriteLog); | ||
_Manyfest.logError('Error...'); | ||
Expect(tmpLogState.length) | ||
.to.equal(1); | ||
Expect(tmpLogState[0]) | ||
.to.equal('Error...'); | ||
_Manyfest.logInfo('Info...'); | ||
_Manyfest.logInfo(); | ||
Expect(tmpLogState.length) | ||
.to.equal(3); | ||
fTestComplete(); | ||
} | ||
); | ||
} | ||
@@ -101,0 +76,0 @@ ); |
251917
1
4529
+ Addedfable-serviceproviderbase@3.0.15(transitive)