<commit_before>/**
 * Dependencies
 */

var events = require('events')
var sys = require('sys')

var _ = require('lodash')
var moment = require('moment')

/**
 * API for listening to task document changes
 */

exports.TasksAPI = function (hoodie, options) {
  var task_events = new events.EventEmitter()

  var task = {}

  task.on = function () {
    return task_events.on.apply(task_events, arguments)
  }

  task.emit = function () {
    return task_events.emit.apply(task_events, arguments)
  }

  task.addSource = options.addSource
  task.removeSource = options.removeSource

  task.success = function (dbname, task,/* optional */ callback) {
    callback = callback || function (err) {
      if (err) {
        console.error(
          'task.success() error:\n' +
          sys.inspect(task) +
          '\n' + (err.stack || err.message || err.toString())
        )
      }
    }
    var updated_task = _.extend(task, {
      '$processedAt': moment().format(),
      '_deleted': true
    })
    var db = hoodie.database(dbname)
    return db.update(task.type, task.id, updated_task, callback)
  }

  task.error = function (dbname, task, err,/* optional */ callback) {
    callback = callback || function (err) {
      if (err) {
        console.error(
          'task.error() error:\n' +
          sys.inspect(task) +
          '\n' + (err.stack || err.message || err.toString())
        )
      }
    }
    var updated_task = _.extend(task, {
      '$processedAt': moment().format(),
      '$error': err
    })
    var db = hoodie.database(dbname)
    return db.update(task.type, task.id, updated_task, callback)
  }

  return task
}
<commit_msg>style: remove deprecated sys call<commit_after>/**
 * Dependencies
 */

var events = require('events')
var util = require('util')

var _ = require('lodash')
var moment = require('moment')

/**
 * API for listening to task document changes
 */

exports.TasksAPI = function (hoodie, options) {
  var task_events = new events.EventEmitter()

  var task = {}

  task.on = function () {
    return task_events.on.apply(task_events, arguments)
  }

  task.emit = function () {
    return task_events.emit.apply(task_events, arguments)
  }

  task.addSource = options.addSource
  task.removeSource = options.removeSource

  task.success = function (dbname, task,/* optional */ callback) {
    callback = callback || function (err) {
      if (err) {
        console.error(
          'task.success() error:\n' +
          util.inspect(task) +
          '\n' + (err.stack || err.message || err.toString())
        )
      }
    }
    var updated_task = _.extend(task, {
      '$processedAt': moment().format(),
      '_deleted': true
    })
    var db = hoodie.database(dbname)
    return db.update(task.type, task.id, updated_task, callback)
  }

  task.error = function (dbname, task, err,/* optional */ callback) {
    callback = callback || function (err) {
      if (err) {
        console.error(
          'task.error() error:\n' +
          util.inspect(task) +
          '\n' + (err.stack || err.message || err.toString())
        )
      }
    }
    var updated_task = _.extend(task, {
      '$processedAt': moment().format(),
      '$error': err
    })
    var db = hoodie.database(dbname)
    return db.update(task.type, task.id, updated_task, callback)
  }

  return task
}

{'fraction_non_alphanumeric': 0.14984984984984984, 'fraction_numerical': 0.0, 'mean_word_length': 2.524867724867725, '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': '3543200', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1031, 'n_words': 238}