Skip to content

Commit

Permalink
Preprocessing bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzealot committed Jan 30, 2023
1 parent c45523f commit 480c362
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}
Expand Down
18 changes: 18 additions & 0 deletions test/unit/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Prepare', function() {
})

it('inherit', function() {
// normal case
p.inherit({
a: {
x: 1,
Expand All @@ -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() {
Expand Down

0 comments on commit 480c362

Please sign in to comment.