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

feat(isBemEntityName): add isBemEntityName method #65

Merged
merged 3 commits into from
Dec 11, 2016
Merged

feat(isBemEntityName): add isBemEntityName method #65

merged 3 commits into from
Dec 11, 2016

Conversation

blond
Copy link
Member

@blond blond commented Dec 10, 2016

Resolved #64

@blond blond requested review from tadatuta and qfox December 10, 2016 12:43
@blond
Copy link
Member Author

blond commented Dec 10, 2016

/cc @tadatuta @zxqfox


const entityName = new BemEntityName({ block: 'input' });

BemEntityName.isBemEntityName(entityName); // true
Copy link
Member

@tadatuta tadatuta Dec 10, 2016

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?

Copy link
Member

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?

Copy link
Member Author

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__;
Copy link
Member

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) {
Copy link
Member

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

@blond blond merged commit ab86b66 into master Dec 11, 2016
@blond blond deleted the issue-64 branch December 11, 2016 17:19
@blond blond removed the in progress label Dec 11, 2016
@blond blond mentioned this pull request Dec 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants