Transformer
Direct Subclass:
Controls how files are transformed from and to the filesystem. Must be subclassed.
Static Member Summary
| Static Public Members | ||
| public static get |
The NodeTypes the transform should be applied to. |
|
Static Method Summary
| Static Public Methods | ||
| public static |
encapsule(file: AtviseFile, extname: String) Encapsules a file. |
|
| public static |
encapsuledFile(file: AtviseFile, extname: String, contentString: String): AtviseFile Takes a file and returns an encapsuled file apon it. |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(options: Object) Creates a new Transformer based on some options |
|
Method Summary
| Public Methods | ||
| public abstract |
flushFromDB(stream: NodeStream, cb: function(err: Error)) A function that is applied after all transformations passed. |
|
| public abstract |
flushFromFilesystem(stream: NodeStream, cb: function(err: Error)) A function that is applied after all transformations passed. |
|
| public |
Returns a string representation of the current Transformer. |
|
| public |
transform(direction: TransformDirection): Stream Applies transformation for a given TransformDirection. |
|
| public abstract |
transformFromDB(stream: NodeStream, node: Node, enc: String, cb: function(err: Error, node: Node)) Transforms a NodeStream. |
|
| public abstract |
transformFromFilesystem(stream: Stream, file: AtviseFile, enc: String, cb: function(err: Error, file: AtviseFile)) Transforms a stream of AtviseFiles. |
|
Static Public Members
Static Public Methods
public static encapsule(file: AtviseFile, extname: String) source
Encapsules a file. Useful helper when splitting a file into multiple others.
Params:
| Name | Type | Attribute | Description |
| file | AtviseFile | The file to encapsule. |
|
| extname | String |
|
The file extension to use. Defaults to |
Example:
const file = new AtviseFile({
path: 'path/to/file.ext'
});
// Results in a file with path 'path/to/file.ext/file.json'
Transformer.encapsule(file, '.json');
// Results in a file with path 'path/to/file.ext/file.ext'
Transformer.encapsule(file);
public static encapsuledFile(file: AtviseFile, extname: String, contentString: String): AtviseFile source
Takes a file and returns an encapsuled file apon it. Useful helper when splitting a file into multiple others. Transformer.encapsule is used to create the new file's path.
Params:
| Name | Type | Attribute | Description |
| file | AtviseFile | The file to clone |
|
| extname | String |
|
The file extension to use. Defaults to |
| contentString | String |
|
The new file's contents given as a string. |
Public Constructors
Public Methods
public abstract flushFromDB(stream: NodeStream, cb: function(err: Error)) source
A function that is applied after all transformations passed.
Params:
| Name | Type | Attribute | Description |
| stream | NodeStream | The stream used. |
|
| cb | function(err: Error) | Callback to call after flushing. |
public abstract flushFromFilesystem(stream: NodeStream, cb: function(err: Error)) source
A function that is applied after all transformations passed.
Params:
| Name | Type | Attribute | Description |
| stream | NodeStream | The stream used. |
|
| cb | function(err: Error) | Callback to call after flushing. |
public transform(direction: TransformDirection): Stream source
Applies transformation for a given TransformDirection.
Params:
| Name | Type | Attribute | Description |
| direction | TransformDirection | The direction to use for transformation. |
public abstract transformFromDB(stream: NodeStream, node: Node, enc: String, cb: function(err: Error, node: Node)) source
Transforms a NodeStream.
public abstract transformFromFilesystem(stream: Stream, file: AtviseFile, enc: String, cb: function(err: Error, file: AtviseFile)) source
Transforms a stream of AtviseFiles.
Params:
| Name | Type | Attribute | Description |
| stream | Stream | The stream used. |
|
| file | AtviseFile | The file to transform. |
|
| enc | String | The encoding used. |
|
| cb | function(err: Error, file: AtviseFile) | Callback to call after transformation. |