Class Config

Hierarchy

Implements

Constructors

Properties

Methods

Constructors

Properties

data: {} = {}

Type declaration

    Description

    Data storage

    Template: {
        empty: boolean;
        function: boolean;
        link: boolean;
        regexp: boolean;
        string: boolean;
    } = ...

    Type declaration

    • empty: boolean
    • function: boolean
    • link: boolean
    • regexp: boolean
    • string: boolean

    Description

    Template enabling settings

    Methods

    • Type Parameters

      • T = unknown

      Parameters

      • path: PropertyPath

        data path

      • Optional def: T

        default value

        Optional

      Returns T

      Description

      Get config property by path

      Example

      import { Config } from '@biorate/config';

      const config = new Config();

      config.set('a', 1);

      console.log(config.get('a')); // 1
      console.log(config.get('b', 2)); // 2
      console.log(config.get('b')); // UndefinedConfigPathError: Undefined config path [b]
      // at Config.get (src/index.ts:2:1608)
      // at Context.<anonymous> (tests/index.spec.ts:19:24)
      // at processImmediate (node:internal/timers:464:21)
    • Parameters

      • path: PropertyPath

        data path

      Returns boolean

      Description

      Has config property by path

      Example

      import { Config } from '@biorate/config';

      const config = new Config();

      config.set('a', 1);

      console.log(config.has('a')); // true
    • Parameters

      • data: unknown

        data object

      Returns void

      Description

      Merge config data

      Example

      import { Config } from '@biorate/config';

      const config = new Config();

      config.merge({
      a: { b: { c: 1 } },
      });

      config.merge({
      a: { b: { d: 2 } },
      });

      console.log(config.has('a')); // true
      console.log(config.has('a.b')); // true
      console.log(config.get('a.b.c')); // 1
      console.log(config.get('a.b.d')); // 2
    • Parameters

      • path: PropertyPath

        data path

      • value: unknown

        data value

      Returns void

      Description

      Set config property by path

      Example

      import { Config } from '@biorate/config';

      const config = new Config();

      config.set('a', 1);

      console.log(config.get('a')); // 1
    • Parameters

      • value: string

      Returns string | RegExp | unknown[] | Record<string, unknown> | (() => unknown)

      Description

      Set template value

    Generated using TypeDoc