Photo Sphere Viewer
    Preparing search index...

    Function getConfigParser

    • Creates a function to validate an user configuration object

      Type Parameters

      • T extends Record<string, any>

        type of input config

      • U extends Record<string, any> = T

        type of config after parsing

      Parameters

      • defaults: Required<U>

        the default configuration

      • Optionalparsers: ConfigParsers<T, U>

        function used to parse/validate the configuration

      Returns ConfigParser<T, U>

      type MyConfig = {
      value: number;
      label?: string;
      };

      const getConfig<MyConfig>({
      value: 1,
      label: 'Title',
      }, {
      value(value, { defValue }) {
      return value < 10 ? value : defValue;
      }
      });

      const config = getConfig({ value: 3 });