<commit_before>import { map, isArray } from 'lodash'

function checkStatus (response) {
  if (response.status >= 200 && response.status < 300) {
    return response
  } else {
    var error = new Error(response.statusText)
    error.response = response
    throw error
  }
}

export function call (server, name, params = []) {
  if (server.secret) params.unshift(`token:${server.secret}`)
  var uri = `http${server.ssl ? 's' : ''}://${server.host}:${server.port}/jsonrpc`
  return fetch(uri, {
    method: 'post',
    body: JSON.stringify({
      'jsonrpc': '2.0',
      'id': 'Glutton',
      'method': name,
      'params': params || []
    })
  })
  .then(checkStatus)
  .then(res => res.json())
  .then(res => res.result)
}

export function multicall (server, calls) {
  if (!isArray(calls)) calls = map(calls, (value, key) => ({ methodName: key, params: value || [] }))
  if (server.secret) {
    calls = calls.forEach(function (call) {
      call.params = call.params.unshift(`token:${server.secret}`)
    })
  }
  var uri = `http${server.ssl ? 's' : ''}://${server.host}:${server.port}/jsonrpc`
  return fetch(uri, {
    method: 'post',
    body: JSON.stringify({
      'jsonrpc': '2.0',
      'id': 'Glutton',
      'method': 'system.multicall',
      'params': [calls]
    })
  })
  .then(checkStatus)
  .then(res => res.json())
  .then(res => res.result.map(value => value[0]))
}<commit_msg>Fix bug with secret<commit_after>import { map, isArray } from 'lodash'

function checkStatus (response) {
  if (response.status >= 200 && response.status < 300) {
    return response
  } else {
    var error = new Error(response.statusText)
    error.response = response
    throw error
  }
}

export function call (server, name, params = []) {
  if (server.secret) params.unshift(`token:${server.secret}`)
  var uri = `http${server.ssl ? 's' : ''}://${server.host}:${server.port}/jsonrpc`
  return fetch(uri, {
    method: 'post',
    body: JSON.stringify({
      'jsonrpc': '2.0',
      'id': 'Glutton',
      'method': name,
      'params': params || []
    })
  })
  .then(checkStatus)
  .then(res => res.json())
  .then(res => res.result)
}

export function multicall (server, calls) {
  if (!isArray(calls)) calls = map(calls, (value, key) => ({ methodName: key, params: value || [] }))
  if (server.secret) {
    calls.forEach(function (call) {
      call.params.unshift(`token:${server.secret}`)
    })
  }
  var uri = `http${server.ssl ? 's' : ''}://${server.host}:${server.port}/jsonrpc`
  return fetch(uri, {
    method: 'post',
    body: JSON.stringify({
      'jsonrpc': '2.0',
      'id': 'Glutton',
      'method': 'system.multicall',
      'params': [calls]
    })
  })
  .then(checkStatus)
  .then(res => res.json())
  .then(res => res.result.map(value => value[0]))
}
{'fraction_non_alphanumeric': 0.20064608758076094, 'fraction_numerical': 0.007896625987078248, 'mean_word_length': 3.1411589895988112, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7278163', 'n_tokens_mistral': 980, 'n_tokens_neox': 972, 'n_words': 209}