Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize #6

Open
blond opened this issue Feb 14, 2015 · 5 comments
Open

Serialize #6

blond opened this issue Feb 14, 2015 · 5 comments

Comments

@blond
Copy link
Member

blond commented Feb 14, 2015

The reverse process of normalization. The method serialize should process declaration specific to each format.

BEMDECL 1.0

var serialize = require('bem-decl').serialize,
    decl = [
        { name: 'block', elems: [{ name: 'elem-1' }] }],
        { name: 'block', elems: [{ name: 'elem-2' }] }]
    ];

serialize(decl, { version: '1.0' });
// [{ name: 'block', elems: [{ name: 'elem-1' }, { name: 'elem-2' }] }]

BEMDECL 2.0

var serialize = require('bem-decl').serialize,
    decl = [
        { block: 'block' }],
        { block: 'block', elem: 'elem-1' }],
        { block: 'block', elem: 'elem-2' }]
    ];

serialize(decl, { version: '2.0' });
// [{ block: 'block', elems: ['elem-1', 'elem-2'] }]

BEMDECL next

var serialize = require('bem-decl').serialize,
    decl = [
        { block: 'block' }],
        { scope: 'block', elem: 'elem-1' }],
        { scope: 'block', elem: 'elem-2' }]
    ];

serialize(decl, { version: 'next' });
// [{ block: 'block', elems: ['elem-1', 'elem-2'] }]
@blond blond changed the title Add serialize method Serialize Mar 31, 2015
@qfox
Copy link
Contributor

qfox commented May 10, 2016

Can we rename this to stringify?

@blond
Copy link
Member Author

blond commented May 10, 2016

No, serialize is method inverse normilize.

Input type for serialize is Array, and output is Array.

Input type for stringify is Array, but output is String.

@qfox
Copy link
Contributor

qfox commented May 10, 2016

Ah, true. So this issue blocking stringify method.

@blond
Copy link
Member Author

blond commented May 10, 2016

So this issue blocking stringify method.

For v1 and next formats only.

@qfox
Copy link
Contributor

qfox commented Jan 23, 2017

If we decide to hide away normalize method, should we have serialize in public API?

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

No branches or pull requests

3 participants