Options
All
  • Public
  • Public/Protected
  • All
Menu

Module toPojo

Index

References

default

Renames and exports toPojo

Type aliases

MatchFn

MatchFn<I>: (input: I) => boolean

Type parameters

  • I

Type declaration

    • (input: I): boolean
    • Function that will match input

      Parameters

      • input: I

      Returns boolean

TransformFn

TransformFn<I, O>: (input: I, ...args: any[]) => O

Type parameters

  • I

  • O

Type declaration

    • (input: I, ...args: any[]): O
    • Function that will transform input to output.

      Returning undefined will cause the key to be deleted.

      Parameters

      • input: I
      • Rest ...args: any[]

      Returns O

Functions

makeBinaryEncoders

  • Returns converters that will encode binary as a format from @znetstar/encode-tools.

    example

    (toPojo.toPojo(body, { ...toPojo.DEFAULT_TO_POJO_OPTIONS, conversions: [ ...makeBinaryEncoders('ascii85' as any), ...(toPojo.DEFAULT_TO_POJO_OPTIONS.conversions || []) ] }))

    Type parameters

    • I

    • O

    Parameters

    • encoder: any

      @znetstar/encode-tools encoder

    • Optional encoding: any

      Encoding to pass to @znetstar/encode-tools

    Returns [Conversion<I, O>, Conversion<I, O>]

makePrototypeMatcher

  • makePrototypeMatcher<I>(constructors: string[] | string): MatchFn<I>
  • Creates a MatchFn that can match against a list of constructor names

    Type parameters

    • I

    Parameters

    • constructors: string[] | string

      List of constructor names

    Returns MatchFn<I>

toPojo

  • toPojo<I, O>(input: I, options?: Partial<ToPojoOptions<I, O>>): O
  • Attempts to turn a complex JavaScript object, into a simple serializable one, by recursively walking through the object and running the provided conversions, or the default transformation.

    Will stop at the first matched conversion and then return the output of the transform function.

    Type parameters

    • I

    • O

    Parameters

    Returns O

Generated using TypeDoc