Options
All
  • Public
  • Public/Protected
  • All
Menu

vis-util

Index

Type aliases

Assignable<T>: T extends undefined ? (T extends Function ? T : T extends object ? { [ Key in keyof T]?: Assignable<T[Key]> } : T) | typeof DELETE : T extends Function ? T | undefined : T extends object ? { [ Key in keyof T]?: Assignable<T[Key]> } : T | undefined

Turns undefined into undefined | typeof DELETE and makes everything partial. Intended to be used with deepObjectAssign.

Type parameters

  • T

ConfiguratorConfig: { readonly [ Key in string]: ConfiguratorConfig | ConfiguratorInput }
ConfiguratorHideOption: (parentPath: readonly string[], optionName: string, options: any) => boolean

Type declaration

    • (parentPath: readonly string[], optionName: string, options: any): boolean
    • Parameters

      • parentPath: readonly string[]
      • optionName: string
      • options: any

      Returns boolean

Mashable: number | string | boolean | object | bigint

Values of these types can be used as a seed.

OptionsConfig: { __type__: { object: "object" } & OptionsType } & { readonly [ Key in string]: OptionsConfig | OptionsType }

Variables

Activator: any = ActivatorJS
ColorPicker: any = ColorPickerJS
Configurator: any = ConfiguratorJS
DELETE: typeof DELETE = ...

Use this symbol to delete properies in deepObjectAssign.

Hammer: HammerStatic = HammerJS
Popup: any = PopupJS
VALIDATOR_PRINT_STYLE: string = VALIDATOR_PRINT_STYLE_JS
Validator: any = ValidatorJS
easingFunctions: { easeInCubic: any; easeInOutCubic: any; easeInOutQuad: any; easeInOutQuart: any; easeInOutQuint: any; easeInQuad: any; easeInQuart: any; easeInQuint: any; easeOutCubic: any; easeOutQuad: any; easeOutQuart: any; easeOutQuint: any; linear: any } = ...

Type declaration

  • easeInCubic:function
    • easeInCubic(t: number): number
    • Accelerate from zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInOutCubic:function
    • easeInOutCubic(t: number): number
    • Accelerate until halfway, then decelerate.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInOutQuad:function
    • easeInOutQuad(t: number): number
    • Accelerate until halfway, then decelerate.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInOutQuart:function
    • easeInOutQuart(t: number): number
    • Accelerate until halfway, then decelerate.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInOutQuint:function
    • easeInOutQuint(t: number): number
    • Accelerate until halfway, then decelerate.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInQuad:function
    • easeInQuad(t: number): number
    • Accelerate from zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInQuart:function
    • easeInQuart(t: number): number
    • Accelerate from zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeInQuint:function
    • easeInQuint(t: number): number
    • Accelerate from zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeOutCubic:function
    • easeOutCubic(t: number): number
    • Decelerate to zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeOutQuad:function
    • easeOutQuad(t: number): number
    • Decelerate to zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeOutQuart:function
    • easeOutQuart(t: number): number
    • Decelerate to zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • easeOutQuint:function
    • easeOutQuint(t: number): number
    • Decelerate to zero velocity.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

  • linear:function
    • linear(t: number): number
    • Provides no easing and no acceleration.

      Parameters

      • t: number

        Time.

      Returns number

      Value at time t.

option: { asBoolean: any; asElement: any; asNumber: any; asSize: any; asString: any } = ...

Type declaration

  • asBoolean:function
    • asBoolean(value: unknown, defaultValue?: boolean): null | boolean
    • Convert a value into a boolean.

      Parameters

      • value: unknown

        Value to be converted intoboolean, a function will be executed as (() => unknown).

      • Optional defaultValue: boolean

        If the value or the return value of the function == null then this will be returned.

      Returns null | boolean

      Corresponding boolean value, if none then the default value, if none then null.

  • asElement:function
    • asElement<T>(value: undefined | T | (() => undefined | T), defaultValue: T): null | T
    • Convert a value into a DOM Element.

      Type parameters

      • T: Node

      Parameters

      • value: undefined | T | (() => undefined | T)

        Value to be converted into DOM Element, a function will be executed as (() => unknown).

      • defaultValue: T

        If the value or the return value of the function == null then this will be returned.

      Returns null | T

      The DOM Element, if none then the default value, if none then null.

  • asNumber:function
    • asNumber(value: unknown, defaultValue?: number): null | number
    • Convert a value into a number.

      Parameters

      • value: unknown

        Value to be converted intonumber, a function will be executed as (() => unknown).

      • Optional defaultValue: number

        If the value or the return value of the function == null then this will be returned.

      Returns null | number

      Corresponding boxed number value, if none then the default value, if none then null.

  • asSize:function
    • asSize(value: unknown, defaultValue?: string): null | string
    • Convert a value into a size.

      Parameters

      • value: unknown

        Value to be converted intosize, a function will be executed as (() => unknown).

      • Optional defaultValue: string

        If the value or the return value of the function == null then this will be returned.

      Returns null | string

      Corresponding string value (number + 'px'), if none then the default value, if none then null.

  • asString:function
    • asString(value: unknown, defaultValue?: string): null | string
    • Convert a value into a string.

      Parameters

      • value: unknown

        Value to be converted intostring, a function will be executed as (() => unknown).

      • Optional defaultValue: string

        If the value or the return value of the function == null then this will be returned.

      Returns null | string

      Corresponding boxed string value, if none then the default value, if none then null.

