<commit_before>import model from './model';
import rest from './rest';
import { min } from './utils';

function hook(resource, pos, fn) {
  let method = resource._currentMethod;
  if (method === 'all') {
    method = ['get', 'post', 'put', 'delete', 'patch', 'list'];
  } else {
    method = [method];
  }
  /*eslint-disable */
  method.map((curr) => {
    if (resource._hooks[curr][pos]) {
      const _fn = resource._hooks[method][pos];
      resource._hooks[curr][pos] = (...args) => {
        _fn.apply(resource, args);
        fn.apply(resource, args);
      };
    } else {
      resource._hooks[curr][pos] = fn;
    }
  });
  /*eslint-enable */
}

export default class {
  constructor(name, userModel) {
    this._name = name;
    this._url = name;
    this._model = userModel;
    this._hooks = {
      list: {},
      get: {},<commit_msg>fix(resource): cant set `all hook` over 1 more function for a resource.<commit_after>import model from './model';
import rest from './rest';
import { min } from './utils';

function hook(resource, pos, fn) {
  let method = resource._currentMethod;
  if (method === 'all') {
    method = ['get', 'post', 'put', 'delete', 'patch', 'list'];
  } else {
    method = [method];
  }
  /*eslint-disable */
  method.map((curr) => {
    if (resource._hooks[curr][pos]) {
      const _fn = resource._hooks[curr][pos];
      resource._hooks[curr][pos] = (...args) => {
        _fn.apply(resource, args);
        fn.apply(resource, args);
      };
    } else {
      resource._hooks[curr][pos] = fn;
    }
  });
  /*eslint-enable */
}

export default class {
  constructor(name, userModel) {
    this._name = name;
    this._url = name;
    this._model = userModel;
    this._hooks = {
      list: {},
      get: {},
{'fraction_non_alphanumeric': 0.18742857142857142, 'fraction_numerical': 0.0005714285714285715, 'mean_word_length': 2.6555323590814197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4361407', 'n_tokens_mistral': 572, 'n_tokens_neox': 580, 'n_words': 137}