In old domino
, properties would be stated thusly:
var d = new domino({
properties: [
{
id: 'p1',
type: 'string'
},
{
id: 'p2',
type: 'number'
}
]
});
So, for starters, we need a a posteriori low-level interface to deal with properties like:
d.addProperty({id: 'p3', type: 'number', namespace: 'x'});
// or
d.addProperty('p3', {type: 'number'});
And we could register properties likewise (considering namespaces also):
var d = new domino({
properties: {
ns1: {
x: {
type: 'number',
description: 'a random number'
},
y: {
type: 'string',
defaultValue: 'Hello World!'
}
},
ns2: {
x: {
type: 'number',
description: 'This property is also x but is also namespaced.'
},
z: {
type: 'object'
}
}
}
});
But now, what do we decide for polymorphism, that is to say, if we write something like the following:
var d = new domino({
properties: {
x: scalar
}
});
// or
d.addProperties('x', scalar);
I would advocate for property type, likewise:
var d = new domino({
properties: {
x: 'number'
}
});
// or
d.addProperties('x', 'number');