packages/shex-webapp/doc/webpacks/shex-webapp.js
/* _repeat: map expr with a min and max cardinality to a corresponding AST with Groups and Stars.
       expr 1 1 => expr
       expr 0 1 => Choice(expr, Eps)
       expr 0 3 => Choice(EachOf(expr, Choice(EachOf(expr, Choice(expr, EPS)), Eps)), Eps)
       expr 2 5 => EachOf(expr, expr, Choice(EachOf(expr, Choice(EachOf(expr, Choice(expr, EPS)), Eps)), Eps))
       expr 0 * => KleeneStar(expr)
       expr 1 * => EachOf(expr, KleeneStar(expr))
       expr 2 * => EachOf(expr, expr, KleeneStar(expr))

       @@TODO: favor Plus over Star if Epsilon not in expr.
    */
map expr with a min and max cardinality to a corresponding AST with Groups and Stars.
map expr with a min and max cardinality to a corresponding AST with Groups and Stars .
function _repeat (expr, min, max) {
      if (min === undefined) { min = 1; }
      if (max === undefined) { max = 1; }
      if (min === 1 && max === 1) { return expr; }
      const opts = max === UNBOUNDED ?
        new KleeneStar(expr) :
        _seq(max - min).reduce(function (ret, elt, ord) {
          return ord === 0 ?
            new Choice([expr, new Epsilon]) :
            new Choice([new EachOf([expr, ret]), new Epsilon]);
        }, undefined);
      const reqd = min !== 0 ?
        new EachOf(_seq(min).map(function (ret) {
          return expr; 
        }).concat(opts)) : opts;
      return reqd;
    }
function _repeat ( expr , min , max ) { if ( min === undefined ) { min = 1 ; } if ( max === undefined ) { max = 1 ; } if ( min === 1 && max === 1 ) { return expr ; } const opts = max === UNBOUNDED ? new KleeneStar ( expr ) : _seq ( max - min ) . reduce ( function ( ret , elt , ord ) { return ord === 0 ? new Choice ( [ expr , new Epsilon ] ) : new Choice ( [ new EachOf ( [ expr , ret ] ) , new Epsilon ] ) ; } , undefined ) ; const reqd = min !== 0 ? new EachOf ( _seq ( min ) . map ( function ( ret ) { return expr ; } ) . concat ( opts ) ) : opts ; return reqd ; }
_repeat: map expr with a min and max cardinality to a corresponding AST with Groups and Stars.
_repeat : map expr with a min and max cardinality to a corresponding AST with Groups and Stars .
// @@ something with ret