Skip to content

Instantly share code, notes, and snippets.

View fitsallun's full-sized avatar

Jonathon Armstrong fitsallun

View GitHub Profile
@jpiccari
jpiccari / constructorFactory.js
Last active August 29, 2015 14:02
Factory for creating constructors that don't require new keywords with minimal boilerplate.
/**
* Factory to take some of the boilerplate out of creating constructors
* which instantiate objects even without the new keyword.
* @param {function} fn - Input function to create constructor from.
* @returns The updated constructor.
*/
function constructorFactory(fn) {
if (typeof fn !== 'function') {
throw new TypeError('Expected function!');
}
@blargism
blargism / basic-wc-with-lit-html.js
Last active October 4, 2022 11:56
Basic Web Component with lit-html
import { html, render } from 'lit-html';
export default class ComponentClass extends HTMLElement {
constructor() {
super();
// set sane defaults if desired.
this._value = null;
}
get values() {