<commit_before>module.exports =
  simpleMap:
    description: 'The squares of a few values over time'
    root:
      type: 'fromTime', args: "{1000: 1, 3000: 2, 5000: 3}"
    operators: [ { type: 'map', args: 'function(x) { return x * x }' } ]

  mapAndTake:
    description: 'The squares of infinite values bounded by take'
    root:
      type: 'interval', args: "500"
    operators: [
      { type: 'map', args: 'function(x) { return x * x }' }
      { type: 'take', args: '10' }
    ]

  "raceCondition#1":
    description:
      "User requests page 1, changes his mind and requests page 2, receives wrong page"
    root:
      type: 'fromTime', args: "{1000: 1, 2000: 2}"
    operators: [
      {
        type: 'flatMap'
        args: 'function(productNr) { return '
        observable:
          root:
            type: 'timer', args: "(5 - productNr * 2) * 1000"
          operators: [
            { type: 'map', args: 'function(x) { return "product " + productNr }' }
          ]
      }
    ]

  "fixedRaceCondition#1":
    description: "Fix race condition #1 by mapping waiting for previous response before new request. The user gets the every requested page and has to wait"
    root:
      type: 'fromTime', args: "{1000: 1, 2000: 2}"
    operators: [
      {
        type: 'concatMap'
        args: 'function(productNr) { return '
        observable:
          root:
            type: 'timer', args: "(5 - productNr * 2) * 1000"
          operators: [
            { type: 'map', args: 'function(x) { return "product " + productNr }' }
          ]
      }
    ]
  "fixedRaceCondition#2":
    description: "Fix race condition #1 by flat mapping the latest request. The user gets the latest requested page immediately"
    root:
      type: 'fromTime', args: "{1000: 1, 2000: 2}"
    operators: [
      {
        type: 'flatMapLatest'
        args: 'function(productNr) { return '
        observable:
          root:
            type: 'timer', args: "(5 - productNr * 2) * 1000"
          operators: [
            { type: 'map', args: 'function(x) { return "product " + productNr }' }
          ]
      }
    ]
  "wrong flatMapLatest":
    description: "Using flatMapLatest is not correct when you want all the mapped results, in this case flatMap is preferred."
    root:
      type: 'of', args: "'question1', 'question2', 'question3'"
    operators: [
      {
        type: 'flatMapLatest'
        args: 'function(question) { return '
        observable:
          root:
            type: 'timer', args: "1000"
          operators: [
            { type: 'map', args: 'function(x) { return "answer" + question[question.length - 1] }' }
          ]
      }
    ]<commit_msg>Add delay with selector example<commit_after>module.exports =
  simpleMap:
    description: 'The squares of a few values over time'
    root:
      type: 'fromTime', args: "{1000: 1, 3000: 2, 5000: 3}"
    operators: [ { type: 'map', args: 'function(x) { return x * x }' } ]

  mapAndTake:
    description: 'The squares of infinite values bounded by take'
    root:
      type: 'interval', args: "500"
    operators: [
      { type: 'map', args: 'function(x) { return x * x }' }
      { type: 'take', args: '10' }
    ]

  "raceCondition#1":
    description:
      "User requests page 1, changes his mind and requests page 2, receives wrong page"
    root:
      type: 'fromTime', args: "{1000: 1, 2000: 2}"
    operators: [
      {
        type: 'flatMap'
        args: 'function(productNr) { return '
        observable:
          root:
            type: 'timer', args: "(5 - productNr * 2) * 1000"
          operators: [
            { type: 'map', args: 'function(x) { return "product " + productNr }' }
          ]
      }
    ]

  "fixedRaceCondition#1":
    description: "Fix race condition #1 by mapping waiting for previous response before new request. The user gets the every requested page and has to wait"
    root:
      type: 'fromTime', args: "{1000: 1, 2000: 2}"
    operators: [
      {
        type: 'concatMap'
        args: 'function(productNr) { return '
        observable:
          root:
            type: 'timer', args: "(5 - productNr * 2) * 1000"
          operators: [
            { type: 'map', args: 'function(x) { return "product " + productNr }' }
          ]
      }
    ]
  "fixedRaceCondition#2":
    description: "Fix race condition #1 by flat mapping the latest request. The user gets the latest requested page immediately"
    root:
      type: 'fromTime', args: "{1000: 1, 2000: 2}"
    operators: [
      {
        type: 'flatMapLatest'
        args: 'function(productNr) { return '
        observable:
          root:
            type: 'timer', args: "(5 - productNr * 2) * 1000"
          operators: [
            { type: 'map', args: 'function(x) { return "product " + productNr }' }
          ]
      }
    ]
  "wrong flatMapLatest":
    description: "Using flatMapLatest is not correct when you want all the mapped results, in this case flatMap is preferred."
    root:
      type: 'of', args: "'question1', 'question2', 'question3'"
    operators: [
      {
        type: 'flatMapLatest'
        args: 'function(question) { return '
        observable:
          root:
            type: 'timer', args: "1000"
          operators: [
            { type: 'map', args: 'function(x) { return "answer" + question[question.length - 1] }' }
          ]
      }
    ]
  delayWithSelector:
    description: "Every value takes progressively longer to process"
    root:
      type: 'interval', args: '500'
    operators: [
      {
        type: 'delayWithSelector'
        args: 'function(input) { return '
        observable:
          root:
            type: 'timer', args: 'input * input * 500'
          operators: [
            {
              type: 'timeout'
              args: '3000'
            }
          ]
      }
      {
        type: 'takeUntilWithTime'
        args: '6000'
      }
    ]
{'fraction_non_alphanumeric': 0.12970781962506334, 'fraction_numerical': 0.03040027022462422, 'mean_word_length': 1.990909090909091, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, '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': '3364917', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1791, 'n_words': 561}