Skip to content

Instantly share code, notes, and snippets.

View remojansen's full-sized avatar

Remo H. Jansen remojansen

View GitHub Profile
@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@remojansen
remojansen / keybase.md
Created February 17, 2017 00:14
keybase.md

Keybase proof

I hereby claim:

  • I am remojansen on github.
  • I am remojansen (https://keybase.io/remojansen) on keybase.
  • I have a public key whose fingerprint is 95CF 4000 58A6 7EBF D965 2C32 C2E7 7CC5 4C37 06E7

To claim this, I am signing this object:

@remojansen
remojansen / lib.ts
Last active August 15, 2024 13:26
"attempt" TypeScript "try" utility
class Result<T, E = Error> {
constructor(
private v: T | undefined,
private e: E | undefined
) {}
onSuccess(cb: (v: T) => void) {
if (this.v !== undefined) {
cb(this.v as T);
}
}