<commit_before>if(typeof define!=='function'){var define=require('amdefine')(module);}

define([
  'jquery',
  'onion/type',
  'onion/event_emitter'
], function($, Type, eventEmitter){

  return Type.sub('JsonApi')

    .proto(eventEmitter)

    .proto({
      get: function (url, data, opts) {
        return this.ajax('GET', url, data, opts)
      },

      put: function (url, data, opts) {
        return this.ajax('PUT', url, JSON.stringify(data), $.extend({processData: false}, opts))
      },

      post: function (url, data, opts) {
        return this.ajax('POST', url, JSON.stringify(data), $.extend({processData: false}, opts))
      },

      delete: function (url, data, opts) {
        return this.ajax('DELETE', url, JSON.stringify(data), $.extend({processData: false}, opts))
      },

      ajax: function (type, url, data, opts) {
        opts = $.extend({
            type: type,
            url: url,
            data: data,
            contentType: 'application/json'
          }, opts)
        return $.ajax(opts)
      }
    })

})<commit_msg>JsonApi is more flexible with urlPrefix and defaultAjaxOptions options<commit_after>if(typeof define!=='function'){var define=require('amdefine')(module);}

define([
  'jquery',
  'onion/type',
  'onion/event_emitter'
], function($, Type, eventEmitter){

  return Type.sub('JsonApi')

    .proto(eventEmitter)

    .proto({
      init: function (options) {
        this.urlPrefix = options.urlPrefix || ""
        this.defaultAjaxOptions = options.defaultAjaxOptions || {}
      },

      get: function (url, data, opts) {
        return this.ajax('GET', url, data, opts)
      },

      put: function (url, data, opts) {
        return this.ajax('PUT', url, JSON.stringify(data), $.extend({processData: false}, opts))
      },

      post: function (url, data, opts) {
        return this.ajax('POST', url, JSON.stringify(data), $.extend({processData: false}, opts))
      },

      delete: function (url, data, opts) {
        return this.ajax('DELETE', url, JSON.stringify(data), $.extend({processData: false}, opts))
      },

      ajax: function (type, url, data, opts) {
        url = this.urlPrefix + url
        opts = $.extend({
            type: type,
            url: url,
            data: data,
            contentType: 'application/json'
          }, this.defaultAjaxOptions, opts)
        return $.ajax(opts)
      }
    })

})
{'fraction_non_alphanumeric': 0.16141078838174275, 'fraction_numerical': 0.0, 'mean_word_length': 2.5197080291970804, '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': '242598', 'n_tokens_mistral': 736, 'n_tokens_neox': 718, 'n_words': 177}