Functions

  • Create a seeded pseudo random generator based on Alea by Johannes Baagøe.

    Parameters

    • Rest ...seed: Mashable[]

      All supplied arguments will be used as a seed. In case nothing is supplied the current time will be used to seed the generator.

    Returns RNG

    A ready to use seeded generator.

  • HSVToHex(h: number, s: number, v: number): string
  • Convert HSV <0, 1> into hex color string.

    Parameters

    • h: number

      Hue.

    • s: number

      Saturation.

    • v: number

      Value.

    Returns string

    Hex color string.

  • HSVToRGB(h: number, s: number, v: number): RGB
  • RGBToHSV(red: number, green: number, blue: number): HSV
  • RGBToHex(red: number, green: number, blue: number): string
  • Convert RGB <0, 255> into hex color string.

    Parameters

    • red: number

      Red channel.

    • green: number

      Green channel.

    • blue: number

      Blue channel.

    Returns string

    Hex color string (for example: '#0acdc0').

  • addClassName(elem: Element, classNames: string): void
  • Add a className to the given elements style.

    Parameters

    • elem: Element

      The element to which the classes will be added.

    • classNames: string

      Space separated list of classes.

    Returns void

  • addCssText(element: HTMLElement, cssText: string): void
  • Append a string with css styles to an element.

    Parameters

    • element: HTMLElement

      The element that will receive new styles.

    • cssText: string

      The styles to be appended.

    Returns void

  • addEventListener<E>(element: E, action: Parameters<E["addEventListener"]>[0], listener: Parameters<E["addEventListener"]>[1], useCapture?: Parameters<E["addEventListener"]>[2]): void
  • Add and event listener. Works for all browsers.

    Type parameters

    • E: Element

    Parameters

    • element: E

      The element to bind the event listener to.

    • action: Parameters<E["addEventListener"]>[0]

      Same as Element.addEventListener(action, —, —).

    • listener: Parameters<E["addEventListener"]>[1]

      Same as Element.addEventListener(—, listener, —).

    • Optional useCapture: Parameters<E["addEventListener"]>[2]

      Same as Element.addEventListener(—, —, useCapture).

    Returns void

  • binarySearchCustom<O, K1, K2>(orderedItems: O[], comparator: (v: O[K1][K2]) => 0 | 1 | -1, field: K1, field2: K2): number
  • binarySearchCustom<O, K1>(orderedItems: O[], comparator: (v: O[K1]) => 0 | 1 | -1, field: K1): number
  • This function does a binary search for a visible item in a sorted list. If we find a visible item, the code that uses this function will then iterate in both directions over this sorted list to find all visible items.

    Type parameters

    • O: object

    • K1: string | number | symbol

    • K2: string | number | symbol

    Parameters

    • orderedItems: O[]

      Items ordered by start.

    • comparator: (v: O[K1][K2]) => 0 | 1 | -1

      -1 is lower, 0 is equal, 1 is higher.

        • (v: O[K1][K2]): 0 | 1 | -1
        • Parameters

          • v: O[K1][K2]

          Returns 0 | 1 | -1

    • field: K1

      Property name on an item (That is item[field]).

    • field2: K2

      Second property name on an item (That is item[field][field2]).

    Returns number

    Index of the found item or -1 if nothing was found.

  • This function does a binary search for a visible item in a sorted list. If we find a visible item, the code that uses this function will then iterate in both directions over this sorted list to find all visible items.

    Type parameters

    • O: object

    • K1: string | number | symbol

    Parameters

    • orderedItems: O[]

      Items ordered by start.

    • comparator: (v: O[K1]) => 0 | 1 | -1

      -1 is lower, 0 is equal, 1 is higher.

        • (v: O[K1]): 0 | 1 | -1
        • Parameters

          • v: O[K1]

          Returns 0 | 1 | -1

    • field: K1

      Property name on an item (That is item[field]).

    Returns number

    Index of the found item or -1 if nothing was found.

  • binarySearchValue<T>(orderedItems: { [ K in string]: number }[], target: number, field: T, sidePreference: "before" | "after", comparator?: (a: number, b: number) => 0 | 1 | -1): number
  • This function does a binary search for a specific value in a sorted array. If it does not exist but is in between of two values, we return either the one before or the one after, depending on user input If it is found, we return the index, else -1.

    Type parameters

    • T: string

    Parameters

    • orderedItems: { [ K in string]: number }[]

      Sorted array.

    • target: number

      The searched value.

    • field: T

      Name of the property in items to be searched.

    • sidePreference: "before" | "after"

      If the target is between two values, should the index of the before or the after be returned?

    • Optional comparator: (a: number, b: number) => 0 | 1 | -1

      An optional comparator, returning -1, 0, 1 for <, ===, >.

        • (a: number, b: number): 0 | 1 | -1
        • Parameters

          • a: number
          • b: number

          Returns 0 | 1 | -1

    Returns number

    The index of found value or -1 if nothing was found.

  • bridgeObject<T>(referenceObject: T): T
  • bridgeObject<T>(referenceObject: T): null
  • This recursively redirects the prototype of JSON objects to the referenceObject. This is used for default options.

    Type parameters

    • T: object

    Parameters

    • referenceObject: T

      The original object.

    Returns T

    The Element if the referenceObject is an Element, or a new object inheriting from the referenceObject.

  • This recursively redirects the prototype of JSON objects to the referenceObject. This is used for default options.

    Type parameters

    • T

    Parameters

    • referenceObject: T

      The original object.

    Returns null

    The Element if the referenceObject is an Element, or a new object inheriting from the referenceObject.

  • copyAndExtendArray<T>(arr: readonly T[], newValue: T): T[]
  • copyAndExtendArray<A, V>(arr: readonly A[], newValue: V): (A | V)[]
  • Used to extend an array and copy it. This is used to propagate paths recursively.

    Type parameters

    • T

    Parameters

    • arr: readonly T[]

      First part.

    • newValue: T

      The value to be aadded into the array.

    Returns T[]

    A new array with all items from arr and newValue (which is last).

  • Used to extend an array and copy it. This is used to propagate paths recursively.

    Type parameters

    • A

    • V

    Parameters

    • arr: readonly A[]

      First part.

    • newValue: V

      The value to be aadded into the array.

    Returns (A | V)[]

    A new array with all items from arr and newValue (which is last).

  • copyArray<T>(arr: readonly T[]): T[]
  • Used to extend an array and copy it. This is used to propagate paths recursively.

    Type parameters

    • T

    Parameters

    • arr: readonly T[]

      The array to be copied.

    Returns T[]

    Shallow copy of arr.

  • deepExtend(a: any, b: any, protoExtend?: boolean, allowDeletion?: boolean): any
  • Deep extend an object a with the properties of object b.

    Parameters

    • a: any

      Target object.

    • b: any

      Source object.

    • protoExtend: boolean = false

      If true, the prototype values will also be extended. (That is the options objects that inherit from others will also get the inherited options).

    • allowDeletion: boolean = false

      If true, the values of fields that are null will be deleted.

    Returns any

    Argument a.

  • deepObjectAssign<T>(target: T, ...sources: Assignable<T>[]): T
  • Deep version of object assign with additional deleting by the DELETE symbol.

    Type parameters

    • T

    Parameters

    • target: T

      The object that will be augmented using the sources.

    • Rest ...sources: Assignable<T>[]

      Objects to be deeply merged into the target.

    Returns T

    The target (same instance).

  • equalArray(a: unknown[], b: unknown[]): boolean
  • Test whether all elements in two arrays are equal.

    Parameters

    • a: unknown[]

      First array.

    • b: unknown[]

      Second array.

    Returns boolean

    True if both arrays have the same length and same elements (1 = '1').

  • extend<T, U>(target: T, source: U): T & U
  • extend<T, U, V>(target: T, source1: U, source2: V): T & U & V
  • extend<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W
  • extend(target: object, ...sources: any[]): any
  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Type parameters

    • T

    • U

    Parameters

    • target: T

      The target object to copy to.

    • source: U

      The source object from which to copy properties.

    Returns T & U

    The target object.

  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Type parameters

    • T

    • U

    • V

    Parameters

    • target: T

      The target object to copy to.

    • source1: U
    • source2: V

    Returns T & U & V

    The target object.

  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Type parameters

    • T

    • U

    • V

    • W

    Parameters

    • target: T

      The target object to copy to.

    • source1: U
    • source2: V
    • source3: W

    Returns T & U & V & W

    The target object.

  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Parameters

    • target: object

      The target object to copy to.

    • Rest ...sources: any[]

    Returns any

    The target object.

  • fillIfDefined<T>(a: T, b: Partial<T>, allowDeletion?: boolean): void
  • Fill an object with a possibly partially defined other object.

    Only copies values for the properties already present in a. That means an object is not created on a property if only the b object has it.

    Type parameters

    • T: object

    Parameters

    • a: T

      The object that will have it's properties updated.

    • b: Partial<T>

      The object with property updates.

    • allowDeletion: boolean = false

      If true, delete properties in a that are explicitly set to null in b.

    Returns void

  • forEach<V>(array: undefined | null | V[], callback: (value: V, index: number, object: V[]) => void): void
  • forEach<O>(object: undefined | null | O, callback: <Key>(value: O[Key], key: Key, object: O) => void): void
  • For each method for both arrays and objects. In case of an array, the built-in Array.forEach() is applied (No, it's not!). In case of an Object, the method loops over all properties of the object.

    Type parameters

    • V

    Parameters

    • array: undefined | null | V[]
    • callback: (value: V, index: number, object: V[]) => void

      Array.forEach-like callback.

        • (value: V, index: number, object: V[]): void
        • Parameters

          • value: V
          • index: number
          • object: V[]

          Returns void

    Returns void

  • For each method for both arrays and objects. In case of an array, the built-in Array.forEach() is applied (No, it's not!). In case of an Object, the method loops over all properties of the object.

    Type parameters

    • O: object

    Parameters

    • object: undefined | null | O

      An Object or Array to be iterated over.

    • callback: <Key>(value: O[Key], key: Key, object: O) => void

      Array.forEach-like callback.

        • <Key>(value: O[Key], key: Key, object: O): void
        • Type parameters

          • Key: string | number | symbol

          Parameters

          • value: O[Key]
          • key: Key
          • object: O

          Returns void

    Returns void

  • getAbsoluteLeft(elem: Element): number
  • Retrieve the absolute left value of a DOM element.

    Parameters

    • elem: Element

      A dom element, for example a div.

    Returns number

    The absolute left position of this element in the browser page.

  • getAbsoluteRight(elem: Element): number
  • Retrieve the absolute right value of a DOM element.

    Parameters

    • elem: Element

      A dom element, for example a div.

    Returns number

    The absolute right position of this element in the browser page.

  • getAbsoluteTop(elem: Element): number
  • Retrieve the absolute top value of a DOM element.

    Parameters

    • elem: Element

      A dom element, for example a div.

    Returns number

    The absolute top position of this element in the browser page.

  • getScrollBarWidth(): number
  • Experimentaly compute the width of the scrollbar for this browser.

    Returns number

    The width in pixels.

  • getTarget(event?: undefined | Event): Element | null
  • Get HTML element which is the target of the event.

    Parameters

    • event: undefined | Event = window.event

      The event.

    Returns Element | null

    The element or null if not obtainable.

  • getType(object: unknown): string
  • Get the type of an object, for example exports.getType([]) returns 'Array'.

    Parameters

    • object: unknown

      Input value of unknown type.

    Returns string

    Detected type.

  • hasParent(element: Element, parent: Element): boolean
  • Check if given element contains given parent somewhere in the DOM tree.

    Parameters

    • element: Element

      The element to be tested.

    • parent: Element

      The ancestor (not necessarily parent) of the element.

    Returns boolean

    True if parent is an ancestor of the element, false otherwise.

  • hexToHSV(hex: string): HSV
  • Convert hex color string into HSV <0, 1>.

    Parameters

    • hex: string

      Hex color string.

    Returns HSV

    HSV color object.

  • hexToRGB(hex: string): RGB | null
  • insertSort<T>(a: T[], compare: (a: T, b: T) => number): T[]
  • This method provides a stable sort implementation, very fast for presorted data.

    Type parameters

    • T

    Parameters

    • a: T[]

      The array to be sorted (in-place).

    • compare: (a: T, b: T) => number

      An order comparator.

        • (a: T, b: T): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns T[]

    The argument a.

  • isDate(value: unknown): value is string | Date
  • Test whether given object is a Date, or a String containing a Date.

    Parameters

    • value: unknown

      Input value of unknown type.

    Returns value is string | Date

    True if Date instance or string date representation, false otherwise.

  • isNumber(value: unknown): value is number
  • Test whether given object is a number.

    Parameters

    • value: unknown

      Input value of unknown type.

    Returns value is number

    True if number, false otherwise.

  • isObject(value: unknown): value is object
  • Test whether given object is a object (not primitive or null).

    Parameters

    • value: unknown

      Input value of unknown type.

    Returns value is object

    True if not null object, false otherwise.

  • isString(value: unknown): value is string
  • Test whether given object is a string.

    Parameters

    • value: unknown

      Input value of unknown type.

    Returns value is string

    True if string, false otherwise.

  • isValidHex(hex: string): boolean
  • Validate hex color string.

    Parameters

    • hex: string

      Unknown string that may contain a color.

    Returns boolean

    True if the string is valid, false otherwise.

  • isValidRGB(rgb: string): boolean
  • Validate RGB color string.

    Parameters

    • rgb: string

      Unknown string that may contain a color.

    Returns boolean

    True if the string is valid, false otherwise.

  • isValidRGBA(rgba: string): boolean
  • Validate RGBA color string.

    Parameters

    • rgba: string

      Unknown string that may contain a color.

    Returns boolean

    True if the string is valid, false otherwise.

  • mergeOptions(mergeTarget: any, options: any, option: string, globalOptions?: any): void
  • This is used to set the options of subobjects in the options object.

    A requirement of these subobjects is that they have an 'enabled' element which is optional for the user but mandatory for the program.

    The added value here of the merge is that option 'enabled' is set as required.

    Parameters

    • mergeTarget: any

      Either this.options or the options used for the groups.

    • options: any

      Options.

    • option: string

      Option key in the options argument.

    • globalOptions: any = {}

      Global options, passed in to determine value of option 'enabled'.

    Returns void

  • overrideOpacity(color: string, opacity: number): string
  • This function takes string color in hex or RGB format and adds the opacity, RGBA is passed through unchanged.

    Parameters

    • color: string

      The color string (hex, RGB, RGBA).

    • opacity: number

      The new opacity.

    Returns string

    RGBA string, for example 'rgba(255, 0, 127, 0.3)'.

  • Parse a color property into an object with border, background, and highlight colors.

    Parameters

    • inputColor: string

      Shorthand color string or input color object.

    Returns FullColorObject

    Color object.

  • Parse a color property into an object with border, background, and highlight colors.

    Parameters

    Returns FullColorObject

    Color object.

  • Parse a color property into an object with border, background, and highlight colors.

    Parameters

    • inputColor: ColorObject

      Shorthand color string or input color object.

    Returns ColorObject

    Color object.

  • Parse a color property into an object with border, background, and highlight colors.

    Parameters

    • inputColor: ColorObject

      Shorthand color string or input color object.

    • defaultColor: FullColorObject

      Full color object to fill in missing values in inputColor.

    Returns FullColorObject

    Color object.

  • preventDefault(event: undefined | Event): void
  • Cancels the event's default action if it is cancelable, without stopping further propagation of the event.

    Parameters

    • event: undefined | Event

      The event whose default action should be prevented.

    Returns void

  • pureDeepObjectAssign<T>(base: T, ...updates: Assignable<T>[]): T
  • Pure version of deepObjectAssign, it doesn't modify any of it's arguments.

    Type parameters

    • T

    Parameters

    • base: T

      The base object that fullfils the whole interface T.

    • Rest ...updates: Assignable<T>[]

      Updates that may change or delete props.

    Returns T

    A brand new instance with all the supplied objects deeply merged.

  • recursiveDOMDelete(DOMobject: undefined | null | Node): void
  • Remove everything in the DOM object.

    Parameters

    • DOMobject: undefined | null | Node

      Node whose child nodes will be recursively deleted.

    Returns void

  • removeClassName(elem: Element, classNames: string): void
  • Remove a className from the given elements style.

    Parameters

    • elem: Element

      The element from which the classes will be removed.

    • classNames: string

      Space separated list of classes.

    Returns void

  • removeCssText(element: HTMLElement, cssText: string): void
  • Remove a string with css styles from an element.

    Parameters

    • element: HTMLElement

      The element from which styles should be removed.

    • cssText: string

      The styles to be removed.

    Returns void

  • removeEventListener<E>(element: E, action: Parameters<E["removeEventListener"]>[0], listener: Parameters<E["removeEventListener"]>[1], useCapture?: Parameters<E["removeEventListener"]>[2]): void
  • Remove an event listener from an element.

    Type parameters

    • E: Element

    Parameters

    • element: E

      The element to bind the event listener to.

    • action: Parameters<E["removeEventListener"]>[0]

      Same as Element.removeEventListener(action, —, —).

    • listener: Parameters<E["removeEventListener"]>[1]

      Same as Element.removeEventListener(—, listener, —).

    • Optional useCapture: Parameters<E["removeEventListener"]>[2]

      Same as Element.removeEventListener(—, —, useCapture).

    Returns void

  • selectiveBridgeObject<F, V>(fields: F[], referenceObject: Record<F, V>): Record<F, V> | null
  • This recursively redirects the prototype of JSON objects to the referenceObject. This is used for default options.

    Type parameters

    • F: string

    • V

    Parameters

    • fields: F[]

      Names of properties to be bridged.

    • referenceObject: Record<F, V>

      The original object.

    Returns Record<F, V> | null

    A new object inheriting from the referenceObject.

  • selectiveDeepExtend(props: string[], a: any, b: any, allowDeletion?: boolean): any
  • Extend object a with selected properties of object b. Only properties with defined values are copied.

    remarks

    Previous version of this routine implied that multiple source objects could be used; however, the implementation was wrong. Since multiple (>1) sources weren't used anywhere in the vis.js code, this has been removed

    Parameters

    • props: string[]

      Names of first-level properties to copy over.

    • a: any

      Target object.

    • b: any

      Source object.

    • allowDeletion: boolean = false

      If true, delete property in a if explicitly set to null in b.

    Returns any

    Argument a.

  • selectiveExtend(props: string[], a: any, ...others: any[]): any
  • Extend object a with selected properties of object b or a series of objects.

    remarks

    Only properties with defined values are copied.

    Parameters

    • props: string[]

      Properties to be copied to a.

    • a: any

      The target.

    • Rest ...others: any[]

      The sources.

    Returns any

    Argument a.

  • selectiveNotDeepExtend(propsToExclude: string[], a: any, b: any, allowDeletion?: boolean): any
  • Extend object a with properties of object b, ignoring properties which are explicitly specified to be excluded.

    remarks

    The properties of b are considered for copying. Properties which are themselves objects are are also extended. Only properties with defined values are copied.

    Parameters

    • propsToExclude: string[]

      Names of properties which should not be copied.

    • a: any

      Object to extend.

    • b: any

      Object to take properties from for extension.

    • allowDeletion: boolean = false

      If true, delete properties in a that are explicitly set to null in b.

    Returns any

    Argument a.

  • throttle(fn: () => void): () => void
  • Throttle the given function to be only executed once per animation frame.

    Parameters

    • fn: () => void

      The original function.

        • (): void
        • Returns void

    Returns () => void

    The throttled function.

      • (): void
      • Throttle the given function to be only executed once per animation frame.

        Returns void

        The throttled function.

  • toArray<T>(o: {} | ArrayLike<T>): T[]
  • toArray(o: {}): any[]
  • Convert an object into an array: all objects properties are put into the array. The resulting array is unordered.

    Type parameters

    • T

    Parameters

    • o: {} | ArrayLike<T>

      Object that contains the properties and methods.

    Returns T[]

    An array of unordered values.

  • Convert an object into an array: all objects properties are put into the array. The resulting array is unordered.

    Parameters

    • o: {}

      Object that contains the properties and methods.

      Returns any[]

      An array of unordered values.

    • topMost(pile: any, accessors: any): any
    • Get the top most property value from a pile of objects.

      Parameters

      • pile: any

        Array of objects, no required format.

      • accessors: any

        Array of property names. For example object['foo']['bar']['foo', 'bar'].

      Returns any

      Value of the property with given accessors path from the first pile item where it's not undefined.

    • updateProperty<K, V>(object: Record<K, V>, key: K, value: V): boolean
    • Update a property in an object.

      Type parameters

      • K: string

      • V

      Parameters

      • object: Record<K, V>

        The object whose property will be updated.

      • key: K

        Name of the property to be updated.

      • value: V

        The new value to be assigned.

      Returns boolean

      Whether the value was updated (true) or already strictly the same in the original object (false).

    Generated using TypeDoc