This file contains hidden or 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
| // Originally from: http://exploringjs.com/es6/ch_generators.html#_example-processing-asynchronously-pushed-data | |
| 'use strict' | |
| const createReadStream = require('fs').createReadStream | |
| function coroutine(generatorFunction) { | |
| return function (...args) { | |
| const generatorObject = generatorFunction(...args); | |
| generatorObject.next() | |
| return generatorObject |
This file contains hidden or 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
| class BinaryTree { | |
| constructor(value, left=null, right=null) { | |
| this.value = value | |
| this.left = left | |
| this.right = right | |
| } | |
| } |
This file contains hidden or 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
| 'use strict'; | |
| var RoundLinkedQueue = function RoundLinkedQueue(maxSize) { | |
| this.maxSize = maxSize; | |
| this.size = 0; | |
| this._root = null; | |
| this._last = null; | |
| } | |
| module.exports = RoundLinkedQueue; |
This file contains hidden or 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
| 'use strict'; | |
| var RoundLinkedQueue = function RoundLinkedQueue(maxSize) { | |
| this.maxSize = maxSize; | |
| this.size = 0; | |
| this._root = null; | |
| this._last = null; | |
| } | |
| module.exports = RoundLinkedQueue; |
This file contains hidden or 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
| 'use strict'; | |
| var RoundLinkedQueue = function RoundLinkedQueue(size) { | |
| } | |
| module.exports = RoundLinkedQueue; | |
| RoundLinkedQueue.prototype.push = function(data) { | |
| }; |
This file contains hidden or 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
| var chai = require('chai'), | |
| expect = chai.expect, | |
| should = chai.should(); | |
| var RoundQueue = require('<round-queue-implementation>'); | |
| describe('Round-Queue', function(){ | |
| describe('When adding elements', function(){ |
This file contains hidden or 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
| var chai = require('chai'), | |
| expect = chai.expect, | |
| should = chai.should(); | |
| var RoundQueue = require('<round-queue-implementation>'); // We'll fix this later | |
| describe('Round-Queue', function(){ | |
| describe('When adding elements', function(){ | |
| it('Should add an element to the end of a non-full queue', function() { | |
| // Queue with max size of 3 |
This file contains hidden or 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
| var chai = require('chai'), | |
| expect = chai.expect, | |
| should = chai.should(); | |
| var RoundQueue = require('<round-queue-implementation>'); // We'll fix this later | |
| describe('Round-Queue', function(){ | |
| }); |
This file contains hidden or 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
| describe('Suite', function() { | |
| describe('Inner Suite', function () { | |
| it('should do something when some condition is met', function () { | |
| }); | |
| }); | |
| }); |
This file contains hidden or 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
| const State = { | |
| PENDING: Symbol.for('pending'), | |
| FULFILLED: Symbol.for('fulfilled'), | |
| REJECTED: Symbol.for('rejected') | |
| }; | |
| function changeState(state) { | |
| if (this.state === state) { | |
| throw new Error('Cannot transition to the same state'); | |
| } |