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
import net from "net"; | |
import EventEmitter from "events"; | |
const PipeEmitter = class PipeEmitter extends EventEmitter { | |
constructor(pipeName, listen) { | |
super(); | |
this.pipeAddress = "\\\\.\\pipe\\" + pipeName; | |
this.listen = listen; | |
this.server = |
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 CallbackWrapper = class CallbackWrapper { | |
constructor() { | |
this.executor = this._executor.bind(this); | |
this.resolve = | |
this.reject = | |
this.root = | |
this.args = | |
this.memoizedArgs = | |
this.method = 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
"use strict"; | |
const { toString } = Object.prototype; | |
class Queue { | |
constructor(list) { | |
this._clearThreshold = 50; | |
this._offset = 0; | |
this._list = []; | |
this.enqueueIterable(list); |
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"; | |
class GetRequest { | |
constructor(args) { | |
const first = args[0]; | |
if (typeof first !== "string") throw new TypeError("Invalid args"); | |
const slice = first.slice(0, first.indexOf(":")); | |
switch (slice) { | |
case "http": case "https": this.agent = this[slice]; break; | |
default: throw new TypeError("Unknown protocol"); | |
} |
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"; | |
// VERSION 1 | |
// less generic, more performant | |
function fizzBuzz(start = 1, limit = 100) { | |
const result = []; | |
let i3 = start % 3; | |
let i5 = start % 5; | |
while (1) { | |
let str; | |
if (!i3) str = `Fizz`; |
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"; | |
class CaptchaScraper { | |
constructor(key, referer) { this.key = key, this.referer = referer; } | |
then(resolve) { | |
this._https.get( | |
`https://www.google.com/recaptcha/api/fallback?k=${this.key}`, | |
{ headers: { Referer: this.referer } }, | |
resolve | |
); | |
} |
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
if (!Object.fromEntries) { | |
Object.defineProperty(Object, "fromEntries", { | |
value: function fromEntries(iterable) { | |
const obj = {}; | |
for (const pair of iterable) { | |
if (typeof pair !== "object" || pair === null) { | |
throw new TypeError("iterable for fromEntries should yield objects"); | |
} | |
obj[pair[0]] = pair[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
"use strict"; | |
// combine | |
function Combine(...iters) { | |
if (!new.target) { | |
return new Combine(...iters); | |
} | |
const { toString } = arguments; | |
for (const iter of iters) { |
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 isIsogram(s) { | |
var map, str, c, i, l, e, h; | |
if (typeof s !== "string") return false; | |
if ((l = s.length) < 2) return true; | |
c = (str = s.toLowerCase()).codePointAt(); | |
if ((h = c > 0xFFFF) && l < 4) return true; | |
(map = {})[c] = true, e = l - 2, i = +h; | |
do { | |
if (map[c = str.codePointAt(++i)]) return false; | |
if (c > 0xFFFF) if (i === e) return true; else ++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
"use strict"; | |
var pow = Math.pow, | |
floor = Math.floor, | |
powArray = Array(54).map(function(_, i) { return pow(2, i); }); | |
function intersection53() { | |
var map, key, i, j, len, mask, arr, value, n1, n2, b, r, argsLen, result; | |
for (map = {}, i = 0, argsLen = arguments.length; i < argsLen; ++i) { |