@@ -22,9 +22,12 @@ module.exports = class BemEntityName {
22
22
* @param {object } obj — representation of entity name.
23
23
* @param {string } obj.block — the block name of entity.
24
24
* @param {string } [obj.elem] — the element name of entity.
25
- * @param {object } [obj.mod] — the modifier of entity.
26
- * @param {string } [obj.mod.name] — the modifier name of entity.
27
- * @param {string } [obj.mod.val] — the modifier value of entity.
25
+ * @param {object } [obj.mod] — the modifier of entity.
26
+ * @param {string } obj.mod.name — the modifier name of entity.
27
+ * @param {string } [obj.mod.val] — the modifier value of entity.
28
+ * @param {string } [obj.modName] — the modifier name of entity. Used if `mod.name` wasn't specified.
29
+ * @param {string } [obj.modVal] — the modifier value of entity.
30
+ * Used if neither `mod.val` nor `val` were not specified.
28
31
*/
29
32
constructor ( obj ) {
30
33
if ( ! obj . block ) {
@@ -75,7 +78,7 @@ module.exports = class BemEntityName {
75
78
*
76
79
* name.elem; // text
77
80
*
78
- * @returns {string } name of entity element.
81
+ * @returns {string|undefined } - name of entity element.
79
82
*/
80
83
get elem ( ) { return this . _data . elem ; }
81
84
@@ -93,7 +96,7 @@ module.exports = class BemEntityName {
93
96
* modName.mod; // { name: 'disabled', val: true }
94
97
* blockName.mod; // undefined
95
98
*
96
- * @returns {{mod: string, val: *} } entity modifier.
99
+ * @returns {{mod: string, val: (string|true)}|undefined } - entity modifier.
97
100
*/
98
101
get mod ( ) { return this . _data . mod ; }
99
102
@@ -102,8 +105,8 @@ module.exports = class BemEntityName {
102
105
*
103
106
* If entity is not modifier then returns `undefined`.
104
107
*
105
- * @returns {string } entity modifier name.
106
- * @deprecated use `mod.name` instead.
108
+ * @returns {string|undefined } - entity modifier name.
109
+ * @deprecated - use `mod.name` instead.
107
110
*/
108
111
get modName ( ) { return this . mod && this . mod . name ; }
109
112
@@ -112,8 +115,8 @@ module.exports = class BemEntityName {
112
115
*
113
116
* If entity is not modifier then returns `undefined`.
114
117
*
115
- * @returns {string } entity modifier name.
116
- * @deprecated use `mod.val` instead.
118
+ * @returns {string|undefined } - entity modifier name.
119
+ * @deprecated - use `mod.val` instead.
117
120
*/
118
121
get modVal ( ) { return this . mod && this . mod . val ; }
119
122
@@ -131,7 +134,7 @@ module.exports = class BemEntityName {
131
134
*
132
135
* name.id; // button_disabled
133
136
*
134
- * @returns {string } id of entity.
137
+ * @returns {string } - id of entity.
135
138
*/
136
139
get id ( ) {
137
140
if ( this . _id ) { return this . _id ; }
@@ -162,7 +165,7 @@ module.exports = class BemEntityName {
162
165
*
163
166
* name.type; // elemMod
164
167
*
165
- * @returns {string } type of entity.
168
+ * @returns {string } - type of entity. One of 'block', 'elem', 'blockMod', 'elemMod' .
166
169
*/
167
170
get type ( ) {
168
171
if ( this . _type ) { return this . _type ; }
@@ -176,6 +179,7 @@ module.exports = class BemEntityName {
176
179
177
180
return this . _type ;
178
181
}
182
+
179
183
/**
180
184
* Returns string representing the entity name.
181
185
*
@@ -209,7 +213,7 @@ module.exports = class BemEntityName {
209
213
*
210
214
* // ➜ { block: 'button', mod: { name: 'focused', value: true } }
211
215
*
212
- * @returns {{block: string, elem: ? string, mod: ? {name: ? string, val: *} } }
216
+ * @returns {{block: string, elem: ( string|undefined) , mod: ( {name: string, val: (string|true)}|undefined) } }
213
217
*/
214
218
valueOf ( ) { return this . _data ; }
215
219
@@ -228,9 +232,9 @@ module.exports = class BemEntityName {
228
232
*
229
233
* console.log(name); // BemEntityName { block: 'button' }
230
234
*
231
- * @param {integer } depth — tells inspect how many times to recurse while formatting the object.
235
+ * @param {number } depth — tells inspect how many times to recurse while formatting the object.
232
236
* @param {object } options — An optional `options` object may be passed
233
- * that alters certain aspects of the formatted string.
237
+ * that alters certain aspects of the formatted string.
234
238
*
235
239
* @returns {string }
236
240
*/
@@ -243,7 +247,8 @@ module.exports = class BemEntityName {
243
247
/**
244
248
* Return raw data for `JSON.stringify()`.
245
249
*
246
- * @returns {{block: string, elem: ?string, mod: ?{name: string, val: *}} }
250
+ * @returns {{block: string, elem: (string|undefined),
251
+ * mod: ({name: string, val: (string|true|undefined)}|undefined) }}
247
252
*/
248
253
toJSON ( ) {
249
254
return this . _data ;
@@ -254,7 +259,7 @@ module.exports = class BemEntityName {
254
259
*
255
260
* @param {BemEntityName } entityName - the entity to compare.
256
261
*
257
- * @returns {boolean } A Boolean indicating whether or not specified entity is the deepEqual entity.
262
+ * @returns {boolean } - A Boolean indicating whether or not specified entity is the deepEqual entity.
258
263
* @example
259
264
* const BemEntityName = require('@bem/entity-name');
260
265
*
@@ -294,7 +299,7 @@ module.exports = class BemEntityName {
294
299
* @param {string } [obj.elem] — the element name of entity.
295
300
* @param {object|string } [obj.mod] — the modifier of entity.
296
301
* @param {string } [obj.val] - the modifier value of entity. Used if `obj.mod` is a string.
297
- * @param {string } [ obj.mod.name] — the modifier name of entity.
302
+ * @param {string } obj.mod.name — the modifier name of entity.
298
303
* @param {string } [obj.mod.val] — the modifier value of entity.
299
304
* @param {string } [obj.modName] — the modifier name of entity. Used if `obj.mod.name` wasn't specified.
300
305
* @param {string } [obj.modVal] — the modifier value of entity.
@@ -307,7 +312,7 @@ module.exports = class BemEntityName {
307
312
* BemEntityName.create('my-button_theme_red');
308
313
* BemEntityName.create({ block: 'my-button', mod: 'theme', val: 'red' });
309
314
* BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' });
310
- * // BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } }
315
+ * // → BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } }
311
316
*/
312
317
static create ( obj ) {
313
318
if ( BemEntityName . isBemEntityName ( obj ) ) {
0 commit comments