diff --git a/roadmap.md b/roadmap.md index fa31aed..f8dea91 100644 --- a/roadmap.md +++ b/roadmap.md @@ -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 diff --git a/src/prepare.js b/src/prepare.js index 2314542..48edd7f 100644 --- a/src/prepare.js +++ b/src/prepare.js @@ -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++ } diff --git a/test/unit/prepare.js b/test/unit/prepare.js index 225e0da..0b416f5 100644 --- a/test/unit/prepare.js +++ b/test/unit/prepare.js @@ -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() {