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

Commit 740e8d1

Browse files
committed
docs: update readme
1 parent ab3a64e commit 740e8d1

File tree

1 file changed

+54
-19
lines changed

1 file changed

+54
-19
lines changed

README.md

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ new BemEntityName({
7575
});
7676
```
7777

78-
To describe the simple modifier field `mod.val` must be specified as `true`.
78+
To describe the simple modifier, field `mod.val` must be specified as `true`.
7979

8080
**Example:**
8181

@@ -103,10 +103,11 @@ API
103103
* [id](#id)
104104
* [type](#type)
105105
* [isEqual(entityName)](#isequalentityname)
106-
* [isBemEntityName(entityName)](#isbementitynameentityname)
107106
* [toString()](#tostring)
108107
* [valueOf()](#valueof)
109108
* [toJSON()](#tojson)
109+
* [#isBemEntityName(entityName)](#isbementitynameentityname)
110+
* [#create(object)](#createobject)
110111

111112
### constructor({ block, elem, mod })
112113

@@ -207,23 +208,6 @@ inputName.isEqual(buttonName); // false
207208
buttonName.isEqual(buttonName); // true
208209
```
209210

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-
227211
### toString()
228212

229213
Returns string representing the entity name.
@@ -255,6 +239,57 @@ name.valueOf();
255239

256240
Returns object for `JSON.stringify()` purposes.
257241

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

0 commit comments

Comments
 (0)