flukejs

0.0.11 • Public • Published

flukeJS

convenience functions for tokenizing javascript strings

objective

provide access to rules after each token gets split

usage

var source = 'A { B( C ); };'
    , rules = { 'open': '{' };

//get a single token:
fluke.splitNext( source, function( type, response ) {
    assert( type == 'open' ); 
    assert( response.lhs == 'A ' );
    assert( response.rhs == ' B( C ); };' );
    assert( response.token == '{' ); 
  }, rules );

//get all tokens: 
fluke.splitAll( source, function( type, response ) {
    assert( type == 'open' || type == 'end' ); 
    
    if (type == 'open') {
      assert( response.lhs == 'A ' );
      assert( response.rhs == ' B( C ); };'); 
      assert( response.token == '{' );
      assert( response.stash == '' );
    }
    else {
      assert( response.lhs == ' B( C ); };' );
      assert( response.stash == 'A {' );
    }
  }, rules ); 

Readme

Keywords

Package Sidebar

Install

npm i flukejs

Weekly Downloads

1

Version

0.0.11

License

MIT

Unpacked Size

8.67 kB

Total Files

7

Last publish

Collaborators

  • mbusenitz