taraskevizer
    Preparing search index...

    Function mutatingStep

    • Utility function for a step that always modifies the text

      Not recommended to use if a step doesn't ALWAYS modify the text.

      Type Parameters

      • TStorage extends object = object

      Parameters

      • callback: (
            ...args: [
                context: {
                    cfg: {
                        abc: { lower: CallableDict<RegExp>; upper?: CallableDict<RegExp> };
                        doEscapeCapitalized: boolean;
                        g: boolean;
                        j: OptionJ;
                        leftAngleBracket: string;
                        newLine: string;
                        noFixPlaceholder: string;
                        variations: Variation;
                        wrappers:
                            | {
                                fix?: TransformString;
                                letterH?: TransformString;
                                variable?: {
                                    all: TransformString;
                                    first: TransformString;
                                    no: TransformString;
                                };
                            }
                            | null;
                    };
                    storage: TStorage;
                    text: string;
                },
            ],
        ) => string

      Returns TaraskStep<TStorage>

      type TextWrapperStorage = { wrapText: (text: string) => string };

      const trimStep = mutatingStep<TextWrapperStorage>(
      ({ text, storage: { wrapText } }) => wrapText(text.trim())
      );
      // is equivalent to
      const trimStep: TaraskStep<TextWrapperStorage> = (ctx) => {
      ctx.text = options.storage.wrapText(
      ctx.text.trim()
      );
      };