Question: const fs = require('fs'); const _ = require(lodash); process.stdin.resume(); process.stdin.setEncoding('utf-8'); let ws; let input = ''; process.stdin.on('data', inputStdin => input += inputStdin); process.stdin.on('end', () =>


const fs = require('fs');
const _ = require("lodash");
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let ws;
let input = '';
process.stdin.on('data', inputStdin => input += inputStdin);
process.stdin.on('end', () => {
ws = fs.createWriteStream(process.env.OUTPUT_PATH);
input
.replace(/\s*$/, '') // trim
.split(' ')
.map(str => str.replace(/\s*$/, '')) // trim again
.filter(str => str.length > 1) // remove empty strings
.map(str => str.split(',')) // parse command and options
.map(([cmd, ...opts]) => { // call coresponding function
switch(cmd) {
case 'add':
return add(...opts);
case 'remove':
return remove(...opts);
case 'move':
return move(...opts);
case 'count':
return writeLine(count(...opts));
case 'print':
return print();
default:
return;
}
});
ws.end();
});
// helper for printing new lines to correct write stream
function writeLine(str) {
ws.write(str + " ");
}
let orgChart;
/**
* @param {String} employeeId
* @param {String} name
* @param {String} managerId
*/
function add(employeeId, name, managerId) {
// implement me
}
/**
* @param {String} employeeId
* @param {String} newManagerId
*/
function move(employeeId, newManagerId) {
// implement me
}
/**
* Return the count, don't worry about writing the value to console
* @param {String} employeeId
* @returns {Int} number of employees that report up to a given employee
*/
function count(employeeId) {
// implement me
}
/**
* @param {String} employeeId
*/
function remove(employeeId) {
// implement me
}
/**
* Call writeLine(str) to print a single line
*/
function print() {
writeLine('implement me');
};
This is a program to manage the Organizational Structure in a company. The program should allow us to: 1. Add employees 2. Generate the Org Chart in a specific format (explained further below). 3. Remove employees 4. Move an Employee from one manager to another. 5. Count the number of employees that ultimately report up to a given manager. The input for this program is a text file comprising of a series of commands and parameters that may look like this: 6 add, 10, Sharilyn Gruber,-1 add, 7, Denice Mattice, 10 add, 3, Lawana Futrell,-1 add, 34, Lissette Gorney,7 add,5,Lan Puls,3 print ,
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
