text: 'use strict';
  
  var FS = '/api/v1/fs';
  
  var isFunc = function isFunc(a) {
    return typeof a === 'function';
  };
  
  module.exports.prefix = function (prefix) {
    FS = prefix;
  };
  
  module.exports.delete = function (url, data, callback) {
    if (!callback && isFunc(data)) {
      callback = data;
      data = null;
    }
  
    sendRequest({
      method: 'DELETE',
      url: FS + url,
      data: data,
      callback: callback
    });
  };
  
  module.exports.patch = function (url, data, callback) {
    if (!callback && isFunc(data)) {
      callback = data;
      data = null;
    }
  
    sendRequest({
      method: 'PATCH',
      url: FS + url,
      data: data,
      callback: callback
    });
  };
  
  module.exports.write = function (url, data, callback) {
    if (!callback && isFunc(data)) {
      callback = data;
      data = null;
    }
  
    sendRequest({
      method: 'PUT',
      url: FS + url,
      data: data,
      callback: callback
    });
  };
  
  module.exports.read = function (url, callback) {
    sendRequest({
      method: 'GET',
      url: FS + url,
      callback: callback
    });
  };
  
  function sendRequest(_ref) {
    var url = _ref.url,
        data = _ref.data,
        method = _ref.method,
        callback = _ref.callback;
    ajax({
      method: method,
      data: data,
      url: escape(url)
    }, callback);
  }
  /*
   * when we send ajax request -
   * no need in hash so we escape #
   */
  
  
  module.exports._escape = escape;
  
  function escape(str) {
    return encodeURI(str).replace(/#/g, '%23');
  }
  
  function ajax(params, callback) {
    var url = params.url,
        data = params.data,
        method = params.method;
    var request = new XMLHttpRequest();
    if (typeof callback !== 'function') throw Error('Callback should be function!');
  
    var load = function load() {
      if (request.status >= 200 && request.status < 400) return callback(null, request.responseText);
      callback(Error(request.responseText));
    };
  
    request.open(method, url, true);
    request.addEventListener('error', callback);
    request.addEventListener('load', load);
    request.send(data);
  }