Skip to content

Instantly share code, notes, and snippets.

View iamlothian's full-sized avatar

Matthew Lothian iamlothian

  • Industrie&Co
  • Sydney
View GitHub Profile
@iamlothian
iamlothian / designer.html
Created January 20, 2015 02:58
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../cool-clock/cool-clock.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@iamlothian
iamlothian / profilingUtils.ts
Last active October 2, 2019 07:11
wrap any object, function or class method in a proxy that will expose pre and post handlers with a built in timer
export type preFunc<T> = (target: T, propertyName: keyof T, args: any[], receiver: any) => void;
export type postFunc<T> = (target: T, propertyName: keyof T, args: any[], result: any, didError: boolean, duration: number, receiver: any) => void;
function postDefault<T extends object>(target: T, propertyName: keyof T, args: any[], result: any, didError: boolean, duration: number, receiver: any) {
console.log(`${target.constructor.name}.${propertyName.toString()} - duration: ${duration}ms ${didError ? '[with Error]' : ''}`);
}
/**
* wrap any object in a proxy that will expose pre and post handlers with a built in timer
* @param source the object to proxy