Skip to content

Instantly share code, notes, and snippets.

View angrykoala's full-sized avatar
💭
🐨

angrykoala angrykoala

💭
🐨
View GitHub Profile
@angrykoala
angrykoala / cheatsheet.cypher
Created March 12, 2021 09:40
A cheatsheet for Neo4j cypher
/// QUERIES
// Get all nodes
MATCH(n)
RETURN n
// Get all nodes with label
MATCH(m:Movie)
RETURN m
@angrykoala
angrykoala / deferred_promise.ts
Created May 25, 2023 16:21
A promise which execution is deferred until awaited
/** Defers an execution until a promise is awaited */
class DeferredPromise<T = void> extends Promise<T> {
private executor: () => Promise<T>;
private resultPromise: Promise<T> | undefined; // Memoize the promise, to avoid executing the executor twice if awaited twice
constructor(executor: () => Promise<T>) {
super(() => {
// Dummy callback to make Promise happy
});
this.executor = executor;