Home > @gglib/utils

utils package


Class Description
BinaryReader A wrapper around the ArrayBuffer and DataView. Simplifies reading binary data.
DataUri Describes parts of a data Uri
Events Base class with an event system
TextReader A wrapper around a string. Simplifies reading arbitrary formatted text data.
TypeToken A token identifying a type
WebWorker Provides a mechanism for registering functions as background tasks which can be executed on a worker thread


Function Description
addToArraySet(set, item) Adds an item to given array but only if it is not already included
append(list, item) Pushes an item into the given array. If array is null, a new instance is created
copy(src, dest)
copy(src, dest)
copy(srcOrDeep, srcOrDest, dest)
copy(srcOrDeep, srcOrDest, dest)
extend(dst, a, b, c, d, e, f) Extends the first argument with properties of all latter arguments
getImageData(image, width, height) Extracts image data from an HTMLImageElement
getLines(value) Splits a string into lines
getOption(options, key, fallback) Gets a value by key from an options object
getOrCreateCanvas(canvas) Gets a canvas element by a CSS selector or creates a new instance of HTMLCanvasElement
hasOwnProperty(object, property)
httpRequest(options) Creates and send an XMLHttpRequest
isObject(value) Checks whether a value is of type 'object' and is not an array or null
isString(value) Checks whether a value is a string
loop(update) Spins the given update function in a loop by utilizing requestAnimationFrame
pick(src, rest) Picks properties from the given source object if they are not undefined
removeFromArray(list, item) Removes an item from given array
trim(value) Removes leading and trailing spaces of a string
uuid() Generates a random uuid string
vendorEvent(el, name, variants)
vendorProperty(el, name, variants)


Interface Description
AbstractType An abstract class type
HttpOptions Options for httpRequest()
Loop A loop function that can be started and killed
Type A type that has a constructor
TypeWithEmptyConstructor A type that has a constructor without arguments


Variable Description
cancelAnimationFrame_2 Browsersafe cancelAnimationFrame function
getTime Gets the current timestamp. Uses performance.now() if available.
isArray Checks whether an object is an array
requestAnimationFrame_2 Browsersafe requestAnimationFrame function

Type Aliases

Type Alias Description
WebWorkerAsyncFunction A function that has been registered at WebWorker class
WebWorkerFunction A function that can be registered at the WebWorker class