1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/patches/await-semaphore+0.1.3.patch
Elliot Winkler 4447727eb6
Add TypeScript to the linting process (#13495)
This commit allows developers to write TypeScript files and lint them
(either via a language server in their editor of choice or through the
`yarn lint` command).

The new TypeScript configuration as well as the updated ESLint
configuration not only includes support for parsing TypeScript files,
but also provides some compatibility between JavaScript and TypeScript.
That is, it makes it possible for a TypeScript file that imports a
JavaScript file or a JavaScript file that imports a TypeScript file to
be linted.

Note that this commit does not integrate TypeScript into the build
system yet, so we cannot start converting files to TypeScript and
pushing them to the repo until that final step is complete.
2022-03-21 12:54:47 -06:00

69 lines
1.7 KiB
Diff

diff --git a/node_modules/await-semaphore/index.ts b/node_modules/await-semaphore/index.ts
deleted file mode 100644
index 69ce92a..0000000
--- a/node_modules/await-semaphore/index.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-export class Semaphore {
- private tasks: (() => void)[] = [];
- count: number;
-
- constructor(count: number) {
- this.count = count;
- }
-
- private sched() {
- if (this.count > 0 && this.tasks.length > 0) {
- this.count--;
- let next = this.tasks.shift();
- if (next === undefined) {
- throw "Unexpected undefined value in tasks list";
- }
-
- next();
- }
- }
-
- public acquire() {
- return new Promise<() => void>((res, rej) => {
- var task = () => {
- var released = false;
- res(() => {
- if (!released) {
- released = true;
- this.count++;
- this.sched();
- }
- });
- };
- this.tasks.push(task);
- if (process && process.nextTick) {
- process.nextTick(this.sched.bind(this));
- } else {
- setImmediate(this.sched.bind(this));
- }
- });
- }
-
- public use<T>(f: () => Promise<T>) {
- return this.acquire()
- .then(release => {
- return f()
- .then((res) => {
- release();
- return res;
- })
- .catch((err) => {
- release();
- throw err;
- });
- });
- }
-}
-
-export class Mutex extends Semaphore {
- constructor() {
- super(1);
- }
-}