Skip to content

Instantly share code, notes, and snippets.

View matthew-dean's full-sized avatar

Matthew Dean matthew-dean

  • Vancouver, BC
View GitHub Profile
@matthew-dean
matthew-dean / methods.ts
Last active October 2, 2023 17:42
Getting all methods of an object - TypeScript version
type Obj = Record<any, any>
const isGetter = (x: Obj, name: string) => Boolean((Object.getOwnPropertyDescriptor(x, name) ?? {})?.get)
const isFunction = (x: Obj, name: string) => typeof x[name] === 'function'
const deepFunctions = (x: Obj): string[] =>
(x && x !== Object.prototype &&
Object.getOwnPropertyNames(x)
.filter(name => isGetter(x, name) || isFunction(x, name))
.concat(deepFunctions(Object.getPrototypeOf(x)) || [])) || []
@matthew-dean
matthew-dean / map.js
Last active July 14, 2016 22:07
Less.js Example for @plugin usage
/**
* This Less.js plugin allows you to create value "maps" with custom at-rules.
* Unlike variables, the maps are global.
*
* This library allows for more dynamic data assignment/retrieval than variables.
*
* Example:
*
@set {
options {