-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added `Array.toArray` & optimization * chore: updated /lib * refactor: review & improve perfomance * fix: fixed bugs after refactoring * feat: added wrapWithSuspending * chore: removed redundant async contexts
- Loading branch information
Showing
166 changed files
with
8,275 additions
and
5,575 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*! | ||
* V4Fire Core | ||
* https://github.com/V4Fire/Core | ||
* | ||
* Released under the MIT license | ||
* https://github.com/V4Fire/Core/blob/master/LICENSE | ||
*/ | ||
import Super from '../../../core/async/core/core'; | ||
import type { ClearOptions } from '../../../core/async/interface'; | ||
export default class Async<CTX extends object = Async<any>> extends Super<CTX> { | ||
/** | ||
* Clears all asynchronous tasks | ||
* @param [opts] - additional options for the operation | ||
*/ | ||
clearAll(opts?: ClearOptions): this; | ||
/** | ||
* Mutes all asynchronous tasks | ||
* @param [opts] - additional options for the operation | ||
*/ | ||
muteAll(opts?: ClearOptions): this; | ||
/** | ||
* Unmutes all asynchronous tasks | ||
* @param [opts] - additional options for the operation | ||
*/ | ||
unmuteAll(opts?: ClearOptions): this; | ||
/** | ||
* Suspends all asynchronous tasks | ||
* @param [opts] - additional options for the operation | ||
*/ | ||
suspendAll(opts?: ClearOptions): this; | ||
/** | ||
* Unsuspends all asynchronous tasks | ||
* @param [opts] - additional options for the operation | ||
*/ | ||
unsuspendAll(opts?: ClearOptions): this; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _core = _interopRequireDefault(require("../../../core/async/core/core")); | ||
var _const = require("../../../core/async/core/const"); | ||
class Async extends _core.default { | ||
clearAll(opts) { | ||
this.usedNamespaces.forEach((used, i) => { | ||
if (!used) { | ||
return; | ||
} | ||
const key = this.Namespaces[i], | ||
alias = `clear-${key}`.camelize(false); | ||
if (Object.isFunction(this[alias])) { | ||
this[alias](opts); | ||
} else if (!_const.isPromisifyNamespace.test(i)) { | ||
throw new ReferenceError(`The method "${alias}" is not defined`); | ||
} | ||
}); | ||
return this; | ||
} | ||
muteAll(opts) { | ||
this.usedNamespaces.forEach((used, i) => { | ||
if (!used) { | ||
return; | ||
} | ||
const key = this.Namespaces[i], | ||
alias = `mute-${key}`.camelize(false); | ||
if (!_const.isPromisifyNamespace.test(i) && Object.isFunction(this[alias])) { | ||
this[alias](opts); | ||
} | ||
}); | ||
return this; | ||
} | ||
unmuteAll(opts) { | ||
this.usedNamespaces.forEach((used, i) => { | ||
if (!used) { | ||
return; | ||
} | ||
const key = this.Namespaces[i], | ||
alias = `unmute-${key}`.camelize(false); | ||
if (!_const.isPromisifyNamespace.test(i) && Object.isFunction(this[alias])) { | ||
this[alias](opts); | ||
} | ||
}); | ||
return this; | ||
} | ||
suspendAll(opts) { | ||
this.usedNamespaces.forEach((used, i) => { | ||
if (!used) { | ||
return; | ||
} | ||
const key = this.Namespaces[i], | ||
alias = `suspend-${key}`.camelize(false); | ||
if (!_const.isPromisifyNamespace.test(i) && Object.isFunction(this[alias])) { | ||
this[alias](opts); | ||
} | ||
}); | ||
return this; | ||
} | ||
unsuspendAll(opts) { | ||
this.usedNamespaces.forEach((used, i) => { | ||
if (!used) { | ||
return; | ||
} | ||
const key = this.Namespaces[i], | ||
alias = `unsuspend-${key}`.camelize(false); | ||
if (!_const.isPromisifyNamespace.test(i) && Object.isFunction(this[alias])) { | ||
this[alias](opts); | ||
} | ||
}); | ||
return this; | ||
} | ||
} | ||
exports.default = Async; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*! | ||
* V4Fire Core | ||
* https://github.com/V4Fire/Core | ||
* | ||
* Released under the MIT license | ||
* https://github.com/V4Fire/Core/blob/master/LICENSE | ||
*/ | ||
import { Namespaces } from '../../../core/async/const'; | ||
export declare const asyncCounter: unique symbol; | ||
export declare const isZombieGroup: { | ||
test(group: string): boolean; | ||
}; | ||
export declare const isPromisifyNamespace: { | ||
test(namespace: Namespaces): boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.isZombieGroup = exports.isPromisifyNamespace = exports.asyncCounter = void 0; | ||
var _const = require("../../../core/async/const"); | ||
const asyncCounter = Symbol('Async counter id'); | ||
exports.asyncCounter = asyncCounter; | ||
const isZombieGroup = { | ||
test(group) { | ||
return group.includes(':zombie'); | ||
} | ||
}; | ||
exports.isZombieGroup = isZombieGroup; | ||
const isPromisifyNamespace = { | ||
test(namespace) { | ||
return namespace > _const.PromiseNamespaces.first; | ||
} | ||
}; | ||
exports.isPromisifyNamespace = isPromisifyNamespace; |
Oops, something went wrong.