Package Exports
- deps-normalize
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (deps-normalize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
deps-normalize
Usage
var normalize = require('deps-normalize');
normalize('block__elem_mod');
API
normalize(dependencies)
Runs normalization of dependencies. Returns array of normalized dependencies.
Normalization
Dependencies should contain deps objects. We do not support full specification, but most of it. Those objects are equivalents of BEM objects, but with additional properties, that reduces boilerplate code. After they are normalized, they can be converted to BEM objects.
elems
- containsArray
ofString
(if it containsString
it will be wrapped in array).mods
- containsObject
with keys as modificators names and values as modificators values. Values can beString
orArray
ofString
.
If deps object contain elems
or mods
it will be splitted in multiple BEM objects. It will not take multiplication of elems
and mods
, if both are present in deps object. Instead it will be interpretated as two deps objects: one with elems
and other with mods
.
// b.deps.js file:
({
require: { elems: ['e1', 'e2'], mods: {m1: 1, m2: [2, 3]} }
})
// Will be translated to:
({
require: [
{ block: 'b', elem: 'e1' },
{ block: 'b', elem: 'e2' },
{ block: 'b', mod: 'm1', value: 1 },
{ block: 'b', mod: 'm2', value: 2 },
{ block: 'b', mod: 'm2', value: 3 }
]
})
level
, block
, elem
, mod
and value
properties will be taken from current BEM object, that described with {bem}.deps.js
file. They will be taken while most concrete is not defined in deps object (see code that does it, if this sounds complicated).
Note: you can not have elem
with elems
in one deps object (same applies to mod
and mods
).
License
MIT (c) 2014 Vsevolod Strukchinsky