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

Commit ae66cf1

Browse files
author
blond
committed
feat(isBemEntityName): add isBemEntityName method
1 parent 0d84693 commit ae66cf1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module.exports = class BemEntityName {
4747
} else if (modObj || hasModVal) {
4848
throw new Error('This is not valid BEM entity: the field `mod.name` is undefined.');
4949
}
50+
51+
this.__isBemEntityName__ = true;
5052
}
5153

5254
/**
@@ -256,4 +258,22 @@ module.exports = class BemEntityName {
256258
isEqual(entityName) {
257259
return entityName && (this.id === entityName.id);
258260
}
261+
262+
/**
263+
* Determines whether specified entity is instance of BemEntityName.
264+
*
265+
* @param {BemEntityName} entityName - the entity to check.
266+
*
267+
* @returns {boolean} A Boolean indicating whether or not specified entity is instance of BemEntityName.
268+
* @example
269+
* const BemEntityName = require('@bem/entity-name');
270+
*
271+
* const entityName = new BemEntityName({ block: 'input' });
272+
*
273+
* BemEntityName.isBemEntityName(entityName); // true
274+
* BemEntityName.isBemEntityName({}); // false
275+
*/
276+
static isBemEntityName(entityName) {
277+
return entityName && entityName.__isBemEntityName__;
278+
}
259279
};

0 commit comments

Comments
 (0)