<commit_before>'use strict';

var request = require('request');
var buildUrl = require('./helpers/build-url');

module.exports = {
  "device": null,
  "action": null,
  "token": null,
  "post": function(data, callback){

    if(arguments.length < 2){
      callback = data;
      data = {};
    }

    callback = callback || function(){};
    data = data || {};

    request.post(buildUrl(this), data, callback);
  }
}<commit_msg>action argument is now required<commit_after>'use strict';

var request = require('request');
var buildUrl = require('./helpers/build-url');

module.exports = function(config){

  return function(action, data, callback){

    if (!action || typeof action !== 'string') {
      callback({
        "error": "Invalid action passed to particle beam."
      });
      return false;
    }

    config.action = action;

    if(typeof data === 'function'){
      callback = data;
      data = {};
    }

    callback = callback || function(){};
    data = data || {};

    request.post(buildUrl(config), data, callback);
  }
};
{'fraction_non_alphanumeric': 0.17063870352716873, 'fraction_numerical': 0.0009532888465204957, 'mean_word_length': 3.0384615384615383, 'pattern_counts': {'":': 5, '<': 4, '<?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': '3265452', 'n_tokens_mistral': 311, 'n_tokens_neox': 301, 'n_words': 80}