addTransform

How to get addTransform

import addTransform from 'fontoxml-operations/src/addTransform.js'

Type: Function

Register a transform to the set of globally usable transforms. Transforms do not change application state, but do change the step data of the operation.

Examples of transforms include setting contextNodeId to various values, or encoding information in a URL.

Arguments

# Name Type Description
1. name String

The name of the transform. Operations can invoke transform action using a step of type "transform/name".

2. run Function

Asynchronous callback function which defines the actual behavior of the transform.

Asynchronous callback function which defines the actual behavior of the transform.

The callback receives the current operation StepData as the first and only argument. It should return the transformed StepData. If your transform is asynchronous, you can return a promise that eventually resolves into the transformed step data.


  Arguments
# Name Type Description
1. stepData StepData
  Returns

Type: StepData | Promise<StepData>

3. [getState] Function

Optional asynchronous callback function which can be implemented to calculate the current state of operations using this transform.

Optional asynchronous callback function which can be implemented to calculate the current state of operations using this transform. Useful if the transform is not entirely without side-effects, or can be simplified when getting operation state.

The callback receives the current operation StepData as the first and only argument. It should return the new OperationState. If determining the operation state is asynchronous, you can return a promise that eventually resolves into the new operation state.


  Arguments
# Name Type Description
1. stepData StepData
  Returns

Type: OperationState | Promise<OperationState>