Class: Translator

@citation-js/core.util.Translator(props)

new Translator(props)

Parameters:
Name Type Description
props Array.<module:@citation-js/core.util.Translator~statement>
Source:
To Do:
  • proper merging (?)
  • 'else' conditions

Members

convertToSource :module:@citation-js/core.util.Translator~convert

Type:
Source:

convertToTarget :module:@citation-js/core.util.Translator~convert

Type:
Source:

(static) Translator.CONVERT_TO_SOURCE

Properties:
Name Type Description
CONVERT_TO_SOURCE Symbol
Source:

(static) Translator.CONVERT_TO_TARGET

Properties:
Name Type Description
CONVERT_TO_TARGET Symbol
Source:

Type Definitions

condition

A top-level Boolean enables or disables a mapping unit in a given direction. Otherwise, individual properties are checked with an object specifying the property name and one of four things:

  • A boolean, checking for presence of the property
  • An array of values for checking whether the property value is in them
  • A value that should match with the property value
  • A predicate function taking in the value and returning a boolean

All conditions have to be fulfilled for the mapping unit to be enabled.

Type:
Source:

conditionPredicate(input) → {Boolean}

Return, whether a mapping should apply.

Parameters:
Name Type Description
input Object

input

Source:
Returns:
Type
Boolean

conditionPropPredicate(input) → {Boolean}

Return, based on a property, whether a mapping should apply.

Parameters:
Name Type Description
input *

input value

Source:
Returns:
Type
Boolean

convert(input) → {Object}

Return, whether a mapping should apply.

Parameters:
Name Type Description
input Object

input

Source:
Returns:

output

Type
Object

convertProp(…input) → {Array|*}

In the case of toTarget, source is input and target is output. In the case of toSource, source is output and target is input.

Parameters:
Name Type Attributes Description
input * <repeatable>

input values

Source:
Returns:

If output is an array and multiple output properties are specified, the output is divided over those properties.

Type
Array | *

statement

Mapping unit.

Type:
  • Object
Properties:
Name Type Attributes Description
source String | Array.<String> <optional>

properties to source value from

target String | Array.<String> <optional>

properties the value should go to

convert Object <optional>

convert serialized or nested values

Properties
Name Type Attributes Description
toTarget module:@citation-js/core.util.Translator~convertProp <optional>

function to convert source prop to target

toSource module:@citation-js/core.util.Translator~convertProp <optional>

function to convert target prop to source

when Object <optional>

conditions as to when this statement should apply

Properties
Name Type Attributes Description
source module:@citation-js/core.util.Translator~condition <optional>
target module:@citation-js/core.util.Translator~condition <optional>
Source: