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
| /** | |
| * @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 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
| 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
| #!/usr/bin/env bash | |
| set -e | |
| say() { | |
| local -r msg=$(tr -d "\n" <<<"$@") | |
| local -ir len=${#msg} | |
| local hr pad | |
| printf -v hr -- "-%.0s" $(seq $((len > 40 ? 42 : len + 2))) |
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 log(value, options) { | |
| return console.dir(value, { | |
| showHidden: true, | |
| depth: null, | |
| colors: true, | |
| ...options | |
| }); | |
| } | |
| export function isKey(key) { |
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 memoize = (() => { | |
| const wvm = new WeakValueMap(); | |
| return function (func, hash = JSON.stringify) { | |
| return function () { | |
| const key = hash.apply(this, arguments); | |
| if (wvm.has(key)) { |
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
| class BreakableArray extends Array { | |
| forEach(callbackFn, thisArg) { | |
| let index = 0; | |
| while(index < this.length) { | |
| let _break = false; | |
| callbackFn.call(thisArg, this[i], index, this, () => _break = true); | |
| if(_break) { | |
| break; |
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
| ^([A-Za-z_][A-Za-z0-9_]*)=(?:([^\s'"#]\S*)|(['"])((?:(?!\3)(?:.|\n)|(?<!\\)(?:\\\\)*\\\3)*)\3|())\s*?(?:#.*)?$ |
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
| \ / | |
| \ They're behind / | |
| \ you / | |
| ] [ ,'| | |
| ] [ / | | |
| ]___ ___[ ,' | | |
| ] ]\ /[ [ |: | | |
| ] ] \ / [ [ |: | | |
| ] ] ] [ [ [ |: | | |
| ] ] ]__ __[ [ [ |: | |