How to use the pegjs.util.clone 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( "shallow clones an object", function () {

            expect( util.clone( meta ) )
                .to.be.an( "object" )
                .that.has.own.includes( meta );

        } );
github pegjs / pegjs / test / unit / parser.spec.js View on Github external
function commented( grammar, comments, options ) {

        function toObject( result, comment ) {

            result[ comment.offset ] = {
                text: comment.text,
                multiline: comment.multiline,
            };

            return result;

        }

        grammar = util.clone( grammar );
        grammar.comments = options.extractComments ? comments.reduce( toObject, {} ) : null;
        return grammar;

    }