-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1bdbee
commit fe92bcb
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# programming-problems | ||
|
||
Solutions for various programming problems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Event Emitter | ||
an event emitter is responsible for managing a set of listeners and publishing events to them when it is told such events happened | ||
used in async event driven architecture | ||
API: | ||
addListener | ||
removeListener | ||
removeAllListeners | ||
emit | ||
once | ||
listeners | ||
http://learnjswith.me/build-an-event-emitter-in-javascript/ | ||
*/ | ||
|
||
|
||
|
||
const emitor = new Emitor(); | ||
|
||
const callback = function(x, y) {console.log(x + y)} | ||
const sub = emitor.subscribe('event_1', callback); | ||
|
||
sub.emit('event_1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// implement a method to effieciently exlude items from the items array, as outlined in the exlude array. | ||
|
||
const items = [ | ||
{type: 'computer', color: 'green', flavor: 'apple'}, | ||
{type: 'cellphone', color: 'gold', flavor: 'orange'}, | ||
{type: 'computer', color: 'silver', flavor: 'grape'}, | ||
] | ||
|
||
const exclude = [ | ||
{k: 'type', v: 'cellphone'}, | ||
{k: 'color', v: 'silver'}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Implement an Iterator of Iterators which traverses through an arbitrary number of iterators. IE, an iterator which iterates over three list iterators in the following way: | ||
L1 = a1, a2, a3 | ||
L2 = b1, b2, b3 | ||
L3 = c1, c2, c3 | ||
Then the iterator should process them in this order: | ||
a1, b1, c1, a2, b2, c2, a3, b3, c3 | ||
*/ |