Creates a new transform chain.
#appendTransform(transform)
Appends a transform to the end of the chain.
Appends a transform to the end of the chain.
Transform
or TransformDefinition
transform
:
the transform to append.
#hasMatch(filename)
Check if the chain has a matching transform for a particular file.
#notifyPostLoadHooks(filename)
Notify every transform that a file has been loaded. Included for legacy istanbul support.
Notify every transform that a file has been loaded. Included for legacy istanbul support.
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.
Prepends a transform at the beginning of the chain.
Transform
or TransformDefinition
transform
:
the transform to prepend.
#transform(code, filename)
Transform an input using the matching transforms from the chain.
Transform an input using the matching transforms from the chain.
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
:
Any
:
The transformed results. Again, this is almost always going to be a string.
A callback that performs a transform
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.
Create a new transform.
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.
Transform
:
A new transform instance
#matches(filename)
Check whether this transform should be applied to a given file. transformCallback
Check whether this transform should be applied to a given file. transformCallback
string
filename
:
The name of the file
boolean
:
true if this transform should be applied to the file.