@nevware21/tripwire - v0.1.2
    Preparing search index...

    Interface IScopeContext

    The scope context is used to track the evaluation of the assertion and provide the necessary information to the assertion functions to enable the evaluation of the assertion and the display of the results.

    0.1.0

    interface IScopeContext {
        _$stackFn: Function[];
        eval(expr: boolean, evalMsg?: MsgSource, causedBy?: Error): boolean;
        fail(
            msg: MsgSource,
            details?: any,
            stackStart?: Function | Function[],
        ): never;
        get(name: string | number | symbol): any;
        getDetails(): any;
        getEvalMessage(evalMsg: MsgSource, skipOverrides?: boolean): string;
        getMessage(evalMsg?: MsgSource, skipOverrides?: boolean): string;
        keys(): string[];
        new: (value: any, overrides?: IScopeContextOverrides) => IScopeContext;
        opts: IAssertConfig;
        orgArgs: any[];
        set(name: string | number | symbol, value: any): IScopeContext;
        setOp(opName: string): IScopeContext;
        value: any;
    }
    Index

    Properties

    _$stackFn: Function[]

    Tracks the internal stack of functions that have been called during the evaluation of the context

    new: (value: any, overrides?: IScopeContextOverrides) => IScopeContext

    Creates a new child IScopeContext object using the provided value and optional overrides

    Type declaration

    Returns the options for the current context.

    orgArgs: any[]

    Returns the original arguments used during the initiation of the proxied request this is used to enable re-evaluation of the original request if needed.

    The original arguments

    value: any

    Returns the initial value being evaluated

    Methods

    • This evaluates the result and if it fails, it throws an error

      Parameters

      • expr: boolean

        The expression to evaluate

      • OptionalevalMsg: MsgSource

        The default message to display

      • OptionalcausedBy: Error

      Returns boolean

    • Throws an AssertionFailure exception with the given message and optional details which are obtained via the getDetails function.

      Parameters

      • msg: MsgSource

        The message to display.

      • Optionaldetails: any

        The details (props) to include in the error

      • OptionalstackStart: Function | Function[]

        The optional stack start function

      Returns never

      AssertionFailure always

    • Returns a named value associated with the context, this is a recursive operation and will return the first value found in the current context and all parent contexts as defined by calling the set function.

      Parameters

      • name: string | number | symbol

        The name of the property

      Returns any

    • Resolves and returns only the eval message to be displayed for the evaluation, this does not include the value or the scope initMsg or any other details.

      Parameters

      • evalMsg: MsgSource

        Used when no-message is provided

      • OptionalskipOverrides: boolean

        When true, the eval message is resolved directly and does not include the other details obtained from the execution chain like the negation.

      Returns string

    • Returns the message to be displayed for the evaluation which includes the scope initMsg prefixed with the evalMsg if provided and the value

      Parameters

      • OptionalevalMsg: MsgSource

        Used when no-message is provided

      • OptionalskipOverrides: boolean

        When true, the eval message is resolved directly and does not include the other details obtained from the execution chain like the negation.

      Returns string

    • Returns all of the keys of the values from both the current and parent context(s), this is a recursive operation and will return all keys from the current context and all parent contexts as defined by calling the set function.

      Returns string[]

    • Sets a named value associated for the context, this only affected the current context and does not affect the parent context. If the value already exists in the parent context, it will be overridden by the new value for any calls to get that are made on the current context. All calls to get for the parent context will return the original value.

      Parameters

      • name: string | number | symbol

        The name of the property

      • value: any

        The value to set

      Returns IScopeContext

    • Sets the current operation name and adds it to the context execution order, which is used to display the order of operations in the error message if an assertion fails.

      Parameters

      • opName: string

        The current operation name

      Returns IScopeContext

      The current context