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

Type Enum #101

Open
blond opened this issue Apr 14, 2017 · 1 comment
Open

Type Enum #101

blond opened this issue Apr 14, 2017 · 1 comment
Labels
Milestone

Comments

@blond
Copy link
Member

blond commented Apr 14, 2017

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

const buttonName = new BemEntityName({ block: 'button' });
const buttonTextName = new BemEntityName({ block: 'button', elem: 'text' });
const buttonTextBoldName = new BemEntityName({ block: 'button', elem: 'text', mod: 'bold' });

buttonName.type === BemEntityName.TYPES.BLOCK // true
buttonTextName.type === BemEntityName.TYPES.ELEM // true
buttonName.type === BemEntityName.TYPES.ELEM_MOD // true
@blond
Copy link
Member Author

blond commented Apr 15, 2017

We can force to use TYPES if enum will contains Symbols.

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

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

name.block // Symbol(BLOCK),

name.block === BemEntityName.TYPES.BLOCK // true
name.block === Symbol('BLOCK') // false

BemEntityName.TYPES

// ➜ Enum {
//    BLOCK: Symbol(BLOCK),
//    BLOCK_MOD: Symbol(BLOCK_MOD),
//    ELEM: Symbol(ELEM),
//    ELEM_MOD: Symbol(ELEM_MOD)
// }

see https://github.com/wwayne/es6-enum

@blond blond added this to the 2.0 milestone Apr 15, 2017
@blond blond added the question label Apr 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant