1
0

Preprocessing bugfix

This commit is contained in:
Bán Dénes 2023-01-30 14:57:24 +01:00
parent c45523f38a
commit 480c362c1e
3 changed files with 24 additions and 1 deletions

View File

@ -14,7 +14,9 @@
### Minor
- Support "direct" anchors, as in, recognize num arrays and parse them as x/y/r
- Add full anchor support to individual points (via `adjust`, probably)
- Handle unnecessary (but seemingly consistent, so easy to confuse) `key` subfield of row-level overrides
- Allow footprints to access raw array/object fields from points with templating
- Include raw kicad footprint integrations
- pull torik's script to be able to convert raw kicad footprints into positionable ergogen ones

View File

@ -42,11 +42,14 @@ const traverse = exports.traverse = (config, root, breadcrumbs, op) => {
}
return result
} else if (a.type(config)() == 'array') {
// needed so that arrays can set output the same way as objects within ops
const dummy = {}
const result = []
let index = 0
for (const val of config) {
breadcrumbs.push(`[${index}]`)
result[index] = traverse(val, root, breadcrumbs, op)
op(dummy, 'dummykey', traverse(val, root, breadcrumbs, op), root, breadcrumbs)
result[index] = dummy.dummykey
breadcrumbs.pop()
index++
}

View File

@ -24,6 +24,7 @@ describe('Prepare', function() {
})
it('inherit', function() {
// normal case
p.inherit({
a: {
x: 1,
@ -43,6 +44,23 @@ describe('Prepare', function() {
z: 3,
w: 4
})
// should apply to objects within arrays as well!
p.inherit({
a: {
x: 1,
y: 2
},
b: [
{
$extends: 'a',
z: 3
}
]
}).b[0].should.deep.equal({
x: 1,
y: 2,
z: 3
})
})
it('parameterize', function() {