variable mapFrom

Provides convenience functions for object mappers.

Use these to map to constant values, or to omit the property.

Methods

constant<TValue>(
this: void,
value: TValue
): () => TValue

Returns a function that always returns a constant value.

const objectMapperSchema = {
  out: mapFrom.constant('Hello'),
}
omit(this: void): OmitProperty

Returns the symbol OmitProperty, which will tell the mapper to omit the property from the output object.

const objectMapperSchema = {
  out: mapFrom.omit,
}
null(this: void): null

Always map the output value to null

const objectMapperSchema = {
  out: mapFrom.null,
}
pick<TKey extends PropertyKey>(
this: void,
key: TKey,
...keys: TKey[]
): [K in TKey]: K

Maps the specified properties to themselves as is

const objectMapperSchema = {
  ...mapFrom.pick('a', 'b', 'c', 'd'),
}
undefined(this: void): undefined

Always map the output value to undefined

const objectMapperSchema = {
  out: mapFrom.undefined,
}

Usage

import { mapFrom } from ".";