<commit_before>/* sample OS to test that the Grove is working */
var keys = {}
var text = ''
function main(event, dataRecorder) {
  var cmd = DataCommand.noop()
  if (event.type === 'startup') {
    text = dataRecorder.read('myfile')
    return 'Start typing! Text is saved when you press ENTER.'
  }

  if (event.type === 'keyDown') {
    keys[event.key] = true
    switch (event.key) {
      case 13:
        // enter
        text += '\n'
        cmd = cmd.and(DataCommand.write('myfile', text))
        break
      case 8:
        // backspace
        text = text.slice(0, text.length - 1)
        break
      case 192:
        // tilde
        // test that we can recover from an infinite loop
        while (true) {}
      default:
        text += String.fromCharCode(event.key)
    }
  }

  if (event.type === 'keyUp') {
    delete keys[event.key]
  }

  var eventOutput =
    '' + event.type + ' ' + Object.keys(keys).join(', ')
  return {
    screen: [eventOutput]
      .concat(text.split('\n')),
    dataCommand: cmd
  }
}<commit_msg>Update testOS to use new record API<commit_after>/* sample OS to test that the Grove is working */
var keys = {}
var text = ''
function main(event, dataRecorder) {
  var toSave = {}
  if (event.type === 'startup') {
    text = dataRecorder.read('myfile')
    return 'Start typing! Text is saved when you press ENTER.'
  }

  if (event.type === 'keyDown') {
    keys[event.key] = true
    switch (event.key) {
      case 13:
        // enter
        text += '\n'
        toSave['myfile'] = text
        break
      case 8:
        // backspace
        text = text.slice(0, text.length - 1)
        break
      case 192:
        // tilde
        // test that we can recover from an infinite loop
        while (true) {}
      default:
        text += String.fromCharCode(event.key)
    }
  }

  if (event.type === 'keyUp') {
    delete keys[event.key]
  }

  var eventOutput =
    '' + event.type + ' ' + Object.keys(keys).join(', ')
  return {
    screen: [eventOutput]
      .concat(text.split('\n')),
    records: toSave
  }
}
{'fraction_non_alphanumeric': 0.14389183969097055, 'fraction_numerical': 0.00772573635924674, 'mean_word_length': 2.024817518248175, 'pattern_counts': {'":': 0, '<': 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': '4752456', 'n_tokens_mistral': 686, 'n_tokens_neox': 663, 'n_words': 186}