Newer
Older
const JSUnit = require('./lib/jsunit.js')
let isStateKey = JSUnit.isStateKey
var rep = {
description: {
id: mdl.description.id,
name: mdl.description.name,
alt: mdl.description.alt,
path: mdl.description.path
}
}
// yikes tho, corner cases should be easier ...
if(mdl.description.isHardware){
rep.description.isHardware = true
}
if(mdl.description.isLink){
rep.description.isLink = true
}
if(mdl.description.position){
rep.description.position = mdl.description.position
}
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// TODO: making rep. of input / output should be a f'n of that object ...
// input, outputs, state objs should be known /sysobjects
// everything else is free play
rep.inputs = {}
for (key in mdl.inputs) {
rep.inputs[key] = {}
rep.inputs[key].accepts = mdl.inputs[key].accepts
}
rep.outputs = {}
for (key in mdl.outputs) {
rep.outputs[key] = {}
rep.outputs[key].emits = mdl.outputs[key].emits
rep.outputs[key].calls = new Array()
mdl.outputs[key].calls.forEach(function(inp) {
var input = {
parentId: inp.parentId,
key: inp.key
}
rep.outputs[key].calls.push(input)
})
}
rep.state = {}
for(key in mdl.state){
if(isStateKey(key)){
rep.state[key] = mdl.state[key]
}
}
return rep
}
module.exports = {
makeFromModule: makeRepFromModule
}