Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "types"

Index

Type aliases

ActionAggregator

ActionAggregator<T>: ActionAggregator<T>

An Array of String that allows to perform a function over source property

example

const source = {
  foo: 'foo',
  bar: 'bar'
};
let schema = {
  fooAndBar: ['foo', 'bar'] // Grab these properties into fooAndBar
};

morphism(schema, source);
//=> { fooAndBar: { foo: 'foo', bar: 'bar' } }

Type parameters

  • T: unknown

ActionString

ActionString<Source>: string
description

A String path that indicates where to find the property in the source input

example

const source = {
  foo: 'baz',
  bar: ['bar', 'foo'],
  baz: {
    qux: 'bazqux'
  }
};
const schema = {
  foo: 'foo', // Simple Projection
  bar: 'bar[0]', // Grab a value from an array
  bazqux: 'baz.qux' // Grab a value from a nested property,
};

morphism(schema, source);
//=> { foo: 'baz', bar: 'bar', bazqux: 'bazqux' }

Type parameters

  • Source

Actions

Actions<Target, Source>: ActionFunction<Target, Source> | ActionAggregator | ActionString<Target> | ActionSelector<Source>

Type parameters

  • Target

  • Source

DestinationFromSchema

DestinationFromSchema<T>: DestinationFromSchema<T>

Type parameters

  • T

ResultItem

ResultItem<TSchema>: DestinationFromSchema<TSchema>

Type parameters

Schema

Schema<Target, Source>: object & object

Type parameters

  • Target

  • Source

SourceFromSchema

SourceFromSchema<T>: SourceFromSchema<T>

Type parameters

  • T

StrictSchema

StrictSchema<Target, Source>: object & object

A structure-preserving object from a source data towards a target data.

The keys of the schema match the desired destination structure. Each value corresponds to an Action applied by Morphism when iterating over the input data

example

const input = {
  foo: {
    baz: 'value1'
  }
};

const schema: Schema = {
  bar: 'foo', // ActionString
  qux: ['foo', 'foo.baz'], // ActionAggregator
  quux: (iteratee, source, destination) => { // ActionFunction
    return iteratee.foo;
  },
  corge: { // ActionSelector
    path: 'foo.baz',
    fn: (propertyValue, source) => {
      return propertyValue;
    }
  }
};

morphism(schema, input);

Type parameters

  • Target

  • Source

Generated using TypeDoc