<commit_before>/**
 * sqlite-parser
 */
import parser from './lib/parser';
import {isFunc} from './lib/parser-util';
import Tracer from './lib/tracer';

export default function sqliteParser(source, callback) {
  let res, err;
  const t = Tracer();
  const isAsync = isFunc(callback);
  try {
    res = parser(source, { 'tracer': t });
  } catch (e) {
    err = t.smartError(e);
  }
  if (isAsync) {
    callback(err, res);
  } else {
    if (err) { throw err; }
    return res;
  }
};


sqliteParser['NAME'] = 'sqlite-parser';
sqliteParser['VERSION'] = '@@VERSION';
<commit_msg>Parser was blocking when called as async func.<commit_after>/**
 * sqlite-parser
 */
import parser from './lib/parser';
import {isFunc} from './lib/parser-util';
import Tracer from './lib/tracer';

export default function sqliteParser(source, callback) {
  const t = Tracer();
  const isAsync = isFunc(callback);
  const opts = { 'tracer': t };
  // Async
  if (isAsync) {
    setTimeout(function () {
      try {
        callback(null, parser(source, opts));
      } catch (e) {
        callback(t.smartError(e));
      }
    }, 0);
    return;
  }
  // Sync
  try {
    return parser(source, opts);
  } catch (e) {
    throw t.smartError(e);
  }
};


sqliteParser['NAME'] = 'sqlite-parser';
sqliteParser['VERSION'] = '@@VERSION';

{'fraction_non_alphanumeric': 0.1717557251908397, 'fraction_numerical': 0.0007633587786259542, 'mean_word_length': 3.0841121495327104, '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': '4563341', 'n_tokens_mistral': 447, 'n_tokens_neox': 440, 'n_words': 114}