Utility TypeScript @ 2.0.0-beta.5
    Preparing search index...

    Class VariableInspector<T_InspectionType>Experimental

    Inspects the value of a variable for debugging.

    Can statically return a readable string (VariableInspector.stringify) or output it straight to console (VariableInspector.dump). By constructing an instance, you can get individual parts of the output inspection (VariableInspector.prefix, VariableInspector.type, VariableInspector.value) or get a json-compatible object representing the inspected value VariableInspector.toJSON.

    0.1.1

    2.0.0-beta.3 — Added support for objects with public toVariableInspection() method to change the value to be inspected. Added T_InspectionType type param.

    VariableInspector.dump( { mysteryVariable } );
    // console: 'mysteryVariable = <type> ...'

    Type Parameters

    Index

    Args

    A completed args object.

    • get ARGS_DEFAULT(): {
          childArgs: { includeValue: true };
          console: MiniConsole;
          debug: false;
          equalString: " =";
          fallbackToJSON: true;
          formatKeys: true;
          formatter: null;
          includePrefix: true;
          includeType: true;
          includeValue: true;
          indent: " ";
          inspectClasses: false;
          inspectFunctions: false;
          locale: "en-CA";
          localizeDateOptions: {};
          localizeDates: true;
          localizeNumberOptions: {};
          localizeNumbers: false;
          stringQuoteCharacter: "\"";
      }
      Experimental

      Returns {
          childArgs: { includeValue: true };
          console: MiniConsole;
          debug: false;
          equalString: " =";
          fallbackToJSON: true;
          formatKeys: true;
          formatter: null;
          includePrefix: true;
          includeType: true;
          includeValue: true;
          indent: " ";
          inspectClasses: false;
          inspectFunctions: false;
          locale: "en-CA";
          localizeDateOptions: {};
          localizeDates: true;
          localizeNumberOptions: {};
          localizeNumbers: false;
          stringQuoteCharacter: "\"";
      }

    Compilers

    • Experimental

      Prefix to print, not including the VariableInspector.type.

      Parameters

      • skipFormatting: boolean = false

        Optional. Whether to skip the _formatter functions. Default false.

      Returns string

    • Experimental

      String to print for variable type.

      In the case of non-Object objects with a constructor, the class name is displayed.

      Parameters

      • skipFormatting: boolean = false

        Optional. Whether to skip the _formatter functions. Default false.

      Returns string

    Constructor

    Exporters

    Formatters

    • Experimental

      Formats an object property name into a string for display.

      Parameters

      • key: string | number | symbol

      Returns string

      2.0.0-beta.3 — Renamed from keyFormatter to _keyFormatter.

    Inputs

    • Experimental

      Builds an array of the properties for the current VariableInspector._inspectionValue| this._inspectionValue.

      Returns Child[]

      2.0.0-beta.3 — Renamed from indexProperties to _indexProperties.

    _inspectionValue: T_InspectionType | undefined

    Value to inspect.

    2.0.0-beta.3

    _name: string

    Value’s name, used in output.

    _properties: Child[]

    These are the properties of the input object, if any.

    _rawValue: InputType<T_InspectionType> | undefined

    Value to inspect as passed to the constructor.

    _typeOf: Return<Extract<T_InspectionType, TestType> | undefined>

    Alias for this.typeOf( this._rawValue ).

    Recursion

    Static

    Translators

    Misc.

    2.0.0-beta.3

    _defaultName: string = 'variable'

    Default name for unnamed variables passed for inspection.

    2.0.0-beta.3

    • get _filter(): {
          type: (type: string, skipFormatting: boolean) => string;
          value: (
              str: string | null | undefined,
              viaMethod: string | undefined,
              skipFormatting: boolean,
          ) => string;
          valueVia: (viaMethod: string, skipFormatting: boolean) => string;
      }
      Experimental

      Filters for the ouput of different inspection parts.

      Returns {
          type: (type: string, skipFormatting: boolean) => string;
          value: (
              str: string | null | undefined,
              viaMethod: string | undefined,
              skipFormatting: boolean,
          ) => string;
          valueVia: (viaMethod: string, skipFormatting: boolean) => string;
      }

      • Readonlytype: (type: string, skipFormatting: boolean) => string

        Filters the value's type for output.

        2.0.0-beta.3

      • Readonlyvalue: (
            str: string | null | undefined,
            viaMethod: string | undefined,
            skipFormatting: boolean,
        ) => string

        Filters the value for output.

        2.0.0-beta.3

      • ReadonlyvalueVia: (viaMethod: string, skipFormatting: boolean) => string

        Add 'via' info to value filter.

        2.0.0-beta.3

      2.0.0-beta.3