new FormatterManager()
constructor
Example
class SampleFormatter {
static pack(payload) {
const boundary = 'Boundary-' + Date.now();
const args = JSON.stringify(payload.args);
const body = new FormData();
body.append('arguments', args);
return {
method: 'POST',
body,
mode: 'cors',
credentails: 'include'
};
}
static unpack(response) {
return response.json();
}
}
export default SampleFormatter;
Methods
-
addFormatter(format, formatter)
-
Add formatter to the formatters object
Parameters:
Name Type Description formatString name of the format formatterObject formatter object Throws:
-
-
Will throw an error when the provided pormatter doesn't implement pack() and unpack()
- Type
- TypeError
-
-
-
Will throw an error when attempting to replace an existing formatter
- Type
- Error
-
-
-
getFormatter(format)
-
Get formatter based on format name
Parameters:
Name Type Description formatString name of the format Returns:
- Type
- Object