Skip to content

Instantly share code, notes, and snippets.

View santigarcor's full-sized avatar

Santiago García santigarcor

View GitHub Profile
<?php
class Match
{
protected $value;
protected $result;
protected $hasMatch;
public function __construct($value)
{
@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {