--- title: "Freie Komponenten Utils" slug: "core-free-component-template-utils" updated: 2025-10-28T16:17:45Z published: 2025-12-13T18:17:06Z canonical: "docs.lobstersoftware.com/core-free-component-template-utils" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Freie Komponenten Utils Im Controller Code der Freien Komponente steht direkt ein globales Symbol "FCUtils" zur Verfügung, welches Helfer-Utilities zum Vereinfachen immerwiederkehrender Probleme dient. Nachfolgend eine Schnittstellenbeschreibung der FCUtils (Der Typ "CollectionLike" steht dabei stellvertretend für ein IList Objekt oder ein natives Array: Schnittstellenberschreibung FCUtils ```plaintext /** * Checks if the given value is an IList or an Array * * @param value The value to check * @returns true if value is CollectionLike */ isCollection(value: any): boolean; /** * Checks if the given value is an empty collection. * If value is not a collection at all, it will be considered as empty collection * * @param value Any value to be checked * @return true if the given value is an empty collection or if value is null or undefined, false otherwise */ isEmpty(value: any): boolean; /** * Returns the number of items in the given collection. * If list is not a collection 0 will be returned. * * @param list A collection */ size(list: CollectionLike): number; /** * Concatenates all given 'joins' elements and adds * the result to the given 'target' array or IList. * If a given element is an array or IList, all elements * will appended to the result * * ### Example * ``` * var target = []; * FCUtils.join(target, [1, 2, 3], 'hello', ['world', 'foo']); * * target.length; // = 6 = [1, 2, 3].length + 1 + ['world', 'foo'].length * * console.log(target); * * //prints: [1, 2, 3, 'hello', 'world', 'foo'] * ``` * ``` * * ``` * @param target The target array or IList which will add the joined 'joins' * @param joins The elements which will be joined (var args) * @returns A reference to the given target */ join, E>(target: V, ...joins: Array | E>): V; /** * Returns the index of the given item within the given IList or array. * How the items are compared for equality is defined by the 'useEquals' parameter (see useEquals paramter) * * ### Example: * ``` * var list = ['hello', new Long(5), 5, 7, 5]; * * FCUtils.getItemIndex(list, 'hello'); //returns 0 (first item of the list) * FCUtils.getItemIndex(list, 5, 3); //returns 4 (fifth item of the list because the search started at index 3) * FCUtils.getItemIndex(list, 5, 0); //returns 2 (third item of the list because new Long(5) !== 5) * FCUtils.getItemIndex(list, 5, 0, true); //returns 1 (second item of the list because (new Long(5)).equals(5) ) * ``` * ``` * * ``` * @param list An IList or array * @param item The item which will be searched in the list * @param start The start index to begin the search (defaults to 0) * * @returns The index of the first occurence of the given item or -1 if it was not found */ getItemIndex(list: CollectionLike, item: any, start?: number): number; /** * Removes an item from the given list by checking if it's index is greater than or equal to 0. * True will be returned if the item was contained in the list and was therefore removed * * @param list The list from which the item will be removed * @param item The item which will be removed if it is contained in the list in the first place * * @returns true if the item was contained and therefore removed from the list */ removeItem(list: CollectionLike, item: T): boolean; /** * Removes the item at the given index and returns the removed item * or undefined if the index was out of range or if the list was null * or undefined * * @param list The list from which the item will be removed * @param index The index of the item which will be removed * @returns the item which has been removed or undefined if the index * was out of range or if the given list was null or undefined */ removeItemAt(list: CollectionLike, index: number): T; /** * Retreives the item at the given index and returns the item * or undefined if the index was out of range or if the list was null * or undefined * * @param list The list from which the item will be retreived * @param index The index of the item which will be retreived * @returns The item which has been retreived or undefined if the index * was out of range or if the given list was null or undefined */ getItemAt(list: CollectionLike, index: number): T; /** * Adds an item to the given list and returns the * new length of the list or 0 if the item was not added * * @param list The list which will add the item * @param item The item which will be added * @returns The new length of the list or 0 if the item was not added */ addItem(list: CollectionLike, item: T): number; /** * Inserts an item into the list at the given index * * @param list An IList or array which will insert the item * @param item The item which will be inserted * @param index The insert position * @returns The new length of the list or 0 if the item was not added */ addItemAt(list: CollectionLike, item: T, index: number): number; /** * Replaces the item at the given index with the * given one and returns the replaced item * * @param item The item which will be set * @param index The index of the replaced item * @returns The replaced item or undefined if the index was out of range * or if the list was null or undefined, or if the replaced item was undefined */ setItemAt(list: CollectionLike, item: T, index: number): T; /** * Sorts the given collection considering an optional sort function (see parameter sortFunction). * If no sort function is given the comparison is made by itemA < itemB * * @param list The collection like object to be sorted * @param inverse Inverts the sorting order if true (defaults to false) * @param sortFunction An optional function to compare two items with each other (returns -1 if a < b, 0 if a === b or 1 if a > b) */ sort(list: CollectionLike, inverse?: boolean, sortFunction?: ((itemA: T, itemB: T) => number)): void; /** * Clears the given collection. i.e. Removes all items * * @param list The collection like object to be cleared */ clear(list: CollectionLike): void; /** * Tries to convert the given collection into an array. * The copy parameter determines whether a copy of the original data source should be returned (defaults to true). * If the given list is not a CollectionLike object, toArray looks for a toArray() member function and applies it if given. * * @param list A collection like element * @param copy Determines whether a copy of the original data source should be returned (defaults to true) * @returns The given object converted to an array */ toArray(list: CollectionLike, copy?: boolean): T[]; /** * Ensures that the given list is converted into an IList collection. * If it is an IList already, the input parameter will be simply returned. * If the conversion is not possible, the result will be null. */ toList(list: CollectionLike): IList; /** * Iterates through all items in the given collection and calls the callback function for each of them. * The callback function may return a truthy value which causes the iteration to stop immediately * * @param col A collection * @param cb A function which gets called for each item in the given collection. If it returns a truthy value, the iteration will stop immediately * @param thisArg Defines the this scope of the callback function cb */ forEach(col: CollectionLike, cb: (item: T) => any, thisArg?: Object): void; /** * Version 4.7.5 * * Returns the value of a style palette property * * Example: * var color = FCUtils.getStyleVar("primaryColor"); * * @param varName The name of the property * @param defaultValue (optional) A value which will be returned if no property has been found or if the value of the property was empty for any reason */ getStyleVar( varName: string, defaultValue?: string ): string; ```