Home Manual Reference Source Test
import PartialTransformer from 'atscm/src/lib/transform/PartialTransformer.js'
public class | source

PartialTransformer

Extends:

Transformer → PartialTransformer

A transformer that transforms only some of the files read.

Test:

Constructor Summary

Public Constructor
public

constructor(options: Object)

Creates a new partial transformer with the specified options.

Member Summary

Public Members
public

The filter stream used.

Method Summary

Public Methods
public

Applies a stream transformer to the given, already filtered stream.

public

Applies the transformer to the given stream.

public abstract

true if file should be transformed.

Private Methods
private

_transform(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile))

Transforms a file if PartialTransformer#shouldBeTransformed returns true.

Inherited Summary

From class Transformer
public static

applyTransformers(stream: Stream, transformers: Transformer[], direction: TransformDirection): Transformer

Creates a stream with all transformers passed, with the given direction.

public get

If reference config files should be handled by the transformer.

public

direction: TransformerDirection

The transformer's direction

private

The options the transformer was created with.

public

Applies the transformer to the given stream.

public

inspect(depth: Number, options: Object): string

Prints the transformer.

public

transformFromDB(chunk: Object, enc: string, callback: function(err: ?Error, obj: ?Object))

Must be overridden by all subclasses: Transforms the given chunk when using TransformDirection.FromDB.

public

transformFromFilesystem(chunk: Object, enc: string, callback: function(err: ?Error, obj: ?Object))

Must be overridden by all subclasses: Transforms the given chunk when using TransformDirection.FromFilesystem.

public

Returns the Transformer with the given direction.

private

_processError(err: Error, chunk: *, callback: function(err: ?Error), args: Array<*>)

Decorates an error that occurred while running a transformer.

private

_transform(chunk: Object, enc: string, callback: function(err: ?Error, obj: ?Object))

Calls Transformer#transformFromDB or Transformer#transformFromFilesystem based on the transformer's direction.

Public Constructors

public constructor(options: Object) source

Creates a new partial transformer with the specified options.

Override:

Transformer#constructor

Params:

NameTypeAttributeDescription
options Object

The options to use. See Transformer#constructor for available options.

Test:

Public Members

public filter: Stream source

The filter stream used.

Test:

Public Methods

public applyToFilteredStream(stream: Stream, direction: TransformDirection): Stream source

Applies a stream transformer to the given, already filtered stream. Override this method if you want to pipe streams directly. Returning a falsy value (false, null, undefined, ...) invokes Transformer#transformFromDB or Transformer#transformFromFilesystem instead.

Params:

NameTypeAttributeDescription
stream Stream

The stream to apply the transformer to.

direction TransformDirection

The direction to use.

Return:

Stream (nullable: true)

The resulting stream.

Test:

public applyToStream(stream: Stream, direction: TransformDirection): Stream source

Applies the transformer to the given stream. It does so by running the following steps:

Override:

Transformer#applyToStream

Params:

NameTypeAttributeDescription
stream Stream

The stream to apply the transformer to.

direction TransformDirection

The direction to use.

Return:

Stream

The resulting stream.

Test:

public abstract shouldBeTransformed(file: AtviseFile) source

true if file should be transformed.

Params:

NameTypeAttributeDescription
file AtviseFile

The file to transform or not.

Test:

Private Methods

private _transform(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) source

Transforms a file if PartialTransformer#shouldBeTransformed returns true.

Override:

Transformer#_transform

Params:

NameTypeAttributeDescription
file AtviseFile

The file to transform.

enc string

The encoding used.

callback function(err: ?Error, data: ?AtviseFile)

Called with the error that occured while transforming or (optionally) the transformed file.

Test: