diff --git a/src/cases.js b/src/cases.js index 0604c48..f6342fc 100644 --- a/src/cases.js +++ b/src/cases.js @@ -57,15 +57,15 @@ exports.parse = (config, outlines, units) => { } const part_qname = `cases.${case_name}.${part_name}` const part_var = `${case_name}__part_${part_name}` - a.unexpected(part, part_qname, ['type', 'name', 'extrude', 'shift', 'rotate', 'operation']) - const type = a.in(part.type || 'outline', `${part_qname}.type`, ['outline', 'case']) + a.unexpected(part, part_qname, ['what', 'name', 'extrude', 'shift', 'rotate', 'operation']) + const what = a.in(part.what || 'outline', `${part_qname}.what`, ['outline', 'case']) const name = a.sane(part.name, `${part_qname}.name`, 'string')() const shift = a.numarr(part.shift || [0, 0, 0], `${part_qname}.shift`, 3)(units) const rotate = a.numarr(part.rotate || [0, 0, 0], `${part_qname}.rotate`, 3)(units) const operation = a.in(part.operation || 'add', `${part_qname}.operation`, ['add', 'subtract', 'intersect']) let base - if (type == 'outline') { + if (what == 'outline') { const extrude = a.sane(part.extrude || 1, `${part_qname}.extrude`, 'number')(units) const outline = outlines[name] a.assert(outline, `Field "${part_qname}.name" does not name a valid outline!`) @@ -79,7 +79,7 @@ exports.parse = (config, outlines, units) => { outline_dependencies.push(name) base = `${name}_outline_fn()` } else { - a.assert(part.extrude === undefined, `Field "${part_qname}.extrude" should not be used when type=case!`) + a.assert(part.extrude === undefined, `Field "${part_qname}.extrude" should not be used when what=case!`) a.in(name, `${part_qname}.name`, Object.keys(cases)) case_dependencies.push(name) base = `${name}_case_fn()` diff --git a/src/operation.js b/src/operation.js index fa210fb..0480324 100644 --- a/src/operation.js +++ b/src/operation.js @@ -17,7 +17,7 @@ exports.operation = (str, choices={}, order=Object.keys(choices)) => { let res = op_prefix(str) for (const key of order) { if (choices[key].includes(res.name)) { - res.type = key + res.what = key break } } diff --git a/test/unit/operation.js b/test/unit/operation.js index de2a12e..9ffe371 100644 --- a/test/unit/operation.js +++ b/test/unit/operation.js @@ -13,10 +13,10 @@ describe('Operation', function() { it('operation', function() { // without choices, it's the same as op_prefix o.operation('arst').should.deep.equal({name: 'arst', operation: 'add'}) - // with choices, it propagates type where it found the name - o.operation('arst', {bad: [], good: ['arst']}).should.deep.equal({name: 'arst', operation: 'add', type: 'good'}) + // with choices, it propagates the "what" from where it found the name + o.operation('arst', {bad: [], good: ['arst']}).should.deep.equal({name: 'arst', operation: 'add', what: 'good'}) // it also respects order when overridden - o.operation('arst', {first: ['arst'], second: ['arst']}, ['second', 'first']).should.deep.equal({name: 'arst', operation: 'add', type: 'second'}) + o.operation('arst', {first: ['arst'], second: ['arst']}, ['second', 'first']).should.deep.equal({name: 'arst', operation: 'add', what: 'second'}) }) }) \ No newline at end of file