Nutrient Web SDK
    Preparing search index...

    Class ComparisonOperation

    ComparisonOperation is a class that provides methods to describe a comparison operation. It encapsulates the type and optional settings for the comparison.

    It is an Immutable.Record and thus can be updated using set(key, value), for example: scale.set("options", { numberOfContextWords: 4 })

    Create a new text comparison operation.

    const operation = new ComparisonOperation(NutrientViewer.ComparisonOperationType.TEXT, { numberOfContextWords: 2 });
    

    Create a new AI comparison operation.

    const aiOperation = new ComparisonOperation(
    NutrientViewer.ComparisonOperationType.AI,
    { operationType: NutrientViewer.AIComparisonOperationType.ANALYZE, model: 'gpt4o' }
    );
    { type: NutrientViewer.ComparisonOperationType.TEXT, options: { numberOfContextWords: 0 } }
    

    Hierarchy

    • Record<IComparisonOperation, this> & Readonly<IComparisonOperation>
      • ComparisonOperation
    Index

    Constructors

    • Parameters

      • type: "text" | "ai"
      • options:
            | {
                numberOfContextWords?: number;
                wordLevel?: boolean;
                [key: string]: any;
            }
            | IAIComparisonOperationOptions = {}

      Returns NutrientViewer.ComparisonOperation

    Properties

    options?: IComparisonOperationOptions
    type: "text" | "ai"

    Methods

    • Returns IterableIterator<
          [
              keyof IComparisonOperation,
              undefined
              | "text" | "ai"
              | IComparisonOperationOptions,
          ],
      >

    • Returns this

      Map#asImmutable

    • Returns this

      Map#asMutable

    • Returns a new instance of this Record type with all values set to their default values.

      Returns this

    • Returns a new instance of this Record type with the value for the specific key set to its default value.

      Type Parameters

      • K extends keyof IComparisonOperation

      Parameters

      • key: K

      Returns this

      remove

    • Parameters

      Returns this

      removeIn

    • Parameters

      • other: any

      Returns boolean

    • Returns the value associated with the provided key, which may be the default value defined when creating the Record factory function.

      If the requested key is not defined by this Record type, then notSetValue will be returned if provided. Note that this scenario would produce an error when using Flow or TypeScript.

      Type Parameters

      • K extends keyof IComparisonOperation

      Parameters

      • key: K
      • OptionalnotSetValue: any

      Returns IComparisonOperation[K]

    • Type Parameters

      • T

      Parameters

      • key: string
      • notSetValue: T

      Returns T

    • Returns the AI operation type, if this is an AI comparison

      Returns undefined | IAIComparisonOperationType

    • Parameters

      Returns any

    • Parameters

      • key: string

      Returns key is "type" | "options"

    • Returns number

    • Parameters

      Returns boolean

    • Returns true if this operation is an AI comparison

      Returns boolean

    • Returns true if this operation is a text comparison

      Returns boolean

    • Parameters

      • ...collections: (Iterable<[string, any]> | Partial<IComparisonOperation>)[]

      Returns this

    • Parameters

      • ...collections: (Iterable<[string, any]> | Partial<IComparisonOperation>)[]

      Returns this

    • Parameters

      • keyPath: Iterable<any>
      • ...collections: any[]

      Returns this

    • Parameters

      • merger: (oldVal: any, newVal: any, key: any) => any
      • ...collections: (Iterable<[string, any]> | Partial<IComparisonOperation>)[]

      Returns this

    • Parameters

      • keyPath: Iterable<any>
      • ...collections: any[]

      Returns this

    • Parameters

      • merger: (oldVal: any, newVal: any, key: keyof IComparisonOperation) => any
      • ...collections: (Iterable<[string, any]> | Partial<IComparisonOperation>)[]

      Returns this

    • Type Parameters

      • K extends keyof IComparisonOperation

      Parameters

      • key: K

      Returns this

    • Parameters

      Returns this

    • Type Parameters

      • K extends keyof IComparisonOperation

      Parameters

      • key: K
      • value: IComparisonOperation[K]

      Returns this

    • Parameters

      Returns this

    • Deeply converts this Record to equivalent native JavaScript Object.

      Note: This method may not be overridden. Objects with custom serialization to plain JS may override toJSON() instead.

      Returns { options?: any; type: any }

    • Shallowly converts this Record to equivalent native JavaScript Object.

      Returns IComparisonOperation

    • Shallowly converts this Record to equivalent JavaScript Object.

      Returns IComparisonOperation

    • Returns Keyed<
          keyof IComparisonOperation,
          undefined
          | "text" | "ai"
          | IComparisonOperationOptions,
      >

    • Type Parameters

      • K extends keyof IComparisonOperation

      Parameters

      • key: K
      • updater: (value: IComparisonOperation[K]) => IComparisonOperation[K]

      Returns this

    • Parameters

      • keyPath: Iterable<any>
      • updater: (value: any) => any

      Returns this

    • Returns boolean

      Map#wasAltered

    • Note: Not all methods can be used on a mutable collection or within withMutations! Only set may be used mutatively.

      Parameters

      • mutator: (mutable: this) => any

      Returns this

      Map#withMutations