<commit_before>// State machine representing URI's
//
// Cleans up the logic of connecting via ports,
// urls or file sockets.

var state = require('state');

module.exports = state({
  // Possible states for the URI
  Initial: state('initial', {
    set: function(value) {
      this.input = value;
    }
  }),
  Url: state(),
  Port: state(),
  File: state(),

  // default for all
  get: function() {
    return this.input;
  }
});
<commit_msg>Add listen and forward methods.<commit_after>// State machine representing URI's
//
// Cleans up the logic of connecting via ports,
// urls or file sockets.

var state = require('state');
var isUrl = require('is-url');
var _ = require('lodash');

module.exports = state({
  // Possible states for the URI
  Initial: state('initial', {
    set: function(input) {
      this.input = input;
    },
    listen: function(input) {
      this.mode = 'listen';
      this.set(input);
    },
    forward: function(input) {
      this.mode = 'forward';
      this.set(input);
    }
  }),
  Url: state(),
  Port: state(),
  File: state(),

  // default for all
  get: function() {
    return this.input;
  },

  // noops in all but initial state.
  listen: function() {},
  forward: function() {}
});

{'fraction_non_alphanumeric': 0.15602263540824576, 'fraction_numerical': 0.0, 'mean_word_length': 2.7515151515151515, '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': '25175', 'n_tokens_mistral': 394, 'n_tokens_neox': 381, 'n_words': 121}