Skip to content

Instantly share code, notes, and snippets.

View joshuaedwardcrowe's full-sized avatar
🐠
Working on Diagnosea Submarine

Joshua Crowe joshuaedwardcrowe

🐠
Working on Diagnosea Submarine
  • Manchester, United Kingdom
View GitHub Profile
@joshuaedwardcrowe
joshuaedwardcrowe / Debouncer.ts
Created June 17, 2019 16:30
Delay the execution of asynchronous functions.
export class Debouncer {
public promiseGenerator: () => Promise;
public delayInMilliseconds: number;
private timeoutCompleted: bool;
private timeoutCached: () => void;
constructor (generator: () => Promise, delayInMilliseconds: number) {
this.promiseGenerator = generator;
@joshuaedwardcrowe
joshuaedwardcrowe / Spreader.js
Last active September 20, 2018 10:52
Spread an Object
/**
* Spread an object into a Map of properties and their values, so that
* you can call Map.values or Map.keys to spread as needed.
*
* @name Spreader
* @example Spreader({userName: 'soas'}, '*');
* @param {Object} object Object to spread.
* @param {String|Array.<String>} [allowed='*'] Properties to allow.
* @returns {Map<String, Object>} Values in the object by properties.
*/