<commit_before>var deps = ['jquery', 'i-bem__dom', 'BEMHTML'];

modules.isDefined('BEMTREE') &&
    deps.push('BEMTREE');

modules.define('angular-bem', deps,
    function(provide, $, BEMDOM, BEMHTML, BEMTREE) {

        angular.module('angular-bem', [])
            .value('bemdom', BEMDOM)
            .value('bemhtml', BEMHTML)
            .value('bemtree', BEMTREE)
            .factory('ngbem', ngBemFactory)
            .directive('ngBem', ngBemDirective)
            .directive('bem', iBemDirective);

        function ngBemFactory(bemhtml, bemtree, $q, $log) {
            var service = {
                render : render,
                processBemtree : processBemtree,
                processBemhtml : processBemhtml
            };

            return service;

            function processBemtree(bemjson) {
                return bemtree.apply(bemjson);
            }

            function processBemhtml(bemjson) {
                return bemhtml.apply(bemjson);
            }

            function render(bemjson, useBemtree) {
                var deferred = $q.defer(),
                    promise;

                if(useBemtree) {
                    angular.isUndefined(bemtree)?
                        $log.error('BEMTREE is not defined') && deferred.reject() :
                        processBemtree(bemjson).then(function(result){
                            deferred.resolve(result);
                        });
                } else {
                    deferred.resolve(bemjson);
                }

                promise = deferred.promise
                    .then(function(result){
                        return processBemhtml(result);
                    });

                return promise;
            }
        }

        function ngBemDirective(ngbem, bemdom, $compile) {
            return {
                restrict : 'E',
                link : function(scope, element, attrs) {
                    var bemjsonExpression = attrs.bemjson || element.text(),
                        useBemtree = !angular.isUndefined(attrs.bemtree);

                    scope.$watch('[' + attrs.observe + ']', function(){
                        // copy prevents unnecessary call of watch function
                        var bemjson = angular.copy(scope.$eval(bemjsonExpression));

                        ngbem.render(bemjson, useBemtree).then(function(html){
                            bemdom.update(element, html);
                            $compile(element.children())(scope);
                        });

                    }, true);

                    scope.$on('$destroy', function(){
                        bemdom.destruct(element.children());
                    });

                }
            };
        }

        function bemController($scope, $attrs, $element) {
            this.bem = $scope.$eval($attrs.bem);

            angular.forEach(this.bem, function(v, blockName) {
                var block;

                Object.defineProperty(this.bem, blockName, { get : function(){
                    return (block = block || $($element).bem(blockName));
                } });<commit_msg>refactor: don't expose `processBemhtml` and `processBemtree` in service<commit_after>var deps = ['jquery', 'i-bem__dom', 'BEMHTML'];

modules.isDefined('BEMTREE') &&
    deps.push('BEMTREE');

modules.define('angular-bem', deps,
    function(provide, $, BEMDOM, BEMHTML, BEMTREE) {

        angular.module('angular-bem', [])
            .value('bemdom', BEMDOM)
            .value('bemhtml', BEMHTML)
            .value('bemtree', BEMTREE)
            .factory('ngbem', ngBemFactory)
            .directive('ngBem', ngBemDirective)
            .directive('bem', iBemDirective);

        function ngBemFactory(bemhtml, bemtree, $q, $log) {

            return render;

            function processBemtree(bemjson) {
                return bemtree.apply(bemjson);
            }

            function processBemhtml(bemjson) {
                return bemhtml.apply(bemjson);
            }

            function render(bemjson, useBemtree) {
                var deferred = $q.defer(),
                    promise;

                if(useBemtree) {
                    angular.isUndefined(bemtree)?
                        $log.error('BEMTREE is not defined') && deferred.reject() :
                        processBemtree(bemjson).then(function(result){
                            deferred.resolve(result);
                        });
                } else {
                    deferred.resolve(bemjson);
                }

                promise = deferred.promise
                    .then(function(result){
                        return processBemhtml(result);
                    });

                return promise;
            }
        }

        function ngBemDirective(ngbem, bemdom, $compile) {
            return {
                restrict : 'E',
                link : function(scope, element, attrs) {
                    var bemjsonExpression = attrs.bemjson || element.text(),
                        useBemtree = !angular.isUndefined(attrs.bemtree);

                    scope.$watch('[' + attrs.observe + ']', function(){
                        // copy prevents unnecessary call of watch function
                        var bemjson = angular.copy(scope.$eval(bemjsonExpression));

                        ngbem(bemjson, useBemtree).then(function(html){
                            bemdom.update(element, html);
                            $compile(element.children())(scope);
                        });

                    }, true);

                    scope.$on('$destroy', function(){
                        bemdom.destruct(element.children());
                    });

                }
            };
        }

        function bemController($scope, $attrs, $element) {
            this.bem = $scope.$eval($attrs.bem);

            angular.forEach(this.bem, function(v, blockName) {
                var block;

                Object.defineProperty(this.bem, blockName, { get : function(){
                    return (block = block || $($element).bem(blockName));
                } });
{'fraction_non_alphanumeric': 0.11582885960631202, 'fraction_numerical': 0.0, 'mean_word_length': 1.3332068311195446, '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': '2678782', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1572, 'n_words': 263}