From 907ae01dd2f1ae523133473429a4da4993577b3f Mon Sep 17 00:00:00 2001 From: Alexey Yaroshevich Date: Fri, 27 Jan 2017 01:12:26 +0300 Subject: [PATCH] docs: description for create method --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 81c7afd..f8f98c3 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ API * [valueOf()](#valueof) * [toJSON()](#tojson) * [isBemCell(cell)](#isbemcellcell) +* [create(object)](#createobject) ### constructor(obj) @@ -191,6 +192,39 @@ BemCell.isBemCell(cell); // true BemCell.isBemCell({}); // false ``` +### #create(object) + +Creates BemCell instance by the any object representation. + +Helper for laziness. + +Parameter | Type | Description +-------------|----------|-------------------------- +`object` | `object` | Representation of entity name. + +Passed Object can have fields for BemEntityName and cell itself: + +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.

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. +`tech` | `string` | Technology of cell. +`layer` | `string` | Layer of cell. + +```js +const BemCell = require('@bem/cell'); + +BemCell.create({ block: 'my-button', mod: 'theme', val: 'red', tech: 'css', layer: 'common' }); +BemCell.create({ block: 'my-button', modName: 'theme', modVal: 'red', tech: 'css', layer: 'common' }); +// BemCell { entity: { block: 'my-button', mod: { name: 'theme', val: 'red' } }, tech: 'css', layer: 'common' } +``` + Debuggability -------------