Skip to content

Commit

Permalink
feat: #17 Add 'Deprecated' info wherever used 'modName, modVal'
Browse files Browse the repository at this point in the history
  • Loading branch information
birhoff committed Feb 17, 2017
1 parent ff49a7e commit df4db81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions index.js
Expand Up @@ -3,6 +3,8 @@
const assert = require('assert');
const util = require('util');

const deprecate = require('depd')('bem-cell');

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

module.exports = class BemCell {
Expand Down Expand Up @@ -101,15 +103,21 @@ module.exports = class BemCell {
* @deprecated - just for compatibility and can be dropped in future
* @returns {string|undefined} - modifier name
*/
get modName() { return this._entity.modName; }
get modName() {
deprecate('modName: just for compatibility and can be dropped in future');
return this._entity.modName;
}

/**
* Proxies `modName` field from entity.
* Proxies `modVal` field from entity.
*
* @deprecated - just for compatibility and can be dropped in future
* @returns {string|true|undefined} - modifier value
*/
get modVal() { return this._entity.modVal; }
get modVal() {
deprecate('modVal: just for compatibility and can be dropped in future');
return this._entity.modVal;
}

/**
* Returns the identifier of this cell.
Expand Down Expand Up @@ -275,17 +283,16 @@ module.exports = class BemCell {
* @param {string} [obj.val] — The modifier value of entity. Used if `mod` is a string.
* @param {string} obj.mod.name — the modifier name of entity.
* @param {string} [obj.mod.val] — the modifier value of entity.
* @param {string} [obj.modName] — the modifier name of entity. Used if `mod.name` wasn't specified.
* @param {string} [obj.modVal] — the modifier value of entity. Used if neither `mod.val` nor `val` were not specified.
* @param {string} [obj.modName] — the modifier name of entity. Used if `mod.name` wasn't specified. Deprecated
* @param {string} [obj.modVal] — the modifier value of entity. Used if neither `mod.val` nor `val` were not
* specified. Deprecated
* @param {string} [obj.tech] — technology of cell.
* @param {string} [obj.layer] — layer of cell.
* @returns {BemCell} An object representing cell.
* @example
* const BemCell = require('@bem/cell');
*
* BemCell.create({ block: 'my-button', mod: 'theme', val: 'red', tech: 'css' });
* BemCell.create({ block: 'my-button', modName: 'theme', modVal: 'red', tech: 'css' });
* BemCell.create({ entity: { block: 'my-button', modName: 'theme', modVal: 'red' }, tech: 'css' });
* // BemCell { block: 'my-button', mod: { name: 'theme', val: 'red' }, tech: 'css' }
*/
static create(obj) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -24,7 +24,8 @@
"node": ">= 4.0"
},
"dependencies": {
"@bem/entity-name": "1.3.1"
"@bem/entity-name": "1.3.1",
"depd": "^1.1.0"
},
"devDependencies": {
"ava": "^0.17.0",
Expand Down

0 comments on commit df4db81

Please sign in to comment.