deps-normalize
This module used to normalize require
and expect
properties in BEM object.
Usage
var normalize = require('deps-normalize');
normalize(undefined);
normalize({ block: 'block' });
normalize({ elem: 'elem' });
API
normalize(dependencies, [options])
Runs normalization of dependencies. Returns array of normalized dependencies.
dependencies
Type: Object
/ String
options
Type: Object
parseString
- contains Function
, that will parse dependencies
if they passed as string.
Normalization
Dependencies should contain deps objects (or String
). We do not support full specification. 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
- contains Array
of String
(if it contains String
it will be wrapped in array).mods
- contains Object
with keys as modificators names and values as modificators values. Values can be Number
, Boolean
, String
or Array
of String
.
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
.
normalize({ elems: ['e1', 'e2'], mods: {m1: 1, m2: [2, 3]} });
level
, block
, elem
, mod
and value
properties will be taken from current processing object.
Note: you can not have elem
with elems
in one deps object (same applies to mod
and mods
).
License
MIT (c) 2014 Vsevolod Strukchinsky