2.0.1 • Published 6 years ago

go-msg v2.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

go-msg

Parses objects representing messages containing a single primary key and zero or more optional attributes.

Installation

$ npm install go-msg

Example (test.js)

var msgStructure = {
        primary: {
            div: 1, 
            input: 0, 
            style: 1,
        }, 
        secondary: {
            style: 1,
        },
};

var msgParser = new require ('go-msg') (msgStructure);

var msg = {div: 'hello world', style: 'color: red;'};
var msgParsed = msgParser.parseMsg (msg);
    console.log ('msgParsed: ' + JSON.stringify (msgParsed) + '\n');
        // expected output:     msgParsed: {"p":"div","c":"hello world","s":{"style":"color: red;"}}

var msg = {id: 'style1', class: 'theStyle', style: '.class1: {color: blue;}'};
var msgParsed = msgParser.parseMsg (msg);
    console.log ('msgParsed: ' + JSON.stringify (msgParsed) + '\n');
        // exptected output:    msgParsed: {"p":"style","c":".class1: {color: blue;}","s":{"id":"style1","class":"theStyle"}}

var msg = {id: 'inputId15', class: 'button', input:0, autocomplete: 'autocomplete', value: 'showme', type: 'submit'};
var msgParsed = msgParser.parseMsg (msg);
    console.log ('msgParsed: ' + JSON.stringify (msgParsed) + '\n');
        // exptected output:    msgParsed: {"p":"input","c":null,"s":{"id":"inputId15","class":"button","autocomplete":"autocomplete","value":"showme","type":"submit"}}

Results

msgParsed: {"p":"div","c":"hello world","s":{"style":"color: red;"}}

msgParsed: {"p":"style","c":".class1: {color: blue;}","s":{"id":"style1","class":"theStyle"}}

msgParsed: {"p":"input","c":null,"s":{"id":"inputId15","class":"button","autocomplete":"autocomplete","value":"showme","type":"submit"}}
2.0.1

6 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago