Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit f52528a

Browse files
committed
docs: update readme
1 parent 01f1a32 commit f52528a

File tree

1 file changed

+55
-24
lines changed

1 file changed

+55
-24
lines changed

README.md

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ new BemEntityName({
7575
});
7676
```
7777

78+
To describe the simple modifier, field `mod.val` must be specified as `true`.
79+
7880
To describe the simple modifier field `mod.val` must be specified as `true`.
7981

8082
**Example:**
@@ -85,12 +87,6 @@ new BemEntityName({
8587
block: 'button',
8688
mod: { name: 'focused', val: true }
8789
});
88-
89-
// Shorthand for the boolean modifier of a block
90-
new BemEntityName({
91-
block: 'button',
92-
mod: 'focused'
93-
});
9490
```
9591

9692
API
@@ -103,10 +99,11 @@ API
10399
* [id](#id)
104100
* [type](#type)
105101
* [isEqual(entityName)](#isequalentityname)
106-
* [isBemEntityName(entityName)](#isbementitynameentityname)
107102
* [toString()](#tostring)
108103
* [valueOf()](#valueof)
109104
* [toJSON()](#tojson)
105+
* [#isBemEntityName(entityName)](#isbementitynameentityname)
106+
* [#create(object)](#createobject)
110107

111108
### constructor({ block, elem, mod })
112109

@@ -207,23 +204,6 @@ inputName.isEqual(buttonName); // false
207204
buttonName.isEqual(buttonName); // true
208205
```
209206

210-
### isBemEntityName(entityName)
211-
212-
Determines whether specified entity is instance of BemEntityName.
213-
214-
Parameter | Type | Description
215-
-------------|-----------------|-----------------------
216-
`entityName` | `BemEntityName` | The entity to check.
217-
218-
```js
219-
const BemEntityName = require('@bem/entity-name');
220-
221-
const entityName = new BemEntityName({ block: 'input' });
222-
223-
BemEntityName.isBemEntityName(entityName); // true
224-
BemEntityName.isBemEntityName({}); // false
225-
```
226-
227207
### toString()
228208

229209
Returns string representing the entity name.
@@ -255,6 +235,57 @@ name.valueOf();
255235

256236
Returns object for `JSON.stringify()` purposes.
257237

238+
### #isBemEntityName(entityName)
239+
240+
Determines whether specified entity is instance of BemEntityName.
241+
242+
Parameter | Type | Description
243+
-------------|-----------------|-----------------------
244+
`entityName` | `BemEntityName` | The entity to check.
245+
246+
```js
247+
const BemEntityName = require('@bem/entity-name');
248+
249+
const entityName = new BemEntityName({ block: 'input' });
250+
251+
BemEntityName.isBemEntityName(entityName); // true
252+
BemEntityName.isBemEntityName({}); // false
253+
```
254+
255+
### #create(object)
256+
257+
Creates BemEntityName instance by any object representation.
258+
259+
Helper for laziness.
260+
261+
Parameter | Type | Description
262+
-------------|--------------------|--------------------------
263+
`object` | `object` | Representation of entity name.
264+
265+
Passed Object can have the common field names for entities:
266+
267+
Object field | Type | Description
268+
-------------|----------|------------------------------
269+
`block` | `string` | The block name of entity.
270+
`elem` | `string` | The element name of entity.
271+
`mod` | `string`, `object` | The modifier of entity.<br><br> If specified value is `string` then it will be equivalent to `{ name: string, val: true }`.
272+
`val` | `string` | The modifier value of entity.
273+
`mod.name` | `string` | The modifier name of entity.
274+
`mod.val` | `*` | The modifier value of entity.
275+
`modName` | `string` | The modifier name of entity.
276+
`modVal` | `*` | The modifier value of entity.
277+
278+
```js
279+
const BemEntityName = require('@bem/entity-name');
280+
281+
BemEntityName.create({ block: 'my-button', mod: 'theme', val: 'red' });
282+
BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' });
283+
// ➜ BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } }
284+
285+
BemEntityName.create({ block: 'my-button', mod: 'focused' });
286+
// ➜ BemEntityName { block: 'my-button', mod: { name: 'focused', val: true } }
287+
```
288+
258289
Debuggability
259290
-------------
260291

0 commit comments

Comments
 (0)