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
// +by shift left | |
// -by shift right | |
const shiftArray = (arr, by) => { | |
const _by = (by | 0) % arr.length; | |
const rest = by > 0 ? arr.slice(0, _by) : arr.slice(_by); | |
return arr.map( | |
(_, i) => arr[i + _by] !== undefined | |
? arr[i + _by] | |
: rest.shift() | |
); |
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
const { spawn } = require("child_process"); | |
const { Readable, Duplex, Writable } = require("stream"); | |
const wrapRS = txt => { | |
const r = new Readable(); | |
r._read = () => { | |
r.push(txt); | |
r.push(null); | |
}; | |
return r; |
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
/** | |
* nanoWS | |
* A very basic websocket client. Its does not fully cover rfc6455 so | |
* it must not used for any real world work. I wrote it to find out | |
* how websockets actually worked. | |
* | |
* @licence MIT | |
* @author Jewel Mahanta <jewelmahanta@gmail.com> | |
*/ |
OlderNewer