<commit_before>part of simple_mvp;

/**
* Utility class to read/update/delete models on the server.
*/
class Storage {
  final _urls;

  Storage(this._urls);

  Future<List> readAll() => _submit("GET", _urls["readAll"], body: {});

  Future<Map> read(id) => _submit("GET", _urls["read"], id: id);

  Future<Map> create(ModelAttributes attrs) => _submit("POST", _urls["create"], body: attrs.asJSON());

  Future<Map> update(id, ModelAttributes attrs) => _submit("PUT", _urls["update"], id: id, body: attrs.asJSON());

  Future<Map> destroy(id) => _submit("DELETE", _urls["destroy"], id: id);

  _submit(method, url, {id, body}){
    var c = new Completer();
    url = id != null ? "$url/$id" : url;
    var req = _createRequest(method, url, (res) => c.complete(res));
    req.send(json.JSON.stringify(body));
    return c.future;
  }

  _createRequest(method, url, callback){
    var req = new html.HttpRequest();

    req.on.load.add((e){
      String response = req.response;
      var parsedResponse = response.isEmpty() ? {} : json.JSON.parse(response);
      callback(parsedResponse);
    });<commit_msg>updated isEmpty function to property<commit_after>part of simple_mvp;

/**
* Utility class to read/update/delete models on the server.
*/
class Storage {
  final _urls;

  Storage(this._urls);

  Future<List> readAll() => _submit("GET", _urls["readAll"], body: {});

  Future<Map> read(id) => _submit("GET", _urls["read"], id: id);

  Future<Map> create(ModelAttributes attrs) => _submit("POST", _urls["create"], body: attrs.asJSON());

  Future<Map> update(id, ModelAttributes attrs) => _submit("PUT", _urls["update"], id: id, body: attrs.asJSON());

  Future<Map> destroy(id) => _submit("DELETE", _urls["destroy"], id: id);

  _submit(method, url, {id, body}){
    var c = new Completer();
    url = id != null ? "$url/$id" : url;
    var req = _createRequest(method, url, (res) => c.complete(res));
    req.send(json.JSON.stringify(body));
    return c.future;
  }

  _createRequest(method, url, callback){
    var req = new html.HttpRequest();

    req.on.load.add((e){
      String response = req.response;
      var parsedResponse = response.isEmpty ? {} : json.JSON.parse(response);
      callback(parsedResponse);
    });
{'fraction_non_alphanumeric': 0.18328118015198927, 'fraction_numerical': 0.0, 'mean_word_length': 4.168591224018476, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, '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': '1835212', 'n_tokens_mistral': 739, 'n_tokens_neox': 742, 'n_words': 180}