Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 602 Server Side development hw1c please explain and comment the following node.js code const colors = require('colors'); const EmployeeEmitter = require('./employeeEmitter').EmployeeEmitter; // Usage const

CS 602 Server Side development hw1c please explain and comment the following node.js code

const colors = require('colors');

const EmployeeEmitter = require('./employeeEmitter').EmployeeEmitter;

// Usage const data = [ {id:1, firstName:'John',lastName:'Smith'}, {id:2, firstName:'Jane',lastName:'Smith'}, {id:3, firstName:'John',lastName:'Doe'} ];

const employees = new EmployeeEmitter(data);

employees.on('lookupById', function (args) { console.log(colors.blue('Event lookupById raised! %s'), args); }); employees.on('lookupByLastName', function (args) { console.log(colors.blue('Event lookupByLastName raised! %s'), args); }); employees.on('addEmployee', function (args) { console.log(colors.blue('Event addEmployee raised! %s'), args); });

console.log(" Lookup by last name (Smith)".red); console.log(employees.lookupByLastName('Smith'));

console.log(" Adding employee William Smith".red); employees.addEmployee('William', 'Smith');

console.log(" Lookup by last name (Smith)".red); console.log(employees.lookupByLastName('Smith'));

console.log(" Lookup by id (2)".red); var e2 = employees.lookupById(2); console.log(e2);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

Students also viewed these Databases questions