bem-graph
Install
$ npm install --save-dev bem-graph
Usage
const BemGraph = ; const graph = ; graph ; graph ; graph ; const decl = block: 'attach' block: 'textarea' block: 'button' ; graph;// [// { entity: { block: 'attach' }, tech: 'css' },// { entity: { block: 'textarea' }, tech: 'css' },// { entity: { block: 'input' }, tech: 'css' },// { entity: { block: 'button' }, tech: 'css' },// { entity: { block: 'button', elem: 'text' }, tech: 'css' }// ] graph;// [// { entity: { block: 'button' }, tech: 'bemhtml' },// { entity: { block: 'attach' }, tech: 'js' },// { entity: { block: 'button', elem: 'text' }, tech: 'bemhtml' },// { entity: { block: 'textarea' }, tech: 'js' }// ]
API
BemGraph based on BemEntityName objects and bem-decl format.
BemGraph.vertex
BemGraph: BemGraph~Vertex
Registers vertex in graph and makes a helper object BemGraph~Vertex
with methods
to link it with other vertices.
BemGraph.dependenciesOf
BemGraph: Array<entity: BemEntityName tech: String>
Resolves ordered declaration and returns .
NB: Will throw for cycles in ordered links.
BemGraph.naturalize
BemGraph: void
Creates "natural" links between registered entities:
- element should depend on block;
- block modifier should also depend on block;
- element modifier should depend on element.
BemGraph~Vertex.dependsOn
Vertex: BemGraph~Vertex
Creates an ordered link between contained and passed vertices.
BemGraph~Vertex.linkWith
Vertex: BemGraph~Vertex
Creates an unordered link between contained and passed vertices.
License
Code and documentation copyright 2016 YANDEX LLC. Code released under the Mozilla Public License 2.0.