-
Notifications
You must be signed in to change notification settings - Fork 3
feat(isBemEntityName): add isBemEntityName
method
#65
Conversation
|
||
const entityName = new BemEntityName({ block: 'input' }); | ||
|
||
BemEntityName.isBemEntityName(entityName); // true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't
const BemEntityName = require('@bem/entity-name');
const entityName = new BemEntityName({ block: 'input' });
entityName instanceof BemEntityName; // true
({}) instanceof BemEntityName; // false
be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if it's not for some reason let's rename the method to isInstanceOf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #2
instanceof
will not work with different versions of BemEntityName
.
* BemEntityName.isBemEntityName({}); // false | ||
*/ | ||
static isBemEntityName(entityName) { | ||
return entityName && entityName.__isBemEntityName__; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.name === entityName.constructor.name;
* BemEntityName.isBemEntityName(entityName); // true | ||
* BemEntityName.isBemEntityName({}); // false | ||
*/ | ||
static isBemEntityName(entityName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I still didn't get why not to call it isInstanceOf
Resolved #64