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

Commit 8190d88

Browse files
author
blond
committed
feat(deprecation): log deprecated info
1 parent 184757d commit 8190d88

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const util = require('util');
44

55
const ExtendableError = require('es6-error');
66
const stringifyEntity = require('@bem/naming').stringify;
7+
const deprecate = require('depd')(require('./package.json').name);
78

89
/**
910
* Enum for types of BEM entities.
@@ -114,19 +115,27 @@ class BemEntityName {
114115
* If entity is not modifier then returns `undefined`.
115116
*
116117
* @returns {?string} - entity modifier name.
117-
* @deprecated - use `mod.name` instead.
118+
* @deprecated use {@link BemEntityName#mod.name}
118119
*/
119-
get modName() { return this.mod && this.mod.name; }
120+
get modName() {
121+
deprecate(`modName is kept just for compatibility and can be dropped in the future. Use mod.name instead in ${this.inspect()} at`);
122+
123+
return this.mod && this.mod.name;
124+
}
120125

121126
/**
122127
* Returns the modifier value of this entity.
123128
*
124129
* If entity is not modifier then returns `undefined`.
125130
*
126131
* @returns {?(string|true)} - entity modifier name.
127-
* @deprecated - use `mod.val` instead.
132+
* @deprecated use {@link BemEntityName#mod.val}
128133
*/
129-
get modVal() { return this.mod && this.mod.val; }
134+
get modVal() {
135+
deprecate(`modVal is kept just for compatibility and can be dropped in the future. Use mod.val instead in ${this.inspect()} at`);
136+
137+
return this.mod && this.mod.val;
138+
}
130139

131140
/**
132141
* Returns id for this entity.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@bem/naming": "2.0.0-5",
36+
"depd": "1.1.0",
3637
"es6-error": "4.0.2"
3738
},
3839
"devDependencies": {

0 commit comments

Comments
 (0)