Skip to content

Instantly share code, notes, and snippets.

View JBoss925's full-sized avatar

JBoss925 JBoss925

View GitHub Profile
@JBoss925
JBoss925 / a-ChainMonad.ts
Last active October 15, 2024 20:58
A typescript implementation of several versions of a Monad that allows a pipe-style application syntax as well as Monad-level logic.
// -------------------------------------------------------------------------------------------------------------------------------------
// This is a basic example of how a framework can be developed to apply a series of transformations in sequence.
// -------------------------------------------------------------------------------------------------------------------------------------
type Chain<T> = {
value: T,
apply: (transform: (value: T) => T) => Chain<T>,
}
function wrap<T>(value: T): Chain<T> {
@JBoss925
JBoss925 / commonOps.ts
Created February 18, 2020 09:17
A promise-based way to resolve firebase firestore references recursively in an object and asynchronously.
// This file contains common operations that will need to be performed often.
import { firestore } from "firebase";
import { isUndefined } from "util";
/**
* This function takes a collection reference and turns it into an array
* of its constituent document references
*
* @param coll the collection to convert into a docref array