Skip to content

Commit

Permalink
Merge pull request #24 from bem-sdk/feature/ISSUE-17_deprecated_modName
Browse files Browse the repository at this point in the history
feat: #17 Add 'Deprecated' info wherever used 'modName, modVal'
  • Loading branch information
birhoff committed Mar 13, 2017
2 parents 7c137b8 + 9bf7079 commit 01f4218
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Returns an object representing this cell.
const BemCell = require('@bem/cell');
const BemEntityName = require('@bem/entity-name');
const cell = new BemCell({
entity: new BemEntityName({ block: 'button', mod: 'focused' })
entity: new BemEntityName({ block: 'button', mod: 'focused' }),
tech: 'css',
layer: 'desktop'
});
Expand Down Expand Up @@ -302,6 +302,15 @@ console.log(JSON.stringify(cell));
// ➜ {"entity":{"block":"input","mod":{"name":"available","val":true}},"tech":"css"}
```

Deprecation
-----------

Deprecation is performed with [depd](https://github.com/dougwilson/nodejs-depd)
To silencing deprecation warnings from being output simply use this. [Details](https://github.com/dougwilson/nodejs-depd#processenvno_deprecation)
```
NO_DEPRECATION=@bem/cell node app.js
```

License
-------

Expand Down
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const assert = require('assert');
const util = require('util');

const deprecate = require('depd')(require('./package.json').name);

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

module.exports = class BemCell {
Expand Down Expand Up @@ -98,18 +100,24 @@ module.exports = class BemCell {
/**
* Proxies `modVal` field from entity.
*
* @deprecated - just for compatibility and can be dropped in future
* @deprecated - just for compatibility. Use {@link BemCell#mod.name}
* @returns {String|undefined} - modifier name
*/
get modName() { return this._entity.modName; }
get modName() {
deprecate('modName: just for compatibility and can be dropped in future. Instead use \'mod.name\'');
return this._entity.modName;
}

/**
* Proxies `modName` field from entity.
* Proxies `modVal` field from entity.
*
* @deprecated - just for compatibility and can be dropped in future
* @deprecated - just for compatibility. Use {@link BemCell#mod.val}
* @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. Instead use \'mod.val\'');
return this._entity.modVal;
}

/**
* Returns the identifier of this cell.
Expand Down Expand Up @@ -286,7 +294,8 @@ module.exports = class BemCell {
* @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.modVal] — the modifier value of entity. Used if neither `mod.val` nor `val` were not
* specified.
* @param {String} [obj.tech] — technology of cell.
* @param {String} [obj.layer] — layer of cell.
* @returns {BemCell} An object representing cell.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
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.18.2",
Expand Down

0 comments on commit 01f4218

Please sign in to comment.