Registry / devops / bem-graph

bem-graph

JSON →
library0.0.3jsnpmunverified

bem-graph is a JavaScript library (v0.0.3, latest) for managing dependency graphs of BEM entities. It allows defining ordered and unordered links between entities (blocks, elements, modifiers) and resolving dependencies for a given declaration of entities, returning the full set of required entities per technology. It works with BemEntityName objects and bem-decl format. Key differentiators: lightweight, simple API, supports naturalization of links, and detects cycles in ordered links. Current status: active but low release cadence (last release likely 2016). Requires Node >=4.

npm install bem-graph
INSTALL
IMPORT
SIG · BEM-GRAPH
B
bem-graph
devopsjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BemGraph
const BemGraph = require('bem-graph');
import BemGraph from 'bem-graph';
Package is CommonJS only, not ESM. Use require().

Shows how to create a graph, define dependencies between BEM entities, and resolve dependencies for a declaration.

const BemGraph = require('bem-graph'); const graph = new BemGraph(); graph.vertex({ block: 'attach' }, 'js') .dependsOn({ block: 'button' }, 'bemhtml'); graph.vertex({ block: 'button' }) .linkWith({ block: 'button', elem: 'text' }); graph.vertex({ block: 'textarea' }, 'css') .dependsOn({ block: 'input' }, 'css'); const decl = [ { block: 'attach' }, { block: 'textarea' }, { block: 'button' } ]; const result = graph.dependenciesOf(decl, 'css'); // result includes { block: 'attach' }, { block: 'textarea' }, { block: 'input' }, { block: 'button' }, { block: 'button', elem: 'text' } console.log(JSON.stringify(result, null, 2));
Debug
Known issues
gotchadependenciesOf throws if cyclic ordered links (created with dependsOn) exist in the graph.
fix
Ensure no cycles in ordered links. Use linkWith for unordered links that allow cycles.
affects: >=0.0.1
gotchaEntity names must be BemEntityName objects. Invalid objects may cause unexpected behavior.
fix
Use objects with block, elem, modName, modVal properties as defined by bem-entity-name.
affects: >=0.0.1
gotchaThe library uses bem-decl format for declarations; passing malformed arrays can break dependency resolution.
fix
Ensure declaration array elements follow BemEntityName structure.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: BemGraph is not a constructor
Using ES module import on a CommonJS-only package.
fix
Use 'const BemGraph = require("bem-graph");' instead of ES import.
Error: Cyclic dependency detected on <entity>
Ordered links (dependsOn) form a cycle in the graph.
fix
Change dependencies to avoid cycles or use linkWith for unordered links.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
bem-graph — npm install bem-graph · libregistry