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

    Class VariableInspector<Type>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

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

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties - Aliases

    Properties - Args

    Properties - Inputs

    Accessors

    Methods - Args

    Methods - Compilers

    Methods - Exporters

    Methods - Formatters

    Methods - Inputs

    Methods - Recursion

    Methods - Static

    Methods - Translators

    Methods - Misc.

    Constructors

    Properties - Aliases

    mergeArgs: {
        <D extends object>(
            defaults: D,
            inputs?: undefined,
            recursive?: boolean,
        ): D;
        <D extends object, I extends Partial<D>>(
            defaults: D,
            inputs: I,
            recursive?: false,
        ): D & I;
        <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs: I,
            recursive: true,
        ): D & I;
        <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs?: I,
            recursive?: boolean,
        ): D | D & I;
    } = mergeArgs

    An alias for this package's mergeArgs().

    Type declaration

      • <D extends object>(defaults: D, inputs?: undefined, recursive?: boolean): D
      • Inputs can be undefined, and if so, the default is returned.

        Type Parameters

        • D extends object

          Default object type.

        Parameters

        • defaults: D

          Default values (if not specified in inputs).

        • Optionalinputs: undefined

          Overriding values (changes to make).

        • Optionalrecursive: boolean

          Optional. Whether to merge the object recursively. Default false.

        Returns D

        Resulting object with all the defaults and inputs keys with either default values or input values, as appropriate.

      • <D extends object, I extends Partial<D>>(
            defaults: D,
            inputs: I,
            recursive?: false,
        ): D & I
      • Passing recursive as false means that the input type must be a Partial (not RecursivePartial).

        Type Parameters

        • D extends object
        • I extends Partial<D>

        Parameters

        • defaults: D
        • inputs: I
        • Optionalrecursive: false

        Returns D & I

      • <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs: I,
            recursive: true,
        ): D & I
      • Passing recursive as true means that the input type may actually be a RecursivePartial.

        Type Parameters

        Parameters

        • defaults: D
        • inputs: I
        • recursive: true

        Returns D & I

      • <D extends object, I extends Partial<D> | RecursivePartial<D>>(
            defaults: D,
            inputs?: I,
            recursive?: boolean,
        ): D | D & I
      • Universal overload.

        Type Parameters

        Parameters

        • defaults: D
        • Optionalinputs: I
        • Optionalrecursive: boolean

        Returns D | D & I

    Properties - Args

    A completed args object.

    Properties - Inputs

    _name: string

    Value’s name, used in output.

    _properties: Child[]

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

    _rawValue: Type

    Value to inspect.

    _typeOf: Return<Type>

    Alias for this.typeOf( this._rawValue ).

    Accessors

    • get sampleComplexObject(): {
          array: undefined
          | any[];
          bigint: undefined | bigint;
          date: undefined | Date;
          false: undefined | false;
          functionParams: undefined | ((a: string, b: string) => any);
          NaN: number;
          null: null;
          number: number;
          objectEmpty: undefined | object;
          objectSimple: undefined | object;
          regex: undefined | RegExp;
          string: string;
          stringMultiline: undefined | string;
          true: undefined | true;
          undefined: undefined;
      }
      Internal

      Used for testing.

      Returns {
          array: undefined | any[];
          bigint: undefined | bigint;
          date: undefined | Date;
          false: undefined | false;
          functionParams: undefined | ((a: string, b: string) => any);
          NaN: number;
          null: null;
          number: number;
          objectEmpty: undefined | object;
          objectSimple: undefined | object;
          regex: undefined | RegExp;
          string: string;
          stringMultiline: undefined | string;
          true: undefined | true;
          undefined: undefined;
      }

    • get ARGS_DEFAULT(): {
          argsRecursive: false;
          childArgs: { includeValue: true };
          debug: false;
          equalString: " =";
          fallbackToJSON: 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 {
          argsRecursive: false;
          childArgs: { includeValue: true };
          debug: false;
          equalString: " =";
          fallbackToJSON: true;
          formatter: null;
          includePrefix: true;
          includeType: true;
          includeValue: true;
          indent: " ";
          inspectClasses: false;
          inspectFunctions: false;
          locale: "en-CA";
          localizeDateOptions: {};
          localizeDates: true;
          localizeNumberOptions: {};
          localizeNumbers: false;
          stringQuoteCharacter: "\"";
      }

    Methods - Args

    Methods - 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

    Methods - Exporters

    Methods - Formatters

    • Experimental

      Formats an object property name into a string for display.

      Parameters

      • key: string | number | symbol

      Returns string

    Methods - Inputs

    Methods - Recursion

    Methods - Static

    • Experimental

      Prints sample output to the console via VariableInspector.dump().

      Parameters

      Returns VariableInspector<
          {
              array: undefined
              | any[];
              bigint: undefined | bigint;
              date: undefined | Date;
              false: undefined | false;
              functionParams: undefined | ((a: string, b: string) => any);
              NaN: number;
              null: null;
              number: number;
              objectEmpty: undefined | object;
              objectSimple: undefined | object;
              regex: undefined | RegExp;
              string: string;
              stringMultiline: undefined | string;
              true: undefined | true;
              undefined: undefined;
          },
      >

      An example, constructed instance for a sample object.

    Methods - Translators

    Methods - Misc.

    • Internal

      Used for testing.

      Parameters

      • verbose: boolean

      Returns {
          NaN: number;
          null: null;
          number: number;
          string: string;
          array?: any[];
          bigint?: bigint;
          class?: typeof TestClass;
          classInstance?: TestClass<Type>;
          date?: Date;
          false?: false;
          functionParams?: (a: string, b: string) => any;
          functionSimple?: () => any;
          objectEmpty?: object;
          objectSimple?: object;
          regex?: RegExp;
          stringMultiline?: string;
          true?: true;
          undefined?: undefined;
      }