import TraitUtil from 'typhonjs-escomplex-commons/src/module/traits/TraitUtil.js'
TraitUtil
Static Method Summary
Static Public Methods | ||
public static |
Provides safe array creation from a given input. |
|
public static |
safeComputedName(node: object, parent: object): string Provides a utility method that determines the name of a method for ESTree / Babylon AST nodes. |
|
public static |
safeComputedOperands(node: object, parent: object): Array<*> Provides a utility method that determines the operands of a method for ESTree / Babylon AST nodes. |
|
public static |
safeComputedOperators(node: object, parent: object): Array<*> Provides a utility method that determines the operators of a method for ESTree / Babylon AST nodes. |
|
public static |
Provides a utility method that defers to |
|
public static |
safeNameOrValue(object: object, defaultNameOrValue: string): string Provides a utility method that defers to |
|
public static |
Provides a utility method that defers to |
Static Public Methods
public static safeArray(value: *): Array source
Provides safe array creation from a given input.
Params:
Name | Type | Attribute | Description |
value | * | A value to potentially convert into a safe array. |
public static safeComputedName(node: object, parent: object): string source
Provides a utility method that determines the name of a method for ESTree / Babylon AST nodes. For ESTree the
parent node must be accessed for class methods. If the name is a computed value and not a string literal then
astParse
is invoked to determine the computed name and is output as <computed~${computed expression}>
.
Note; ESTree has a parent node which defines the method name with a child FunctionExpression /
FunctionDeclaration. Babylon AST only has ClassMethod with a child key
providing the method name.
public static safeComputedOperands(node: object, parent: object): Array<*> source
Provides a utility method that determines the operands of a method for ESTree / Babylon AST nodes. For ESTree the
parent node must be accessed for class methods. If the name is a computed value and not a string literal then
astParse
is invoked to determine the computed operands.
Note; ESTree has a parent node which defines the method name with a child FunctionExpression /
FunctionDeclaration. Babylon AST only has ClassMethod with a child key
providing the method name.
public static safeComputedOperators(node: object, parent: object): Array<*> source
Provides a utility method that determines the operators of a method for ESTree / Babylon AST nodes. For ESTree the
parent node must be accessed for class methods. If the node is computed then astParse
is invoked to determine
the computed operators.
Note; ESTree has a parent node which defines the method name with a child FunctionExpression /
FunctionDeclaration. Babylon AST only has ClassMethod with a child key
providing the method name.
public static safeName(object: object, defaultName: string): string source
Provides a utility method that defers to object.name
if it exists or fallback to defaultName
or anonymous
.
public static safeNameOrValue(object: object, defaultNameOrValue: string): string source
Provides a utility method that defers to object.name
if it exists then falls back to 'object.value' if it exists
or falls back to defaultNameOrValue
or anonymous
.