Options
All
  • Public
  • Public/Protected
  • All
Menu

@ezy/object-description

Index

Type aliases

Path

Path: Array<string | number>

Values

Values: Array<object>

Functions

defaultAssignStructure

  • defaultAssignStructure(target: any, prop: any, Ctor: any): void
  • assign a structure to a target structure

    Parameters

    • target: any
    • prop: any
    • Ctor: any

    Returns void

defaultAssignValue

  • defaultAssignValue(target: any, prop: any, value: any): void
  • assign a value to a target structure

    Parameters

    • target: any
    • prop: any
    • value: any

    Returns void

defaultIsValue

  • defaultIsValue(value: any): boolean
  • check if a given value is a literal Object or an Array

    Parameters

    • value: any

    Returns boolean

from

  • Convert an object/array description in it's exact representation.

    Example

    import { from as fromDescription } from '@ezy/object-description'
    console.log(fromDescription({
     Ctor: Object,
     values: [
      { path: ['value'], value: true },
      { path: ['lvl1', 'lvl2', 0, 1, '50'], value: false }
    ]
    }))
    // => { value: true, lvl1: { lvl2: [ [ undefined, { '50': false } ] ] } }

    Parameters

    Returns any

    an object or array.

getByPath

  • getByPath(paths: any, obj: any): any

to

  • to(value: any, complete?: boolean, isValue?: function): Description
  • Convert any object/array into a description object with all values values and their associated path.

    Example

    import { to as toDescription } from '@ezy/object-description'
    console.log(toDescription({
       value: true,
       lvl1: {
          lvl2: [
              [undefined, { 50: false }]
         ]
      }
    }))
    // => {
    // Ctor: Object,
    // values: [
    //   { path: ['value'], value: true },
    //   { path: ['lvl1', 'lvl2', 0, 1, '50'], value: false }
    // ]
    //}

    Parameters

    • value: any

      an object or array.

    • Default value complete: boolean = false
    • Default value isValue: function = defaultIsValue

      a function to check if the given object or primitive should be considered as a value (Optional)

        • (value: any, key?: string | number, path?: Path): boolean
        • Parameters

          • value: any
          • Optional key: string | number
          • Optional path: Path

          Returns boolean

    Returns Description

    a description object.

Generated using TypeDoc