<commit_before>'use strict';
const request = require('request');

var getJSON = function(query, cb) {
  if (typeof query != 'string') cb(TypeError('Expected a string as first argument.'));

  const base = 'https://www.googleapis.com/scribe/v1/research';
  const qs = {
    key: '<KEY>',
    dataset: 'dictionary',
    dictionaryLanguage: 'en',
    callback: cb,
    query: query
  }

  request({url: base, qs: qs, json: true}, function(error, response, body) {
    cb(error, body);
  });
}

var getDefinition = function(query, cb) {
  getJSON(query, function(error, response) {
    if (response.data == undefined) cb(ReferenceError('No results found for given query.'));
    var definitions = [];
    response.data[0]['dictionaryData']['definitionData'].forEach(function(obj, i) {
      definitions.push(obj.meanings[0].meaning)
    });
    cb(error, definitions);
  });
}

module.exports = getJSON;
module.exports.getDef = getDefinition;<commit_msg>Add return for callbacks, name for Errors.<commit_after>'use strict';

const request = require('request');

var getJSON = function(query, cb) {
  
  if (typeof query != 'string') return cb(new TypeError('Expected a string as first argument.'), null);

  const base = 'https://www.googleapis.com/scribe/v1/research';
  const qs = {
    key: '<KEY>',
    dataset: 'dictionary',
    dictionaryLanguage: 'en',
    callback: cb,
    query: query
  }

  request({url: base, qs: qs, json: true}, function(error, response, body) {
    return cb(error, body);
  });
}

var getDefinitions = function(query, cb) {
  getJSON(query, function(error, response) {
    if (response['data'] == undefined) return cb(new Error('No results for given query.'), null);

    var definitions = [];
    response['data'][0]['dictionaryData']['definitionData'].forEach(function(obj, i) {
      definitions.push(obj.meanings[0].meaning)
    });

    cb(error, definitions);
  });
}

module.exports = getJSON;
module.exports.definitions = getDefinitions;
{'fraction_non_alphanumeric': 0.16210739614994935, 'fraction_numerical': 0.00303951367781155, 'mean_word_length': 4.143229166666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '840275', 'n_tokens_mistral': 617, 'n_tokens_neox': 602, 'n_words': 155}