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
| function csvWriter(del, enc) { | |
| this.del = del || ','; | |
| this.enc = enc || '"'; | |
| this.escapeCol = (col) => { | |
| if(isNaN(col)) { | |
| if(!col) { | |
| col = ''; | |
| } else { | |
| col = String(col); |
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
| function mixin(receiver, supplier) { | |
| if(Object.getOwnPropertyDescriptor) { | |
| Object.keys(supplier).forEach(function(prop) { | |
| let descriptor = Object.getOwnPropertyDescriptor(supplier, prop); | |
| Object.defineProperty(receiver, prop, descriptor); | |
| }); | |
| } else { // For older browsers, does not support accessor properties | |
| for(let prop in supplier) { | |
| if (supplier.hasOwnProperty(prop) { | |
| receiver[prop] = supplier[prop]; |
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
| function CsvWriter(del, enc) { | |
| this.del = del || ','; | |
| this.enc = enc || '"'; | |
| this.escapeCol = (col) => { | |
| if(isNaN(col)) { | |
| if(!col) { | |
| col = ''; | |
| } else { | |
| col = String(col); |
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
| function roundStrings(s1, s2) { | |
| for (let i in s1) { | |
| if (s1.hasOwnProperty(i)) { | |
| if (s1[i] !== s2[s2.length - i - 1]) { | |
| return -1; | |
| } | |
| } | |
| } | |
| return 1; | |
| } |
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
| function isObjectEqual(a, b) { | |
| let aProps = Object.getOwnPropertyNames(a), | |
| bProps = Object.getOwnPropertyNames(b); | |
| if (aProps.length !== bProps.length) { | |
| return false; | |
| } | |
| for (let i = 0; i < aProps.length; i++) { | |
| let propName = aProps[i]; |
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
| function Stack() { | |
| this._size = 0; | |
| this._storage = {}; | |
| } | |
| Stack.prototype.push = function(data) { | |
| this._size += 1; | |
| this._storage[this._size] = 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
| function Node(data) { | |
| this.data = data; | |
| this.next = null; | |
| } | |
| function SinglyList() { | |
| this._length = 0; | |
| this.head = null; | |
| } |
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
| function Node(value) { | |
| this.data = value; | |
| this.previous = null; | |
| this.next = null; | |
| } | |
| function DoublyList() { | |
| this._length = 0; | |
| this.head = null; | |
| this.tail = null; |
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
| function Queue() { | |
| this._storage = {}; | |
| this._oldestIndex = 1; | |
| this._newestIndex = 1; | |
| } | |
| Queue.prototype.size = function() { | |
| return this._oldestIndex - this._newestIndex; | |
| }; |
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
| function Subject() { | |
| let context = this; | |
| this.observers = []; | |
| return { | |
| subscribeObserver(observer) { | |
| context.observers.push(observer); | |
| }, | |
| unsubscribeObserver(observer) { | |
| const idx = context.observers.indexOf(observer); |