<commit_before>
module Fayde.Media.Animation {
    export interface IAnimationStorage {
        ID: number;
        Animation: AnimationBase;
        PropStorage: Providers.IPropertyStorage;
        IsDisabled: boolean;
        BaseValue: any;
        CurrentValue: any;
        StopValue: any;
    }

    export class AnimationStore {
        static Create(target: DependencyObject, propd: DependencyProperty): IAnimationStorage {
            var baseValue = target.GetValue(propd);
            if (baseValue === undefined) {
                var targetType = propd.GetTargetType();
                if (targetType === Number)
                    baseValue = 0;
                else if (targetType === String)
                    baseValue = "";
                else
                    baseValue = new (<any>targetType)();
            }
            return {
                ID: createId(),
                Animation: undefined,
                PropStorage: Providers.GetStorage(target, propd),
                IsDisabled: false,
                BaseValue: baseValue,
                CurrentValue: undefined,
                StopValue: undefined,
            };
        }
        static Attach(animStorage: IAnimationStorage) {
            var storage = animStorage.PropStorage;
            var list = storage.Animations;
            if (!list)
                storage.Animations = list = [];
            var prevStorage = list[list.length - 1];
            list.push(animStorage);
            if (prevStorage) {
                animStorage.StopValue = prevStorage.StopValue;
                prevStorage.IsDisabled = true;
            } else {
                animStorage.StopValue = storage.Local;
            }
        }
        static Detach(animStorage: IAnimationStorage): boolean {
            var storage = animStorage.PropStorage;

            var list = storage.Animations;
            if (!list)
                return false;

            var len = list.length;
            if (len < 1)
                return false;

            var i = list.lastIndexOf(animStorage);
            if (i === (len - 1)) {
                list.pop();
                if (len > 1) {
                    var last = list[len - 2];
                    if (last.IsDisabled) {
                        last.IsDisabled = false;
                        AnimationStore.ApplyCurrent(last);
                        return true;
                    }
                }
            } else {
                list.splice(i, 1);
                list[i].StopValue = animStorage.StopValue;
            }
            return false;<commit_msg>Exception when lastIndexOf animStorage not found (#270)<commit_after>
module Fayde.Media.Animation {
    export interface IAnimationStorage {
        ID: number;
        Animation: AnimationBase;
        PropStorage: Providers.IPropertyStorage;
        IsDisabled: boolean;
        BaseValue: any;
        CurrentValue: any;
        StopValue: any;
    }

    export class AnimationStore {
        static Create(target: DependencyObject, propd: DependencyProperty): IAnimationStorage {
            var baseValue = target.GetValue(propd);
            if (baseValue === undefined) {
                var targetType = propd.GetTargetType();
                if (targetType === Number)
                    baseValue = 0;
                else if (targetType === String)
                    baseValue = "";
                else
                    baseValue = new (<any>targetType)();
            }
            return {
                ID: createId(),
                Animation: undefined,
                PropStorage: Providers.GetStorage(target, propd),
                IsDisabled: false,
                BaseValue: baseValue,
                CurrentValue: undefined,
                StopValue: undefined,
            };
        }
        static Attach(animStorage: IAnimationStorage) {
            var storage = animStorage.PropStorage;
            var list = storage.Animations;
            if (!list)
                storage.Animations = list = [];
            var prevStorage = list[list.length - 1];
            list.push(animStorage);
            if (prevStorage) {
                animStorage.StopValue = prevStorage.StopValue;
                prevStorage.IsDisabled = true;
            } else {
                animStorage.StopValue = storage.Local;
            }
        }
        static Detach(animStorage: IAnimationStorage): boolean {
            var storage = animStorage.PropStorage;

            var list = storage.Animations;
            if (!list)
                return false;

            var len = list.length;
            if (len < 1)
                return false;

            var i = list.lastIndexOf(animStorage);
            if(i < 0)
                return false;
            
            if (i === (len - 1)) {
                list.pop();
                if (len > 1) {
                    var last = list[len - 2];
                    if (last.IsDisabled) {
                        last.IsDisabled = false;
                        AnimationStore.ApplyCurrent(last);
                        return true;
                    }
                }
            } else {
                list.splice(i, 1);
                list[i].StopValue = animStorage.StopValue;
            }
            return false;
{'fraction_non_alphanumeric': 0.08422434815231664, 'fraction_numerical': 0.0033764772087788407, 'mean_word_length': 1.2412778478352249, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '7134345', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1216, 'n_words': 301}