Constructor
new Transformer(definition)
Parameters:
Name | Type | Description |
---|---|---|
definition | string |
- Since
- 1.5.0
- Copyright
- schukai GmbH
- License
- AGPLv3
- See
Example
import {Transformer} from '@schukai/monster/source/data/transformer.mjs';
const transformer = new Transformer("tolower")
console.log(transformer.run("HELLO"))
// ↦ hello
console.log(transformer.run("WORLD"))
// ↦ world
Methods
run(value) → {*}
Parameters:
Name | Type | Description |
---|---|---|
value | * |
Throws:
unknown command
- Type
- Error
unsupported type
- Type
- TypeError
type not supported
- Type
- Error
Returns:
- Type:
- *
setCallback(name, callback, context) → {Transformer}
Parameters:
Name | Type | Description |
---|---|---|
name | string | |
callback | function | |
context | object |
Throws:
value is not a string
- Type
- TypeError
value is not a function
- Type
- TypeError
Returns:
- Type:
- Transformer