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

Transformer

The base transformer class.

Test:

Static Method Summary

Static Public Methods
public static

combinedTransformer(transformers: Transformer[], direction: TransformDirection): function(node: Node): Promise<any>

Returns a function that combines multiple transformer actions.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Creates a new Transformer with the specified options.

Member Summary

Public Members
public

Method Summary

Public Methods
public

compatTransform(direction: TransformDirection, node: Node, context: Object): *

A transform wrapper that works with both async/await (atscm >= 1) and callback-based (atscm < 1)transformers.

public

Determines if a node's value node should be read, e.G. The Variable.Bool file for a node defined in .Variable.Bool.Json.

public

async transformFromDB(node: BrowsedNode, context: Object)

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

public

async transformFromFilesystem(node: BrowsedNode, context: Object)

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

public

Returns the Transformer with the given direction.

Static Public Methods

public static combinedTransformer(transformers: Transformer[], direction: TransformDirection): function(node: Node): Promise<any> source

Returns a function that combines multiple transformer actions.

Params:

NameTypeAttributeDescription
transformers Transformer[]

An array of transformers.

direction TransformDirection

The direction to use.

Return:

function(node: Node): Promise<any>

The combined transform function.

Public Constructors

public constructor(options: Object) source

Creates a new Transformer with the specified options.

Params:

NameTypeAttributeDescription
options Object
  • optional

The options to use.

options.direction TransformDirection
  • optional

The direction to use.

Throw:

Error

Throws an error if the given direction is invalid.

Test:

Public Members

public direction: * source

Public Methods

public compatTransform(direction: TransformDirection, node: Node, context: Object): * source

A transform wrapper that works with both async/await (atscm >= 1) and callback-based (atscm < 1)transformers.

Params:

NameTypeAttributeDescription
direction TransformDirection

The direction to use.

node Node

The node to transform.

context Object

The browser context.

Return:

*

public readNodeFile(node: FileNode): boolean source

Determines if a node's value node should be read, e.G. The Variable.Bool file for a node defined in .Variable.Bool.Json.

Params:

NameTypeAttributeDescription
node FileNode

The node to read or not.

Return:

boolean

true if the node's value file should be read, undefined to let other transformers decide.

public async transformFromDB(node: BrowsedNode, context: Object) source

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

Params:

NameTypeAttributeDescription
node BrowsedNode

The node to split.

context Object

The transform context.

Test:

public async transformFromFilesystem(node: BrowsedNode, context: Object) source

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

Params:

NameTypeAttributeDescription
node BrowsedNode

The node to transform.

context Object

The browser context.

Test:

public withDirection(direction: TransformDirection): Transformer source

Returns the Transformer with the given direction.

Params:

NameTypeAttributeDescription
direction TransformDirection

The direction to use.

Return:

Transformer

Itself, to be chainable.

Throw:

Error

Throws an error if the given direction is invalid.

Test: