<commit_before>var ViewModel = require("./view-model.js")
var TodoModel = require("./todo-model.js")

module.exports = App

function App(initialState, inputs) {
    var router = inputs.router
    var events = inputs.events

    // Model
    var model = ViewModel(initialState)
    var events = model.events

    // store route in model
    router.on("route", function (ev) {
        model.route.set(ev.hash)
    })

    events.on(events.toggleAll, function (ev) {
        model.todos().array.forEach(function (todo) {
            todo.completed.set(!todo.completed())
        })
    })

    TodoItem(model, events)

    events.on(events.add, function (ev) {
        model.todos.push(TodoModel({
            title: ev.currentValue
        }))
        model.todoField.set("")
    })

    return model
}

function TodoItem(model, events) {
    var events = model.events

    events.on(events.toggle, function (ev) {
        ev.meta.completed.set(!ev.meta.completed())
    })

    events.on(events.editing, function (ev) {
        ev.meta.editing.set(true)
    })

    events.on(events.destroy, function (ev) {
        var index = model.todos.indexOf(ev.meta)
        model.todos.splice(index, 1)
    })

    events.on(events.edit, function (ev) {
        ev.meta.title.set(ev.currentValue)
        ev.meta.editing.set(false)
    })
}
<commit_msg>fix bug in eventNames<commit_after>var ViewModel = require("./view-model.js")
var TodoModel = require("./todo-model.js")

module.exports = App

function App(initialState, inputs) {
    var router = inputs.router
    var events = inputs.events

    // Model
    var model = ViewModel(initialState)
    var eventNames = model.events

    // store route in model
    router.on("route", function (ev) {
        model.route.set(ev.hash)
    })

    events.on(eventNames.toggleAll, function (ev) {
        model.todos().array.forEach(function (todo) {
            todo.completed.set(!todo.completed())
        })
    })

    TodoItem(model, events)

    events.on(eventNames.add, function (ev) {
        model.todos.push(TodoModel({
            title: ev.currentValue
        }))
        model.todoField.set("")
    })

    return model
}

function TodoItem(model, events) {
    var eventNames = model.events

    events.on(eventNames.toggle, function (ev) {
        ev.meta.completed.set(!ev.meta.completed())
    })

    events.on(eventNames.editing, function (ev) {
        ev.meta.editing.set(true)
    })

    events.on(eventNames.destroy, function (ev) {
        var index = model.todos.indexOf(ev.meta)
        model.todos.splice(index, 1)
    })

    events.on(eventNames.edit, function (ev) {
        ev.meta.title.set(ev.currentValue)
        ev.meta.editing.set(false)
    })
}

{'fraction_non_alphanumeric': 0.1408657373440939, 'fraction_numerical': 0.0007336757153338225, 'mean_word_length': 2.417293233082707, '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': '202124', 'n_tokens_mistral': 919, 'n_tokens_neox': 888, 'n_words': 155}