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

Ability to read bemObjects by levels, not randomly. #38

Open
Yeti-or opened this issue Mar 18, 2016 · 3 comments
Open

Ability to read bemObjects by levels, not randomly. #38

Yeti-or opened this issue Mar 18, 2016 · 3 comments

Comments

@Yeti-or
Copy link
Member

Yeti-or commented Mar 18, 2016

Currently bemObjects are pushed from different levels.
what about adding some API like this:

walk.sorted([
    'libs/bem-core/common.blocks',
    'libs/bem-core/desktop.blocks',
    'common.blocks',
    'desktop.blocks'
], config)
    .pipe(stringify())
    .pipe(process.stdout);

so walk will flush objects randomly from levels,
walk.sorted will flush it grouping by levels, in order of levels in array.
@blond what do u think?

@blond
Copy link
Member

blond commented Mar 20, 2016

I agree that such a possibility must be in the API, but I don't like walk.sorted method.

Also I do not want to bem-walk has a complex API. What can we do in my opinion:

  1. Sort by default (if this does not slow down the scan)

    The order will be taken into account:

    walk(['common.blocks', 'desktop.blocks'])
        .pipe(stringify())
        .pipe(process.stdout);

    The order will not be taken into account:

    walk('*.blocks', config)
        .pipe(stringify())
        .pipe(process.stdout);
  2. Add option the levelOrder option

    The order will not be taken into account:

    walk(['common.blocks', 'desktop.blocks'])
        .pipe(stringify())
        .pipe(process.stdout);

    The order will be taken into account:

    walk(['common.blocks', 'desktop.blocks'], { levelOrder: true })
        .pipe(stringify())
        .pipe(process.stdout);

    The order will be taken into account:

    walk('*.blocks', config, { levelOrder: ['common.blocks', 'desktop.blocks'] })
        .pipe(stringify())
        .pipe(process.stdout);
  3. Add option the levelOrder option with true value by default

    The order will be taken into account:

    walk(['common.blocks', 'desktop.blocks'])
        .pipe(stringify())
        .pipe(process.stdout);

    The order will not be taken into account:

    walk('*.blocks', config)
        .pipe(stringify())
        .pipe(process.stdout);

@Yeti-or, what do you think about this API? May be you have other ideas?

@blond
Copy link
Member

blond commented May 9, 2016

In terms implementation it's like #20.

@blond
Copy link
Member

blond commented May 10, 2016

The #16 issue have bean closed, so we can add ordered option.

walk(['common.blocks', 'desktop.blocks'], { ordered: true })
    .pipe(stringify())
    .pipe(process.stdout);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants