M module

module:Support

Support is a collection of utility classes and standard library extensions that were found useful for the Viking framework. These additions reside in this package so they can be loaded as needed in Javascript projects outside of Viking.

Modules

M   Array
M   Class
M   Date

Functions

Helper function to compare arrays for equality

Parameters

a : Array

First array to compare

b : Array

Second array to compare

Returns

boolean

True if arrays are equivalent, false otherwise

Creates a deep clone of a value Handles null, undefined, arrays, plain objects, and primitive values

Parameters

value : *

The value to clone

Returns

*

A deep clone of the value

Executes the callback when the DOM is fully loaded If DOM is already loaded, executes the callback immediately

Parameters

callback : function

Function to execute when DOM is ready

Iterates over elements of a collection (array, object, DataTransferItemList) and executes the callback for each element

Parameters

value : Array | Object | DataTransferItemList

The collection to iterate over

callback : function

Function to execute for each element For arrays: (item, index) => {} For objects: (key, value) => {} For DataTransferItemList: (item, index) => {}

Performs a deep comparison between two values to determine if they are equivalent

Parameters

a : *

First value to compare

b : *

Second value to compare

Returns

boolean

True if the values are equivalent, false otherwise

Checks if a value is a function

Parameters

object : *

The value to check

Returns

boolean

True if value is a function, false otherwise

Retrieves the value of a property from an object. If the value is a function, it is invoked with the given arguments and its return value becomes the result. If an array is passed, it returns the result from the first object in the array that has the specified property.

Parameters

obj : Object | Array

The object or array of objects to retrieve the property from

key : string optional

The name of the property to retrieve

args : *

Arguments to pass to the function if the property is a function

Returns

*

The property value, or the result of calling the function

Converts a value to a string parameter representation Delegates to the appropriate type-specific converter

Parameters

value : *

The value to convert to parameter form

Returns

string

The string parameter representation of the value

Converts a value to a query string parameter Delegates to the appropriate type-specific converter based on value's type

Parameters

value : *

The value to convert to a query parameter

key : string

The key for the query parameter

Returns

string | undefined

The formatted query string parameter or undefined if value is null/undefined

Generates a unique ID prefixed with the provided string

Parameters

prefix : string

The prefix to use for the ID

Returns

string

A unique ID with the specified prefix