Skip to content

Instantly share code, notes, and snippets.

View colorincode's full-sized avatar

Kayla B colorincode

  • Color in code
View GitHub Profile
<!--////////////////////////////////////////////////////////////////////////////////////////
/// ///
/// Example Using Three.js Library, HTML, CSS & JavaScript ///
// 3D Interactive Web Apps & Games 2021-2024 ///
/// Contact Shane Brumback https://www.shanebrumback.com ///
/// Send a message if you have questions about this code ///
/// I am a freelance developer. I develop any and all web. ///
/// Apps Websites 3D 2D CMS Systems etc. Contact me anytime :) ///
/// ///
////////////////////////////////////////////////////////////////////////////////////////////-->
// leaving as-is for now
function factorial(n: bigint, x = 1n): bigint {
if (n <= 1) return x;
return factorial(n - 1n, n * x);
}
function factorialAux(n: bigint, x = 1n): bigint | Thunk<bigint> {
if (n <= 1) return x;
return () => factorial(n - 1n, n * x);
}
@colorincode
colorincode / tramp.ts
Created July 11, 2024 18:57 — forked from trvswgnr/tramp.ts
trampoline typescript
/**
* Transforms a function that returns either a direct value or a thunk (a
* no-argument function that returns a value) into a function that only returns
* a direct value. It does this by repeatedly evaluating the function if it
* returns a thunk, until a direct value is obtained.
*
* @template T The type of the value to be returned by the trampoline function.
* @template A The type tuple representing the argument types accepted by the
* function `f`.
* @param f A function that takes arguments of type `A` and returns either a
const { readFileSync, statSync, existsSync } = require('fs')
const mime = require('mime')
const CSSAsset = require(`parcel-bundler/${parseInt(process.versions.node, 10) < 8 ? 'lib' : 'src'}/assets/CSSAsset`)
const { dirname, join, resolve, extname, normalize, relative } = require('path')
const projectRootPath = resolve(__dirname, '../../../')
const parcelrcPath = join(projectRootPath, '.parcelrc')
const getConfig = () => existsSync(parcelrcPath) ? JSON.parse(readFileSync(parcelrcPath))['css-url-loader'] : {}
const EXTS = ['png', 'svg', 'jpg', 'gif', 'jpeg']