<commit_before><commit_msg>adding Angular.js client<commit_after>'use strict';

/* 
Angular.js service wrapping the elastic.js API. This module can simply
be injected into your angular controllers. 
*/
angular.module('elasticjs.service', [])
    .factory('ejsResource', function($http) {

        function ejsResourceFactory(url) {
        
            var ejs = window.ejs || {};
            url = url || '';
        
            /* results are returned as a promise */
            var promiseThen = function (httpPromise, successcb, errorcb) {
                return httpPromise.then(function (response) {
                    (successcb || angular.noop)(response.data);
                    return response.data;
                }, function(response) {
                    (errorcb || angular.noop)(undefined);
                    return undefined;
                });
            };
        
            /* implement the elastic.js client interface for angular */
            ejs.client = {
                server: function(s) {
                    if (s === null) {
                        return url;
                    } else {
                        url = s;
                    }
                    return this;
                },
                post: function (path, data, successcb, errorcb) {
                    path = url + path;
                    return promiseThen($http.post(path, data), successcb, errorcb);
                },
                get: function(path, data, successcb, errorcb) {
                    path = url + path;
                    return promiseThen($http.get(path, data), successcb, errorcb);
                },
                put: function(path, data, successcb, errorcb) {
                    path = url + path;
                    return promiseThen($http.put(path, data), successcb, errorcb);
                },
                del: function(path, data, successcb, errorcb) {
                    path = url + path;
                    return promiseThen($http.delee(path, data), successcb, errorcb);
                },
                head: function(path, data, successcb, errorcb) {
                    path = url + path;
                    return $http.head(path, data)
                        .then(function(response) {
                            (successcb || angular.noop)(response.headers());
                            return response.headers();
                        }, function(response) {
                            (errorcb || angular.noop)(undefined);
                            return undefined;
                        });
                }
            };
            return ejs;
        }
        return ejsResourceFactory;
    });

{'fraction_non_alphanumeric': 0.10107367641614216, 'fraction_numerical': 0.0, 'mean_word_length': 1.1598721023181455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7573385', 'n_tokens_mistral': 646, 'n_tokens_neox': 595, 'n_words': 152}