Number<Countable> = Either<Countable, Just<0>>
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
import { Result, ResultType } from "./adt"; | |
import { list } from "./primitives"; | |
type Method<T extends any[] = any[], U = any> = U extends any[] | |
? (...arg: T) => Readonly<U> | |
: (...arg: T) => U; | |
type Chained<T extends readonly any[]> = T extends readonly [ | |
infer First extends Method, | |
infer Second extends Method, |
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 s = new Proxy({},{ | |
get(target, prop){ | |
if(!target[prop]) target[prop] = Symbol(); | |
return target[prop]; | |
}, | |
set(){ | |
return false; | |
} | |
}) |
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
class Rrray extends Array { | |
constructor(){ | |
super(...arguments); | |
this.index = {} | |
return new Proxy(this, this.handler); | |
} | |
get handler () { | |
let $self = this; | |
return { | |
get(target, prop, proxy){ |
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
/* | |
Using Es6 Proxies, I created an object that can resolve promises from a chained object accessor pattern. | |
simply await the values, or supply a callback to .then() and watch the magic. | |
*/ | |
Symbol.queue = Symbol("queue"); //using Symbols to hide properties from being used or altered | |
Symbol.data = Symbol("data"); | |
function Promiser( obj ) { | |
return new Proxy(obj, { | |
get(target, prop){ |