bem-sdk-archive / bem-decl

:capital_abcd: Manage declaration of BEM entities. DEPRECATED →
https://github.com/bem/bem-sdk/tree/master/packages/decl
Other
11 stars 3 forks source link

Support true bemcell algebra #91

Open qfox opened 7 years ago

qfox commented 7 years ago

Cross tech decl algebra:

// U — merge
[{ entity: A }] U [{ entity: A, tech: '1' }] →
    → [{ entity: A }, { entity: A, tech: '1' }] // Because any tech can be not '1' in result
[{ entity: A, tech: '1' }] U [{ entity: A, tech: '2' }] →
    → [{ entity: A, tech: '1' }, { entity: A, tech: '2' }]

// / — subtract
[{ entity: A, tech: 'specified' }] / [{ entity: A }] → []
[{ entity: A, layer: 'specified' }] / [{ entity: A }] → []
[{ entity: A }] / [{ entity: A, tech: 'specified' }] → ERROR
[{ entity: A }] / [{ entity: A, layer: 'specified' }] → ERROR
[{ entity: A, tech: 'specified' }] / [{ entity: A, layer: 'specified' }] → ERROR
[{ entity: A, layer: 'specified' }] / [{ entity: A, tech: 'specified' }] → ERROR

// П — intersect
[{ entity: A }] П [{ entity: A, tech: 'specified' }] → [{ entity: A, tech: 'specified' }]
[{ entity: A, tech: '1' }] П [{ entity: A, tech: '2' }] → []
[{ entity: A, tech: '1' }] П [{ entity: A, layer: 'l' }] → [{ entity: A, tech: '1', layer: 'l' }]
belozer commented 7 years ago

subtract for [{ entity: A }] / [{ entity: A, tech: 'specified' }] → [{throw exception}]