<commit_before>const EventEmitter = require('events')
const https = require('https')
const querystring = require('querystring')
const WebSocket = require('ws')

const constants = require('./constants')
const totp = require('./totp')

// eslint-disable-next-line import/newline-after-import
const VERSION = require('../package.json').version
const BASE_URL = 'www.avanza.se'
const USER_AGENT = process.env.AVANZA_USER_AGENT || `Avanza API client/${VERSION}`
const MIN_INACTIVE_MINUTES = 30
const MAX_INACTIVE_MINUTES = 60 * 24
const SOCKET_URL = 'wss://www.avanza.se/_push/cometd'
const MAX_BACKOFF_MS = 2 * 60 * 1000

/**
 * Simple debug utility function
 *
 * @private
 * @param {String} message The message to log
 */
function debug(...message) {
  if (process.env.NODE_ENV === 'development') {
    // eslint-disable-next-line no-console
    console.error(...message)
  }
}

/**
* Execute a request.
*
* @private
* @param {Object} options Request options.
* @return {Promise}
*/
function request(options) {
  if (!options) {
    return Promise.reject('Missing options.')
  }
  const data = JSON.stringify(options.data)
  return new Promise((resolve, reject) => {
    const req = https.request({
      host: BASE_URL,
      port: 443,
      method: options.method,
      path: options.path,
      headers: Object.assign({
        'Accept': '*/*',
        'Content-Type': 'application/json',
        'User-Agent': USER_AGENT,
        'Content-Length': data.length
      }, options.headers)
    }, (response) => {
      const body = []
      response.on('data', chunk => body.push(chunk))
      response.on('end', () => {
        let parsedBody = body.join('')

        try {
          parsedBody = JSON.parse(parsedBody)
        } catch (e) {
          debug('Received non-JSON data from API.', body)
        }

        const res = {
          statusCode: response.statusCode,
          statusMessage: response.statusMessage,<commit_msg>Resolves issue with nordic letters<commit_after>const EventEmitter = require('events')
const https = require('https')
const querystring = require('querystring')
const WebSocket = require('ws')

const constants = require('./constants')
const totp = require('./totp')

// eslint-disable-next-line import/newline-after-import
const VERSION = require('../package.json').version
const BASE_URL = 'www.avanza.se'
const USER_AGENT = process.env.AVANZA_USER_AGENT || `Avanza API client/${VERSION}`
const MIN_INACTIVE_MINUTES = 30
const MAX_INACTIVE_MINUTES = 60 * 24
const SOCKET_URL = 'wss://www.avanza.se/_push/cometd'
const MAX_BACKOFF_MS = 2 * 60 * 1000

/**
 * Simple debug utility function
 *
 * @private
 * @param {String} message The message to log
 */
function debug(...message) {
  if (process.env.NODE_ENV === 'development') {
    // eslint-disable-next-line no-console
    console.error(...message)
  }
}

/**
* Execute a request.
*
* @private
* @param {Object} options Request options.
* @return {Promise}
*/
function request(options) {
  if (!options) {
    return Promise.reject('Missing options.')
  }
  const data = JSON.stringify(options.data)
  return new Promise((resolve, reject) => {
    const req = https.request({
      host: BASE_URL,
      port: 443,
      method: options.method,
      path: options.path,
      headers: Object.assign({
        'Accept': '*/*',
        'Content-Type': 'application/json',
        'User-Agent': USER_AGENT,
        'Content-Length': Buffer.byteLength(data)
      }, options.headers)
    }, (response) => {
      const body = []
      response.on('data', chunk => body.push(chunk))
      response.on('end', () => {
        let parsedBody = body.join('')

        try {
          parsedBody = JSON.parse(parsedBody)
        } catch (e) {
          debug('Received non-JSON data from API.', body)
        }

        const res = {
          statusCode: response.statusCode,
          statusMessage: response.statusMessage,
{'fraction_non_alphanumeric': 0.14691579216790376, 'fraction_numerical': 0.008190427437931917, 'mean_word_length': 3.0164439876670093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3567599', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1211, 'n_words': 283}