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

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
qfox committed Jan 26, 2017
1 parent 01f1a32 commit f52528a
Showing 1 changed file with 55 additions and 24 deletions.
79 changes: 55 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ new BemEntityName({
});
```

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

To describe the simple modifier field `mod.val` must be specified as `true`.

**Example:**
Expand All @@ -85,12 +87,6 @@ new BemEntityName({
block: 'button',
mod: { name: 'focused', val: true }
});

// Shorthand for the boolean modifier of a block
new BemEntityName({
block: 'button',
mod: 'focused'
});
```

API
Expand All @@ -103,10 +99,11 @@ API
* [id](#id)
* [type](#type)
* [isEqual(entityName)](#isequalentityname)
* [isBemEntityName(entityName)](#isbementitynameentityname)
* [toString()](#tostring)
* [valueOf()](#valueof)
* [toJSON()](#tojson)
* [#isBemEntityName(entityName)](#isbementitynameentityname)
* [#create(object)](#createobject)

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

Expand Down Expand Up @@ -207,23 +204,6 @@ inputName.isEqual(buttonName); // false
buttonName.isEqual(buttonName); // true
```

### isBemEntityName(entityName)

Determines whether specified entity is instance of BemEntityName.

Parameter | Type | Description
-------------|-----------------|-----------------------
`entityName` | `BemEntityName` | The entity to check.

```js
const BemEntityName = require('@bem/entity-name');

const entityName = new BemEntityName({ block: 'input' });

BemEntityName.isBemEntityName(entityName); // true
BemEntityName.isBemEntityName({}); // false
```

### toString()

Returns string representing the entity name.
Expand Down Expand Up @@ -255,6 +235,57 @@ name.valueOf();

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

### #isBemEntityName(entityName)

Determines whether specified entity is instance of BemEntityName.

Parameter | Type | Description
-------------|-----------------|-----------------------
`entityName` | `BemEntityName` | The entity to check.

```js
const BemEntityName = require('@bem/entity-name');

const entityName = new BemEntityName({ block: 'input' });

BemEntityName.isBemEntityName(entityName); // true
BemEntityName.isBemEntityName({}); // false
```

### #create(object)

Creates BemEntityName instance by any object representation.

Helper for laziness.

Parameter | Type | Description
-------------|--------------------|--------------------------
`object` | `object` | Representation of entity name.

Passed Object can have the common field names for entities:

Object field | Type | Description
-------------|----------|------------------------------
`block` | `string` | The block name of entity.
`elem` | `string` | The element name of entity.
`mod` | `string`, `object` | The modifier of entity.<br><br> If specified value is `string` then it will be equivalent to `{ name: string, val: true }`.
`val` | `string` | The modifier value of entity.
`mod.name` | `string` | The modifier name of entity.
`mod.val` | `*` | The modifier value of entity.
`modName` | `string` | The modifier name of entity.
`modVal` | `*` | The modifier value of entity.

```js
const BemEntityName = require('@bem/entity-name');

BemEntityName.create({ block: 'my-button', mod: 'theme', val: 'red' });
BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' });
// ➜ BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } }

BemEntityName.create({ block: 'my-button', mod: 'focused' });
// ➜ BemEntityName { block: 'my-button', mod: { name: 'focused', val: true } }
```

Debuggability
-------------

Expand Down

0 comments on commit f52528a

Please sign in to comment.