<commit_before>const mod = angular.module('pa.animations.router', []),
    directiveName = 'paRouter';

mod.directive(directiveName, ($parse) => {
    return {
        restrict: 'A',
        require: [directiveName, '^^?paRouter'],
        controller ($q, $scope, $attrs) {
            const statusScopeVar = $attrs.paStatus;

            let animations = [],
                customAnimationQueue,
                animationsMap = {},
                deferred = $q.defer(),
                status = '',
                register = (name, controller, order = 0) => {
                    animations.push({
                        name,
                        controller,
                        order,
                        pushOrder: animations.length
                    });
                    animationsMap[name] = controller;
                },
                setStatus = newStatus => {
                    let statusM;
                    if (statusScopeVar) {
                        statusM = $parse(statusScopeVar);
                        statusM.assign($scope, newStatus);
                    }
                    status = newStatus;
                },
                clear = () => {
                    if (status === 'RUNNING') {
                        deferred.resolve();
                    }

                    setStatus('CLEARING');

                    return $q.all(
                        animations.map(animation => animation.controller.clear())
                    ).then(() => {
                        setStatus('READY');
                    });
                },
                setUp = () => {
                    setStatus('READY');
                },
                runAnimation = () => {
                    let animationPromise,
                        ordered = animations.slice()
                            .sort((a, b) => {
                                let delta = a.order - b.order;
                                return delta ? delta : a.pushOrder - b.pushOrder;
                            }),
                        initDeferred = $q.defer();


                    setStatus('RUNNING');
                    initDeferred.resolve();

                    if (!customAnimationQueue) {
                        //Used for init purposes only.
                        animationPromise = ordered.reduce(
                            (prev, curr) => prev.then(
                                //Prevent animation to run if cleared
                                () =>  status === 'RUNNING' ? curr.controller.play() : prev
                            ),
                            initDeferred.promise
                        ).then(setStatus.bind(undefined, 'FINISHED'));
                    } else {
                        animationPromise = customAnimationQueue(initDeferred)
                                                .then(setStatus.bind(undefined, 'FINISHED'));
                    }

                    return animationPromise;
                },
                setCustomAnimation = (animationQueue) => {
                    customAnimationQueue =  animationQueue;
                },
                play = () => {
                    if (status === 'READY') {
                        deferred = $q.defer();
                        runAnimation().then(deferred.resolve.bind(deferred));
                    }
                    return deferred.promise;
                },
                getAnimation = (animationName) => {
                    return animationsMap[animationName];
                };

            //APIs used by linking function
            this.setUp = setUp;
            this.runAnimation = runAnimation;

            //Public APIs
            this.play = play;
            this.clear = clear;
            this.register = register;
            this.getAnimation = getAnimation;
            this.setCustomAnimation = setCustomAnimation;

        },
        link (scope, element, attrs, controllers) {
            const selfController = controllers[0],
                routerController = controllers[1],
                animationName = attrs.paAnimationName || directiveName;

            if (routerController) {
                routerController.register(animationName, selfController);
            }

            selfController.setUp();

            if (attrs.paActive) {<commit_msg>Add getAllAnimations method to paRouter #35<commit_after>const mod = angular.module('pa.animations.router', []),
    directiveName = 'paRouter';

mod.directive(directiveName, ($parse) => {
    return {
        restrict: 'A',
        require: [directiveName, '^^?paRouter'],
        controller ($q, $scope, $attrs) {
            const statusScopeVar = $attrs.paStatus;

            let animations = [],
                customAnimationQueue,
                animationsMap = {},
                deferred = $q.defer(),
                status = '',
                register = (name, controller, order = 0) => {
                    animations.push({
                        name,
                        controller,
                        order,
                        pushOrder: animations.length
                    });
                    animationsMap[name] = controller;
                },
                setStatus = newStatus => {
                    let statusM;
                    if (statusScopeVar) {
                        statusM = $parse(statusScopeVar);
                        statusM.assign($scope, newStatus);
                    }
                    status = newStatus;
                },
                clear = () => {
                    if (status === 'RUNNING') {
                        deferred.resolve();
                    }

                    setStatus('CLEARING');

                    return $q.all(
                        animations.map(animation => animation.controller.clear())
                    ).then(() => {
                        setStatus('READY');
                    });
                },
                setUp = () => {
                    setStatus('READY');
                },
                runAnimation = () => {
                    let animationPromise,
                        ordered = animations.slice()
                            .sort((a, b) => {
                                let delta = a.order - b.order;
                                return delta ? delta : a.pushOrder - b.pushOrder;
                            }),
                        initDeferred = $q.defer();


                    setStatus('RUNNING');
                    initDeferred.resolve();

                    if (!customAnimationQueue) {
                        //Used for init purposes only.
                        animationPromise = ordered.reduce(
                            (prev, curr) => prev.then(
                                //Prevent animation to run if cleared
                                () =>  status === 'RUNNING' ? curr.controller.play() : prev
                            ),
                            initDeferred.promise
                        ).then(setStatus.bind(undefined, 'FINISHED'));
                    } else {
                        animationPromise = customAnimationQueue(initDeferred)
                                                .then(setStatus.bind(undefined, 'FINISHED'));
                    }

                    return animationPromise;
                },
                setCustomAnimation = (animationQueue) => {
                    customAnimationQueue =  animationQueue;
                },
                play = () => {
                    if (status === 'READY') {
                        deferred = $q.defer();
                        runAnimation().then(deferred.resolve.bind(deferred));
                    }
                    return deferred.promise;
                },
                getAnimation = (animationName) => {
                    return animationsMap[animationName];
                },
                getAllAnimations = () => {
                    return animationsMap;
                };

            //APIs used by linking function
            this.setUp = setUp;
            this.runAnimation = runAnimation;

            //Public APIs
            this.play = play;
            this.clear = clear;
            this.register = register;
            this.getAnimation = getAnimation;
            this.getAllAnimations = getAllAnimations;
            this.setCustomAnimation = setCustomAnimation;

        },
        link (scope, element, attrs, controllers) {
            const selfController = controllers[0],
                routerController = controllers[1],
                animationName = attrs.paAnimationName || directiveName;

            if (routerController) {
                routerController.register(animationName, selfController);
            }

            selfController.setUp();

            if (attrs.paActive) {
{'fraction_non_alphanumeric': 0.09696629213483146, 'fraction_numerical': 0.0008988764044943821, 'mean_word_length': 0.9762433392539964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6597559', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1813, 'n_words': 362}