<commit_before>#!/usr/bin/env node
var jet = require('../lib/jet');
var express = require('express');
var http = require('http');

var app = express();
app.use(express.static('./'));

var server = http.createServer(app);
server.listen(80);

var daemon = new jet.Daemon();
daemon.listen({
  server: server,
  tcpPort: 11123
});

var peer = new jet.Peer({
  onOpen: function() {
    console.log('todo-server peer connected to daemon');
  },
  name: 'todo-server',
  port: 11123
});

var todos = {};
var id = 0;

peer.method({
  path: 'todo/add',
  call: function(todo) {
    var todoId = ++id;
    var todo = peer.state({
      path: 'todo/#' + todoId,
      value: {
        completed: todo.completed,
        title: todo.title,
        id: todoId
      },
      set: function(todo) {
        return {
          value: {
            completed: todo.completed,
            title: todo.title,
            id: todo.id
          }
        };
      }
    });

    todos[todoId] = todo;
  }
});

peer.method({
  path: 'todo/remove',
  call: function() {
    var args = Array.prototype.slice.call(arguments);
    args.forEach(function (todo) {
      todos[todo.id].remove();
    });
  }
});
<commit_msg>make port variable, add todo/removeAll<commit_after>#!/usr/bin/env node
var jet = require('../lib/jet');
var express = require('express');
var http = require('http');

var app = express();
app.use(express.static('./'));

var server = http.createServer(app);
var port = parseInt(process.argv[2]) || 80;
server.listen(port);

var daemon = new jet.Daemon();
daemon.listen({
  server: server,
  tcpPort: 11123
});

var peer = new jet.Peer({
  onOpen: function() {
    console.log('todo-server peer connected to daemon');
  },
  name: 'todo-server',
  port: 11123
});

var todos = {};
var id = 0;

peer.method({
  path: 'todo/add',
  call: function(todo) {
    var todoId = ++id;
    var todo = peer.state({
      path: 'todo/#' + todoId,
      value: {
        completed: todo.completed,
        title: todo.title,
        id: todoId
      },
      set: function(todo) {
        return {
          value: {
            completed: todo.completed,
            title: todo.title,
            id: todo.id
          }
        };
      }
    });

    todos[todoId] = todo;
  }
});

peer.method({
  path: 'todo/remove',
  call: function() {
    var args = Array.prototype.slice.call(arguments);
    args.forEach(function (todo) {
      todos[todo.id].remove();
    });
  }
});

peer.method({
  path: 'todo/removeAll',
  call: function() {
    for(var id in todos) {
      todos[id].remove();
    }
  }
});

{'fraction_non_alphanumeric': 0.17335907335907336, 'fraction_numerical': 0.010424710424710425, 'mean_word_length': 2.356217616580311, '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': '4703345', 'n_tokens_mistral': 915, 'n_tokens_neox': 896, 'n_words': 202}