Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "utils/helpers"

Index

Type aliases

ElementType

ElementType: string | Partial<{ type: string }>

Functions

extend

  • extend<T, S>(target: T, source: S): T & S
  • Similar to merge but only extends top levels.

    Type parameters

    • T

    • S

    Parameters

    • target: T

      the target object.

    • source: S

      the source to extend to the target.

    Returns T & S

isArray

  • isArray(value: unknown): boolean
  • Checks if value is an array.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isBooleanLike

  • isBooleanLike(value: any): boolean
  • Checks if a value is boolean like.

    Parameters

    • value: any

      the value to inspect.

    Returns boolean

isCheckbox

  • Checks if value or value.type is "checkbox".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isElement

  • isElement(value: unknown): boolean
  • Checks if an object is an element.

    Parameters

    • value: unknown

      the value to inspect as element.

    Returns boolean

isElementOrVirtual

  • isElementOrVirtual(value: unknown): any
  • Checks if an object is an element or a virtual element.

    Parameters

    • value: unknown

      the value to inspect as element or virtual.

    Returns any

isElementType

  • isElementType(tag: ElementType, match: string): boolean
  • Checks if value is matching tag type.

    Parameters

    • tag: ElementType

      the tag type or object containing type.

    • match: string

      the value to match.

    Returns boolean

isEmpty

  • isEmpty(value: unknown): boolean
  • Checks if string, object or array are empty.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isFile

  • Checks if value or value.type is "file".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isFunction

  • isFunction(value: unknown): boolean
  • Checks if is a function.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isHidden

  • Checks if value or value.type is "hidden".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isNullOrUndefined

  • isNullOrUndefined(value: unknown): boolean
  • Checks if is null or undefined.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isObject

  • isObject(value: unknown): boolean
  • Checks if is an object.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isPlainObject

  • isPlainObject(value: unknown): boolean
  • Checks if is a plain object.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isPreventEnter

  • Checks if element is of type that should prevent enter key submits.

    Parameters

    Returns boolean

isPromise

  • isPromise(value: any): boolean
  • Checks loosely if value is a promise.

    Parameters

    • value: any

      the value to inspect.

    Returns boolean

isRadio

  • Checks if value or value.type is "radio".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isSelect

  • Checks if value or value.type is "select".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isSelectMultiple

  • Checks if value or value.type is "select-multiple".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isSelectOne

  • Checks if value or value.type is "select-one".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isString

  • isString(value: unknown): boolean
  • Checks if is a string.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isText

  • Checks if value or value.type is "text".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isTextLike

  • Checks if value.type is text like input (i.e. not radio, check, submit, reset etc.)

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isTextarea

  • Checks if value or value.type is "textarea".

    Parameters

    • value: ElementType

      the string or object containing type to inspect.

    Returns boolean

isTruthy

  • isTruthy(value: unknown): boolean
  • Checks if a value is truthy.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isUndefined

  • isUndefined(value: unknown): boolean
  • Checks if value is undefined.

    Parameters

    • value: unknown

      the value to inspect.

    Returns boolean

isVirtual

  • isVirtual(value: unknown): any
  • Checks if an object is an element or is a virtual.

    Parameters

    • value: unknown

      the value to inspect as element or virtual.

    Returns any

merge

  • merge<T, S>(target: T, source: S): T & S
  • Merges two objects.

    Type parameters

    • T

    • S

    Parameters

    • target: T

      the target object.

    • source: S

      the source object to add to target.

    Returns T & S

noop

  • noop(def?: any): (Anonymous function)
  • Non operation function.

    Parameters

    • Optional def: any

      a default value to return for noop.

    Returns (Anonymous function)

parseBoolean

  • parseBoolean(value: unknown): boolean
  • Parses boolean value.

    Parameters

    • value: unknown

      the value to inspect

    Returns boolean

Const promise

  • Promise wrapper that returns an object when used with await preventing the need for try/catch.

    the promise to be executed.

    example

    const { err, data } = await me(Promise);

    Type parameters

    • T

    • E

    Parameters

    Returns { data?: T; err?: E }

    • Optional data?: T
    • Optional err?: E

toDefault

  • toDefault(value: any, def: any): any
  • Ensures default when value is undefined.

    Parameters

    • value: any

      the value to inspect.

    • def: any

      the default if value is undefined.

    Returns any

Generated using TypeDoc