Skip to content

Commit

Permalink
feat: Add method Promise.ignore().
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern committed Sep 22, 2024
1 parent 37bc56b commit 4b79e9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Promise.createRace = async function* <T, R>(
}
};

Promise.prototype.ignore = function (this): void {
this.catch();
};

const globals = globalThis as any;
globals.Discord = Discord;
globals.constants = await import("./constants/constants.ts").then((module) => module.default);
5 changes: 5 additions & 0 deletions source/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ declare global {
): AsyncGenerator<{ element: T; result?: R }, void, void>;
}

interface Promise {
/** Ignores the result of the promise. Useful in fire-and-forget situations. */
ignore(): void;
}

interface Array<T> {
/**
* Taking an array, splits it into parts of equal sizes.
Expand Down

0 comments on commit 4b79e9e

Please sign in to comment.