<commit_before>var Opbeat = require('./opbeat')

var wrap = function (fn, before, after) {
  return function opbeatInstrumentationWrapper () {
    var args = Array.prototype.slice.call(arguments)

    before.apply(this, args)

    var result = fn.apply(this, args)

    after.apply(this, args)

    return result
  }
}

var instrumentMethod = function (module, fn, transaction, type, options) {<commit_msg>Handle promise-based return values<commit_after>var Opbeat = require('./opbeat')

var wrap = function (fn, before, after) {
  return function opbeatInstrumentationWrapper () {
    var args = Array.prototype.slice.call(arguments)

    before.apply(this, args)

    var result = fn.apply(this, args)

    // Promise handling
    if (result && typeof result.then === 'function') {
      result.then(function() {
        after.apply(this, args)
      }.bind(this))
    } else {
      after.apply(this, args)
    }

    return result
  }
}

var instrumentMethod = function (module, fn, transaction, type, options) {
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0, 'mean_word_length': 3.4025974025974026, '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': '772298', 'n_tokens_mistral': 307, 'n_tokens_neox': 297, 'n_words': 81}