<commit_before>import Ember from 'ember';
import { pluralize } from './utils/inflector';
import Pretender from 'pretender';
import Db from './db';
import controller from './controller';

/*
  Given a variable number of arguments, it generates an array of with
  [path, handler, code, options], `path` and `options` being always defined,
  and `handler` and `code` being undefined if not suplied.
*/
function extractStubArguments(/* path, handler, code, options */) {
  var ary = Array.prototype.slice.call(arguments);
  var argsInitialLength = ary.length;
  var lastArgument = ary[ary.length - 1];
  var options;
  var i = 0;
  if (lastArgument.constructor === Object) {
    argsInitialLength--;
  } else {
    options = { colesce: false };
    ary.push(options);
  }
  for(; i < 5 - ary.length; i++) {
    ary.insertAt(argsInitialLength, undefined);
  }
  return ary;
}

/*
  The Mirage server, which has a db and an XHR interceptor.

  Requires an environment.
*/
export default function(options) {
  // Init vars
  var server = this;

  if (!options || !options.environment) {
    throw "You must pass an environment in when creating a Mirage server instance";
  }
  var environment = options.environment;

  /*
    Routing methods + props
  */

  // Default properties
  this.timing = 400;
  this.namespace = '';

  this.loadConfig = function(config) {
    config.call(this);
    this.timing = environment === 'test' ? 0 : (this.timing || 0);
  };<commit_msg>Use splice instead of insertAt<commit_after>import Ember from 'ember';
import { pluralize } from './utils/inflector';
import Pretender from 'pretender';
import Db from './db';
import controller from './controller';

/*
  Given a variable number of arguments, it generates an array of with
  [path, handler, code, options], `path` and `options` being always defined,
  and `handler` and `code` being undefined if not suplied.
*/
function extractStubArguments(/* path, handler, code, options */) {
  var ary = Array.prototype.slice.call(arguments);
  var argsInitialLength = ary.length;
  var lastArgument = ary[ary.length - 1];
  var options;
  var i = 0;
  if (lastArgument.constructor === Object) {
    argsInitialLength--;
  } else {
    options = { colesce: false };
    ary.push(options);
  }
  for(; i < 5 - ary.length; i++) {
    ary.splice(argsInitialLength, 0, undefined);
  }
  return ary;
}

/*
  The Mirage server, which has a db and an XHR interceptor.

  Requires an environment.
*/
export default function(options) {
  // Init vars
  var server = this;

  if (!options || !options.environment) {
    throw "You must pass an environment in when creating a Mirage server instance";
  }
  var environment = options.environment;

  /*
    Routing methods + props
  */

  // Default properties
  this.timing = 400;
  this.namespace = '';

  this.loadConfig = function(config) {
    config.call(this);
    this.timing = environment === 'test' ? 0 : (this.timing || 0);
  };
{'fraction_non_alphanumeric': 0.12737771739130435, 'fraction_numerical': 0.00577445652173913, 'mean_word_length': 3.3824404761904763, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6134050', 'n_tokens_mistral': 924, 'n_tokens_neox': 893, 'n_words': 301}