<commit_before>/***
 * Experimental generator
 */

import "timer.jsx";

class Async {
  static function sleep(durationMS : number) : (variant) -> void {
    return (g) -> {
      Timer.setTimeout(() -> {
        Async.go(g);
      }, durationMS);
    };
  }

  static function run(coro : () -> GeneratorObject.<(variant)->void>) : void {
    Async.go(coro());
  }

  static function go(v : variant) : void {
    var g = v as GeneratorObject.<(variant)->void>;

    var data = g.next();
    if (data.done) {
      return; // nothing
    } else {
      data.value(g);
    }
  }
}

class _Main {
  static function main(args : string[]) : void {
    Async.run(function * () {
      log "H";
      yield Async.sleep(100);
      log "e";
      yield Async.sleep(100);
      log "l";
      yield Async.sleep(100);
      log "l";
      yield Async.sleep(100);
      log "o";
    });
  }
}
// vim: set tabstop=2 shiftwidth=2 expandtab:
<commit_msg>update example/yield.jsx<commit_after>/***
 * Experimental generator
 */

import "timer.jsx";

class Async {
  static function sleep(durationMS : number) : (variant) -> void {
    return (g) -> {
      Timer.setTimeout(() -> {
        Async.go(g);
      }, durationMS);
    };
  }

  static function run(coro : () -> Generator.<(variant)->void>) : void {
    Async.go(coro());
  }

  static function go(v : variant) : void {
    var g = v as Generator.<(variant)->void>;

    var data = g.next();
    if (data.done) {
      return; // nothing
    } else {
      data.value(g);
    }
  }
}

class _Main {
  static function main(args : string[]) : void {
    Async.run(function * () {
      log "H";
      yield Async.sleep(100);
      log "e";
      yield Async.sleep(100);
      log "l";
      yield Async.sleep(100);
      log "l";
      yield Async.sleep(100);
      log "o";
    });
  }
}
// vim: set tabstop=2 shiftwidth=2 expandtab:

{'fraction_non_alphanumeric': 0.17261587639850826, 'fraction_numerical': 0.014917421417155035, 'mean_word_length': 2.183050847457627, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2048868', 'n_tokens_mistral': 662, 'n_tokens_neox': 634, 'n_words': 149}