Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object

Type aliases

TransferableObjectType

TransferableObjectType: ArrayBuffer | ImageBitmap | MessagePort | OffscreenCanvas | ReadableStream | WritableStream

Object Basic Functions

objectBasicClone

  • objectBasicClone<ValueType>(value: ValueType, transfer?: ReadonlyArray<TransferListItem>): ValueType
  • name

    objectBasicClone

    description

    Creates a deep clone of a given value using the structured clone algorithm. Do not throw errors if structured cloning is not possible. In case of failure returns the same variable. You can check it with Object.is(originalVariable, clonedVariable). Requires: NodeJS v17.0.0, Firefox v94.

    summary

    import { objectBasicClone } from "@corefunc/corefunc/object/basic/clone";

    template
    since

    0.3.20

    Type parameters

    • ValueType

    Parameters

    • value: ValueType

      The object to be cloned. This can be any structured-clonable type.

    • Optional transfer: ReadonlyArray<TransferListItem>

    Returns ValueType

    The returned value is a deep copy of the original value.

objectBasicDeCycle

  • objectBasicDeCycle<ObjectType>(object: ObjectType, _path?: string): ObjectType
  • name

    objectBasicDeCycle

    description

    De-cycle object.

    summary

    import { objectBasicDeCycle } from '@corefunc/corefunc/object/basic/de-cycle';

    since

    0.1.55

    Type parameters

    • ObjectType: any[] | Record<string, any>

    Parameters

    • object: ObjectType

      Object to de-cycle.

    • Optional _path: string

      Path ot property to de-cycle.

    Returns ObjectType

    De-cycled object.

objectBasicLock

  • objectBasicLock<ObjectType>(object: ObjectType): ObjectType
  • name

    objectBasicLock

    description

    Lock, freeze and seal object.

    summary

    import { objectBasicLock } from '@corefunc/corefunc/object/basic/lock';

    since

    0.1.55

    Type parameters

    • ObjectType: Record<string, any>

    Parameters

    • object: ObjectType

      Object to lock.

    Returns ObjectType

    Locked object.

objectBasicSize

  • objectBasicSize<ObjectType>(object: ObjectType): number
  • name

    objectBasicSize

    description

    Get count of properties in object.

    summary

    import { objectBasicSize } from '@corefunc/corefunc/object/basic/size';

    since

    0.1.55

    Type parameters

    • ObjectType: Record<string, any>

    Parameters

    • object: ObjectType

      Object to search in.

    Returns number

    Count of properties.

Object From Functions

objectFromKeysValues

  • objectFromKeysValues(keys: string[], values: unknown[]): Record<string, unknown>
  • name

    objectFromKeysValues

    description

    Create object form array of keys and array of values

    Parameters

    • keys: string[]
    • values: unknown[]

    Returns Record<string, unknown>

Object Get Functions

objectGetClass

  • objectGetClass(value: Record<string, unknown>): string
  • name

    objectGetClass

    description

    Retrieve instance class name

    since

    1.0.2

    Parameters

    • value: Record<string, unknown>

    Returns string

objectGetKeys

  • objectGetKeys(object: object): string[]
  • name

    objectGetKeys

    Parameters

    • object: object

    Returns string[]

objectGetProperty

  • objectGetProperty<ObjectType, KeyType, DefaultType>(object: ObjectType, keyOrPath: KeyType | string | string[], defaultValue?: DefaultType, valueType?: "asyncfunction" | "array" | "boolean" | "date" | "error" | "function" | "generatorfunction" | "map" | "null" | "number" | "object" | "promise" | "proxy" | "regexp" | "set" | "string" | "symbol" | "undefined" | "weakmap" | "weakset"): ObjectType[KeyType] | DefaultType
  • name

    objectGetProperty

    description

    Gets the value at path of object.

    summary

    import { objectGetProperty } from '@corefunc/corefunc/object/get/property';

    since

    0.0.47

    deprecated

    Use optional chaining instead

    const value = object?.property?.subProperty ?? "N/A";
    

    Type parameters

    • ObjectType: Record<string, any>

    • KeyType: string | number | symbol

    • DefaultType: unknown

    Parameters

    • object: ObjectType

      Object to search in

    • keyOrPath: KeyType | string | string[]

      String key or array of string to form path

    • Optional defaultValue: DefaultType
    • Optional valueType: "asyncfunction" | "array" | "boolean" | "date" | "error" | "function" | "generatorfunction" | "map" | "null" | "number" | "object" | "promise" | "proxy" | "regexp" | "set" | "string" | "symbol" | "undefined" | "weakmap" | "weakset"

    Returns ObjectType[KeyType] | DefaultType

    Value in path or default value

objectGetType

  • objectGetType(objectLike: Record<string, unknown>): string
  • name

    objectGetType

    description

    Get type of object

    Parameters

    • objectLike: Record<string, unknown>

    Returns string

objectIsOwnProperty

  • objectIsOwnProperty<ObjectType>(object: ObjectType, key: string): boolean
  • name

    objectGetProperty

    description

    Whether the object has the specified own property.

    summary

    import { objectIsOwnProperty } from '@corefunc/corefunc/object/is/own-property';

    since

    0.1.55

    Type parameters

    • ObjectType: Record<string, any>

    Parameters

    • object: ObjectType

      Object to search in

    • key: string

    Returns boolean

    Is own property.

Object Is Functions

