How to use the pegjs.util.each function in pegjs

To help you get started, we’ve selected a few pegjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pegjs / pegjs / test / api / pegjs-util.spec.js View on Github external
it( "should iterate over an objects properties", function () {

            const size = Object.keys( util ).length;
            const entries = [];

            util.each( util, ( value, key ) => {

                entries.push( { key, value } );

            } );

            expect( entries.length ).to.equal( size );

            entries.forEach( entry => {

                expect( util )
                    .to.have.ownProperty( entry.key )
                    .which.equals( entry.value );

            } );

        } );
github pegjs / pegjs / test / api / pegjs-util.spec.js View on Github external
it( "applies a transformation on each properties value", function () {

            util.each( result, property => {

                expect( property ).to.be.a( "string" );

            } );

        } );
github pegjs / pegjs / test / unit / parser.spec.js View on Github external
grammar( node ) {

                delete node.location;
                delete node._alwaysConsumesOnSuccess;

                if ( node.initializer ) {

                    strip( node.initializer );

                }
                if ( node.comments ) {

                    util.each( node.comments, stripLeaf );

                }
                node.rules.forEach( strip );

            },