How @bem/sdk.decl works?

node v10.24.1
version: 1.0.0
const bemDecl = require('@bem/sdk.decl'); // Create two files with declarations: const mock = require('mock-fs'); mock({ 'set1.bemdecl.js': "exports.blocks = [\n {name: 'a'},\n {name: 'b'},\n {name: 'c'}\n];", 'set2.bemdecl.js': "exports.blocks = [\n {name: 'b'},\n {name: 'e'}\n];" }); // In the RunKit you don't need to use an async function // Await loading of file and put it to `set1` variable const set1 = await bemDecl.load('set1.bemdecl.js'); // `set1` is an array of BemCell objects, // convert them to strings using `.map` and special `id` property: =>;
// Load the second set const set2 = await bemDecl.load('set2.bemdecl.js'); =>;
bemDecl.subtract(set1, set2).map(c =>;
bemDecl.subtract(set2, set1).map(c =>;
bemDecl.intersect(set1, set2).map(c =>;
bemDecl.merge(set1, set2).map(c =>;
const mergedSet = bemDecl.normalize(bemDecl.merge(set1, set2));'mergedSet.bemdecl.js', mergedSet, { format: 'v1', exportType: 'commonjs' }) const fs = require('fs'); fs.readFile('mergedSet.bemdecl.js', 'utf-8', (err, data) => { if (err) throw err; console.log(data); });

no comments

    sign in to comment