objectIsEmpty

  • objectIsEmpty(object: Record<string, any>, withNotEnumerable?: boolean): boolean
  • name

    objectIsEmpty

    description

    Checks wherever object is empty

    example

    const object = {}; Object.defineProperties(object, { key: { enumerable: false } }); objectIsEmpty(object) ➜ true objectIsEmpty(object, false) ➜ true objectIsEmpty(object, true) ➜ false

    since

    0.1.45

    Parameters

    • object: Record<string, any>
    • withNotEnumerable: boolean = false

    Returns boolean

Object Keys Functions

objectKeysOrder

  • objectKeysOrder<ObjectType>(instance: ObjectType, keys?: string[], alphabetize?: boolean): ObjectType
  • name

    objectKeysOrder

    description

    Order keys if can and return new object instance.

    summary

    import { objectKeysOrder } from "@corefunc/corefunc/object/keys/order";

    Type parameters

    • ObjectType: object

    Parameters

    • instance: ObjectType

      Object to be ordered.

    • keys: string[] = []
    • alphabetize: boolean = false

    Returns ObjectType

    New object with ordered keys.

objectKeysPick

  • objectKeysPick<GenericObject, Keys, PartialObject, Value, DefineMissing>(instance: GenericObject, keys: Keys, defineMissing: DefineMissing): DefineMissing extends true ? Partial<PartialObject> : PartialObject
  • name

    objectKeysPick

    description

    Pick keys from object and return new plain object.

    summary

    import { objectKeysPick } from '@corefunc/corefunc/object/keys/pick';

    Type parameters

    • GenericObject: Record<string | number | symbol, Value>

    • Keys: string[] | readonly string[]

    • PartialObject: Record<keyof Keys, Value>

    • Value

    • DefineMissing: boolean

    Parameters

    • instance: GenericObject
    • keys: Keys
    • defineMissing: DefineMissing

    Returns DefineMissing extends true ? Partial<PartialObject> : PartialObject

    New plain object.

objectKeysSort

  • objectKeysSort<ObjectType>(objectLike: ObjectType, isDeep?: boolean, depth?: number): ObjectType
  • name

    objectKeysSort

    description

    Sort keys if can and return new object instance.

    summary

    import { objectKeysSort } from "@corefunc/corefunc/object/keys/sort";

    Type parameters

    • ObjectType: Record<string | number | symbol, unknown>

    Parameters

    • objectLike: ObjectType

      Object to be sorted.

    • isDeep: boolean = true
    • depth: number = 8

    Returns ObjectType

    New object with sorted keys.

Object Set Functions

objectSetDeep

  • objectSetDeep<Target, Source>(target: Target, source: Source): Target & Source
  • name

    objectSetDeep

    description

    Set object values.

    summary

    import { objectSetDeep } from "@corefunc/corefunc/object/set/deep";

    since

    0.3.56

    Type parameters

    • Target: Record<string, any>

    • Source: Record<string, any>

    Parameters

    • target: Target
    • source: Source

    Returns Target & Source

objectSetDefaults

  • objectSetDefaults<Dest, Src>(destination: Dest, source: Src, options?: object): Dest & Src
  • name

    objectSetDefaults

    example

    objectSetDefaults({}, { val: true }) // { val: true }

    example

    objectSetDefaults({ val: undefined }, { val: true }) // { val: true }

    example

    objectSetDefaults({ val: null }, { val: true }) // { val: null }

    example

    objectSetDefaults({ val: "text" }, { val: true }) // { val: "text" }

    Type parameters

    • Dest: object

    • Src: object

    Parameters

    • destination: Dest
    • source: Src
    • options: object = ...
      • Optional arrayMergeToUnique?: boolean
      • Optional nullAsUndefined?: boolean
      • Optional objectDeepMerge?: boolean
      • Optional undefinedPreservation?: boolean

    Returns Dest & Src

objectSetTarget

  • objectSetTarget<Target, Source>(destination: Target, source: Source, options?: object): Target & Source
  • name

    objectSetTarget

    description

    Set source object to target object. Override properties in target object. Do not create new object. Do not override undefined properties.

    summary

    import { objectSetTarget } from "@corefunc/corefunc/object/set/target";

    since

    0.3.63

    Type parameters

    • Target: object

    • Source: object

    Parameters

    • destination: Target
    • source: Source
    • options: object = ...
      • Optional arrayMergeToUnique?: boolean
      • Optional nullAsUndefined?: boolean
      • Optional objectDeepMerge?: boolean
      • Optional undefinedPreservation?: boolean

    Returns Target & Source

objectSetValue

  • objectSetValue<ObjectType>(object: ObjectType, key: string, value: any): ObjectType
  • name

    objectSetValue

    description

    Sets the value at key of object.

    summary

    import { objectSetValue } from '@corefunc/corefunc/object/set/value';

    since

    0.1.55

    Type parameters

    • ObjectType: Set<any> | Map<any, any> | Record<string, any> | WeakSet<any> | WeakMap<any, any>

    Parameters

    • object: ObjectType

      Object to set in.

    • key: string
    • value: any

    Returns ObjectType

    Object that was modified.

Object Values Functions

objectValues

  • objectValues<ObjectType>(object: ObjectType): any[]
  • name

    objectValues

    description

    Gets object values.

    summary

    import { objectValues } from '@corefunc/corefunc/object/values/values';

    Type parameters

    • ObjectType: Record<string, any>

    Parameters

    • object: ObjectType

      Object to search in

    Returns any[]

    Array with values.

Generated using TypeDoc