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
export function flow(...fn) { | |
return function (...args) { | |
let ret = fn[0].apply(this, args); | |
let index = 1; | |
let { length } = fn; | |
while (index < length) { | |
ret = fn.call(this, ret); | |
index++; | |
} |
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
export function deepcopy(value) { | |
return __deepcopy(value, new WeakMap()); | |
} | |
export default deepcopy; | |
const TypedArray = Reflect.getPrototypeOf(Int8Array); | |
function identity(value) { | |
return value; |
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
/** | |
* @param {any} value | |
* @param {Set<any> | WeakSet<any>} visited | |
* @returns {boolean} | |
*/ | |
function detect(value, visited) { | |
if ( | |
(typeof value == "object" && value != null) || | |
typeof value == "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
export class Resolvable extends Promise { | |
constructor() { | |
let _resolve; | |
let _reject; | |
super((resolve, reject) => { | |
_resolve = resolve; | |
_reject = reject; | |
}); |
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
#!/usr/bin/env bash | |
read -r -d '' usage <<EOF | |
Usage: | |
random [options] bytes | |
random -h|--help | |
Generate random bytes from /dev/random. | |
Options: |
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 GlobalPromise = global.Promise; | |
// delete global.Promise; | |
function typename(value) { | |
if (typeof value == "object" && typeof value != "null") { | |
let name; | |
try { | |
name = value.constructor?.name; |
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
export function mktable(strings, ...args) { | |
strings = strings[0].split("|"); | |
if (!strings.length || !args.length || args.length % strings.length) { | |
throw new TypeError("Label and argument count do not match"); | |
} | |
const labels = new Set(); | |
const table = new Array(args.length / strings.length) |
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
/* | |
* Copyright (C) 2021 John Hunter Kohler <[email protected]> | |
*/ | |
/** | |
* Returns true if `value` is non-primitive (ECMA script standard, i.e., null is | |
* a primitive, function is an object). | |
* | |
* @param {any} value | |
* @returns {bool} |
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
export class FrozenSet extends Set { | |
clone() { | |
return new FrozenSet(this); | |
} | |
} | |
FrozenSet.prototype.add = undefined; | |
FrozenSet.prototype.delete = undefined; | |
FrozenSet.prototype.clear = undefined; |
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
/* | |
* Copyright (C) 2021 Hunter Kohler <[email protected]> | |
* | |
* WARNING: AUTOGENERATED FILE, DO NOT EDIT DIRECTLY | |
*/ | |
#ifndef REGEX_OPERATORS_H_ | |
#define REGEX_OPERATORS_H_ | |
#include <string> | |
#include <regex> |