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
/** | |
* WHATWG ReadableStream <-> Node stream.Readable | |
* @author SourceBoy | |
* @license MIT | |
*/ | |
/** | |
* WHATWG ReadableStream to Node stream.Readable | |
* @param {ReadableStream} rs | |
* @returns {stream.Readable} |
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
/** | |
* sha256 | |
* @param {string} [input=''] | |
* @param {string} [algorithm='SHA-256'] | |
* @returns {Promise<string>} | |
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest} | |
* @author SourceBoy | |
* @license MIT | |
*/ | |
async function sha256(input = '', algorithm = 'SHA-256') { |
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
/** | |
* Run Length Encoding | |
* @author SourceBoy | |
* @license MIT | |
*/ | |
function runlengthEncode(input = '') { | |
const chars = input.split('').concat([' ']); | |
const out = []; | |
let [current] = chars; |
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
/** | |
* Translate ReadableStreamDefaultReader to Node.js stream.Readable | |
* @author SourceBoy | |
* @license MIT | |
*/ | |
async function pump(rs, _rs) { | |
const { done, value } = await rs.read(); | |
if (done) { | |
_rs.push(null); |