Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
fairwind2k committed Dec 13, 2023
1 parent 40b2ca8 commit 990f29d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/formatters/getOutput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import makePlain from './makePlain.js';
import makeStylish from './makeStylish.js';

const getOutput = (tree, formatter) => {
switch (formatter) {
case 'plain':
return makePlain(tree);
case 'json':
return JSON.stringify(tree);
case 'stylish':
return makeStylish(tree);
default:
throw new Error('Error! Choose the option!');
}
};

export default getOutput;

0 comments on commit 990f29d

Please sign in to comment.