class-o-mat-data-object-plugin

    0.0.4 • Public • Published

    ClassOMat DataObject plugin

    Will export a data as an object or a JSON string from a
    ClassOMat-generated class ( Minion ) instance.

    Compatible with ClassOMat ~0.5.0

    This is Version 0.0.4 (Alpha):

    STATUS: Strongly recommend using "~0.x.x" in your package.json instead of "^0.x.x". Should work, but use at own risk.
    Updates are frequent for both new features and bug fixes.
    Release Notes:

        import ClassOMat from 'class-o-mat';
        import dOPlugin from 'class-o-mat-data-object-plugin';
        
        const albumOMatDO = new ClassOMat('albumOMatDOM');
        const songOMat = new ClassOMat('songOMat');
        songOMat.field('title');
        albumOMat.field('title').addChild(songOMat).as$('songs');
    
        dOPlugin.connect(albumOMatDO);
    
        const album = new (albumOMat.$())();
        album.title('A Momentary Lapse of Reason');
        album.songs().title('Learning to Fly');
        album.songs().title('On the Turning Away');
    
        album.___data(); /*
            returns: 
            { 
                title: 'A Momentary Lapse of Reason',
                songs: [ 
                    {title: 'Learning to Fly'},
                    {title: 'On the Turning Away'},
                ]
            }
        */
       
       album.___json(); // returns JSON string of album.___data();
    

    Without this plugin, the params() method of a Minion would return all the params in raw form.

    With this plugin, all params that are specified is fields are removed and all child minions will also be included in the object.

    Release Notes :

    Version 0.0.4

    upped class-o-mat version to 0.5.6. Non breaking change.

    Version 0.0.3

    fixed .npmignore error

    Version 0.0.2

    Reworked to new ClassOMat plugin system.

    Install

    npm i class-o-mat-data-object-plugin

    DownloadsWeekly Downloads

    4

    Version

    0.0.4

    License

    GPL-2.0

    Last publish

    Collaborators

    • bobbwhy