model-attributes
Advanced tools
Comparing version 1.2.0 to 1.3.0
/* jslint node: true, esnext: true */ | ||
'use strict'; | ||
const types = require('./types'); | ||
@@ -8,3 +9,2 @@ function setAttributes(dest, atts, src = {}, cb = (ca, path, value) => {}, prefix = '') { | ||
const ca = atts[name]; | ||
//ca.name = name; | ||
@@ -56,4 +56,8 @@ if (ca.attributes) { | ||
module.exports.createAttributes = function (definitions) { | ||
Object.keys(definitions).forEach(name => definitions[name].name = name); | ||
Object.keys(definitions).forEach(name => { | ||
const d = definitions[name]; | ||
d.name = name; | ||
d.type = types.getType(d.type); | ||
}); | ||
return definitions; | ||
}; |
@@ -7,2 +7,3 @@ /* jslint node: true, esnext: true */ | ||
function DeclareType(name, options) { | ||
options.name = name; | ||
if (options.parent) { | ||
@@ -25,14 +26,20 @@ options.parent = types[options.parent]; | ||
DeclareType('blob', { | ||
parent: 'base', | ||
description: 'raw bytes' | ||
}); | ||
DeclareType('unsigned-integer', { | ||
parent: 'base', | ||
min: 0 | ||
minValue: 0 | ||
}); | ||
DeclareType('port', { | ||
DeclareType('ip-port', { | ||
parent: 'unsigned-integer', | ||
description: 'ip port number', | ||
max: 65535 | ||
maxValue: 65535 | ||
}); | ||
DeclareType('duration', { | ||
parent: 'base', | ||
description: 'time duration in seconds', | ||
@@ -43,1 +50,5 @@ toString(value) { | ||
}); | ||
module.exports.getType = function(name) { | ||
return types[name]; | ||
} |
{ | ||
"name": "model-attributes", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "attribute meta description", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
5839
99