SergeiKiss/frontend-project-46

View on GitHub
src/formatters/index.js

Summary

Maintainability
A
0 mins
Test Coverage
B
80%
import stringifyStylish from './stylish.js';
import stringifyPlain from './plain.js';
import stringifyJSON from './json.js';

export default (formatName) => {
  switch (formatName) {
    case 'stylish':
      return stringifyStylish;
    case 'plain':
      return stringifyPlain;

    case 'json':
      return stringifyJSON;

    default:
      throw new Error('Unknown formatter');
  }
};