@haraldki/jsonaccess
    Preparing search index...

    Function jsonAsInstance

    • Calls jsonAsType using the provided constructor as the factory method. Consider, for example, a class Item with two constructor parameters of type string and number respectively. Then we can use

      const item = jsonAsInstance(
      data,
      [jsonStringGetter('name'), jsonNumberGetter('count')],
      Item
      );

      to safely pick fields name and count respectively from data and call the constructor of Item.

      Type Parameters

      • A extends unknown[]
      • C extends object

      Parameters

      • data: unknown
      • mappers: { [I in string | number | symbol]: Extractor<A[I]> }
      • ctor: new (...args: A) => C

      Returns Maybe<C>