Home > @gglib/utils

utils package

Classes

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
PointerLockApi
TextReader A wrapper around a string. Simplifies reading arbitrary formatted text data.
TypeToken A token identifying a type
Uri
WebWorker Provides a mechanism for registering functions as background tasks which can be executed on a worker thread

Functions

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
flattenArray(value)
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
isArrayBufferView(v)
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)

Interfaces

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

Variables

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

Type Aliases

Type Alias Description
Callback
FunctionProperties
FunctionPropertyNames
Immutable
NonFunctionProperties
NonFunctionPropertyNames
Primitive
WebWorkerAsyncFunction A function that has been registered at WebWorker class
WebWorkerFunction A function that can be registered at the WebWorker class