<commit_before>/*
 * moysklad
 * Клиент для JSON API МойСклад
 *
 * Copyright (c) 2017, <NAME>
 * Licensed under MIT.
 */

'use strict'

const stampit = require('stampit')
const have = require('./have')

// methods
const getTimeString = require('./tools/getTimeString')
const getAuthHeader = require('./methods/getAuthHeader')
const buildUri = require('./methods/buildUri')
const parseUri = require('./methods/parseUri')
const fetchUri = require('./methods/fetchUri')
const GET = require('./methods/GET')
const POST = require('./methods/POST')
const PUT = require('./methods/PUT')
const DELETE = require('./methods/DELETE')

module.exports = stampit({
  // TODO bind methods to this
  methods: {
    getAuthHeader,
    buildUri,
    parseUri,
    fetchUri,
    GET,
    POST,
    PUT,
    DELETE
  },
  statics: {
    getTimeString
  }
})
  .init(function (options) {
    let _options

    have(options, {
      endpoint: 'opt str',
      api: 'opt str',
      apiVersion: 'opt str'

      // TODO fix have object arguments parsing
      // login: 'opt str',
      // password: '<PASSWORD>',
      // fetch: 'opt function'
      // queue: 'opt bool',
      // emitter: 'opt obj'
    })

    if (options.fetch) {
      this.fetch = options.fetch
    } else if (typeof fetch !== 'undefined') {
      this.fetch = fetch
    } else {
      throw new Error('fetch not specified')
    }

    if (options.emitter) {
      this.emitter = options.emitter
    }

    _options = Object.assign({
      endpoint: 'https://online.moysklad.ru/api',
      api: 'remap',
      apiVersion: '1.1'
    }, options)

    this.getOptions = function () {
      return _options
    }
  })
<commit_msg>✏️ более понятное описание ошибки Fetch API<commit_after>/*
 * moysklad
 * Клиент для JSON API МойСклад
 *
 * Copyright (c) 2017, <NAME>
 * Licensed under MIT.
 */

'use strict'

const stampit = require('stampit')
const have = require('./have')

// methods
const getTimeString = require('./tools/getTimeString')
const getAuthHeader = require('./methods/getAuthHeader')
const buildUri = require('./methods/buildUri')
const parseUri = require('./methods/parseUri')
const fetchUri = require('./methods/fetchUri')
const GET = require('./methods/GET')
const POST = require('./methods/POST')
const PUT = require('./methods/PUT')
const DELETE = require('./methods/DELETE')

module.exports = stampit({
  // TODO bind methods to this
  methods: {
    getAuthHeader,
    buildUri,
    parseUri,
    fetchUri,
    GET,
    POST,
    PUT,
    DELETE
  },
  statics: {
    getTimeString
  }
})
  .init(function (options) {
    let _options

    have(options, {
      endpoint: 'opt str',
      api: 'opt str',
      apiVersion: 'opt str'

      // TODO fix have object arguments parsing
      // login: 'opt str',
      // password: '<PASSWORD>',
      // fetch: 'opt function'
      // queue: 'opt bool',
      // emitter: 'opt obj'
    })

    if (options.fetch) {
      this.fetch = options.fetch
    } else if (typeof fetch !== 'undefined') {
      this.fetch = fetch
    } else {
      throw new Error('Не указан Fetch API модуль.' +
       'Подробнее см. https://github.com/wmakeev/moysklad#Установка')
    }

    if (options.emitter) {
      this.emitter = options.emitter
    }

    _options = Object.assign({
      endpoint: 'https://online.moysklad.ru/api',
      api: 'remap',
      apiVersion: '1.1'
    }, options)

    this.getOptions = function () {
      return _options
    }
  })

{'fraction_non_alphanumeric': 0.14677838774920543, 'fraction_numerical': 0.0034672060098237503, 'mean_word_length': 2.5507692307692307, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 3, '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': '5164058', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1101, 'n_words': 283}