TransformChain

Creates a new transform chain.

Instance members

#appendTransform(transform)

Appends a transform to the end of the chain.

appendTransform(transform)

Appends a transform to the end of the chain.

Parameters

  • Transform or TransformDefinition transform :

    the transform to append.

#hasMatch(filename)

Check if the chain has a matching transform for a particular file.

hasMatch(filename)

Check if the chain has a matching transform for a particular file.

Parameters

  • string filename :

    the path to the file.

Returns

boolean :

true if at least one transform in the chain matches the file.

#notifyPostLoadHooks(filename)

Notify every transform that a file has been loaded. Included for legacy istanbul support.

notifyPostLoadHooks(filename)

Notify every transform that a file has been loaded. Included for legacy istanbul support.

Parameters

  • string filename :

    Passed to every transforms postLoadHook (regardless of whether the transform matches the loaded file).

#prependTransform(transform)

Prepends a transform at the beginning of the chain.

prependTransform(transform)

Prepends a transform at the beginning of the chain.

Parameters

  • Transform or TransformDefinition transform :

    the transform to prepend.

#transform(code, filename)

Transform an input using the matching transforms from the chain.

transform(code, filename)

Transform an input using the matching transforms from the chain.

Parameters

  • Any code :

    The object to be transformed using the chain. Usually this will always be a string, but it is not required. Whatever type it is. All transforms in the chain must support it.

  • string filename :

Returns

Any :

The transformed results. Again, this is almost always going to be a string.

transformCallback(code, filename, next)

A callback that performs a transform

Parameters

  • string or Any code :

    The input to be transformed.

  • string filename :

    The name of the file being transformed.

  • Function next :

    Execute the rest of the transform synchronously

    • Function next.hasNext

      Check if any of the transforms remaining in the chain can handle the file. You can optionally pass a string to change the name of the file.

Transform(opts)

Create a new transform.

Parameters

  • Object or transformCallback opts :
    • [transformCallback] opts.transform (default noop)

      The transform function.

    • [Function or string or Array<string> or RegExp] opts.match

      Used to filter whether or not this transform is applied to a given file.

    • [Array<string>] opts.extensions (default '.js')

      List of file extensions this transform applies to.

    • [boolean] opts.verbose (default false)

      If true, every invocation of the transform will be logged.

    • [string] opts.name

      The name of this transform, used in logging and error reporting.

Returns

Transform :

A new transform instance

Instance members

#matches(filename)

Check whether this transform should be applied to a given file. transformCallback

matches(filename)

Check whether this transform should be applied to a given file. transformCallback

Parameters

  • string filename :

    The name of the file

Returns

boolean :

true if this transform should be applied to the file.

#transform(code, filename, next)

Perform the transform. Called with the same parameters as transformCallback.

transform(code, filename, next)

Perform the transform. Called with the same parameters as transformCallback.

Parameters

Returns

string or Any