Natural Pleistocene Monsters


    0.2.0 • Public • Published


    Build Status Dependency Status npm version Coverage Status

    Build nodes for stating which match an exact string


    npm install --save @stating/string-plugin


    // returns a builder function
    var buildBuilder = require('@stating/builder')
    // build a new builder to add plugins to and use
    var builder = buildBuilder()
    // add this plugin
    // now build a node to match the word "true"
    var trueNode = builder.string('true')
    // trueNode is a function which will wait for 4 bytes of input
    // and then test if the next 4 bytes equals 'true'.
    // it will if it's not.
    // it will if it is.
    // add it to your stating instance:
    stating.add('true', trueNode)
    // create others and add them...

    Custom Success

    When the node matches it increments index and calls

    Customize what it does by providing a function:

    var trueNode = builder.string('true', function() {
      this.index = this.index + 4, N.anotherNode)
    stating.add('true', trueNode)

    The contents of your function are inserted into the generated node function's "else" statement reached upon a successful match. Use the usual stating node args control, N, context.

    Note, you must call with or without nodes to properly advance.

    If you're going to test your success function then specify the standard stating parameters in the function declaration: function(control, N, context). Up to you. The code is placed into another function so, for example, control is already defined there.

    Debugging Breakpoint

    To add a debugging breakpoint wrap the generated function and set a breakpoint.

    function wrappedTrueNode(control, N, context) {
      // set a breakpoint here... then step into trueNode., control, N, context)  
    // add the wrapped version instead.
    stating.add('true', wrappedTrueNode)

    MIT License


    npm i @stating/string-plugin

    DownloadsWeekly Downloads






    Last publish


    • elidoran