<commit_before>import * as Entities from "./AbstractItem";

    export class Functionals {

        static stringArrayToCdl(stringArr: string[]): string {

            return stringArr.reduce((prev: string, curr: string) => {

                if (prev.length > 0) {
                    return curr + ", " + prev;
                }

                return curr;

            }, "");

        }

        static idHighWaterMark(fromArray: Entities.AbstractItem[]) {
            return fromArray.reduce((prev: number, curr: Entities.AbstractItem) => { return curr.InternalID > prev ? curr.InternalID : prev }, 0);
        }

        static entityIsInCollection(collection: Entities.AbstractItem[], testID: string) {
            return collection.some((anItem) => { return anItem.UniqueID === testID; });
        }

        static getFirstEntityByInternalID<T extends Entities.IAbstractItem>(forID: number, entityCollection: T[]): T {
            return entityCollection.filter((anEntity) => {
                return anEntity.InternalID === forID;
            })[0];
        }

        static getEntityByUniqueID<T extends Entities.IAbstractItem>(forID: string, entityCollection: T[]): T {

            if (! entityCollection) { 
                throw ("Functionals: getEntityByUniqueID: Error: entityCollect is null or undefined.");
            }

            const foundEntities = entityCollection.filter((anEntity) => {
                return anEntity.UniqueID === forID;
            });

            if (foundEntities.length > 0) {
                return foundEntities[0];
            }

            throw {
                msg: `Functionals: getEntityByUniqueID: ERROR: Failed to retrieve an entity with ID [${forID}]`,
                fullCollection: entityCollection
            };

        }

        static filterOutEntityByUniqueID<T extends Entities.IAbstractItem>(forID: string, entityCollection: T[]): T[] {
            return entityCollection.filter((anEntity) => {
                return anEntity.UniqueID != forID;
            });
        }

        static IsNullOrUndefined<T>(value: T) {
            return value ? false : true;
        }

        static IsIDAssigned<T extends Entities.IAbstractItem>(ItemToTest: T): boolean {

            console.debug(`Functions.ts: IsIDAssigsned: Testing an item:`, { itm: ItemToTest });

            if (Functionals.IsNullOrUndefined(ItemToTest.UniqueID)) {
                console.debug(`Functions.ts: IsIDAssigsned: False.`);
                return false;
            }

            if (ItemToTest.UniqueID.length > 0) {
                console.debug(`Functionalss.ts: IsIDAssigsned: True.`);
                return true;
            }

            console.debug(`Functions.ts: IsIDAssigsned: False.`);
            return false;

        }

        static getMergedCollection<T extends Entities.IAbstractItem> (collection: T[], mergeItem: T): T[] {
<commit_msg>Applied proper naming convention.<commit_after>import * as Entities from "./AbstractItem";

    export class Functionals {

        static stringArrayToCdl(stringArr: string[]): string {

            return stringArr.reduce((prev: string, curr: string) => {

                if (prev.length > 0) {
                    return curr + ", " + prev;
                }

                return curr;

            }, "");

        }

        static idHighWaterMark(fromArray: Entities.AbstractItem[]) {
            return fromArray.reduce((prev: number, curr: Entities.AbstractItem) => { return curr.InternalID > prev ? curr.InternalID : prev }, 0);
        }

        static entityIsInCollection(collection: Entities.AbstractItem[], testID: string) {
            return collection.some((anItem) => { return anItem.UniqueID === testID; });
        }

        static getFirstEntityByInternalID<T extends Entities.IAbstractItem>(forID: number, entityCollection: T[]): T {
            return entityCollection.filter((anEntity) => {
                return anEntity.InternalID === forID;
            })[0];
        }

        static getEntityByUniqueID<T extends Entities.IAbstractItem>(forID: string, entityCollection: T[]): T {

            if (! entityCollection) { 
                throw ("Functionals: getEntityByUniqueID: Error: entityCollect is null or undefined.");
            }

            const foundEntities = entityCollection.filter((anEntity) => {
                return anEntity.UniqueID === forID;
            });

            if (foundEntities.length > 0) {
                return foundEntities[0];
            }

            throw {
                msg: `Functionals: getEntityByUniqueID: ERROR: Failed to retrieve an entity with ID [${forID}]`,
                fullCollection: entityCollection
            };

        }

        static filterOutEntityByUniqueID<T extends Entities.IAbstractItem>(forID: string, entityCollection: T[]): T[] {
            return entityCollection.filter((anEntity) => {
                return anEntity.UniqueID != forID;
            });
        }

        static IsNullOrUndefined<T>(value: T) {
            return value ? false : true;
        }

        static isIDAssigned<T extends Entities.IAbstractItem>(ItemToTest: T): boolean {

            console.debug(`Functions.ts: IsIDAssigsned: Testing an item:`, { itm: ItemToTest });

            if (Functionals.IsNullOrUndefined(ItemToTest.UniqueID)) {
                console.debug(`Functions.ts: IsIDAssigsned: False.`);
                return false;
            }

            if (ItemToTest.UniqueID.length > 0) {
                console.debug(`Functionalss.ts: IsIDAssigsned: True.`);
                return true;
            }

            console.debug(`Functions.ts: IsIDAssigsned: False.`);
            return false;

        }

        static getMergedCollection<T extends Entities.IAbstractItem> (collection: T[], mergeItem: T): T[] {

{'fraction_non_alphanumeric': 0.11025641025641025, 'fraction_numerical': 0.0020512820512820513, 'mean_word_length': 1.9867279224093926, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 35, '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': '4795167', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1497, 'n_words': 343}