Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speddup #436

Merged
merged 33 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1e97a3c
feat: added `Array.toArray` & optimization
kobezzza Aug 23, 2024
8fd13fa
chore: updated /lib
kobezzza Aug 23, 2024
11e6de3
chore: optimization
kobezzza Aug 23, 2024
4cc4500
chore: optimization
kobezzza Aug 23, 2024
e38b38f
chore: fixed spec
kobezzza Aug 26, 2024
4b9fe82
chore: optimization
kobezzza Aug 26, 2024
eb4629f
chore: fixed eslint
kobezzza Aug 26, 2024
472cd2c
refactor: review & improve perfomance
kobezzza Aug 27, 2024
57a7470
fix: fixed bugs after refactoring & performance
kobezzza Aug 27, 2024
0ac0b7e
fix: fixed bugs after refactoring
kobezzza Aug 27, 2024
47d7533
fix: fixed bugs after refactoring
kobezzza Aug 27, 2024
b121029
fix: fixed bugs after refactoring
kobezzza Aug 27, 2024
2d6665e
fix: fixed bugs after refactoring
kobezzza Aug 27, 2024
f3c8133
fix: fixed bugs after refactoring
kobezzza Aug 27, 2024
4618a7f
feat: added wrapWithSuspending
kobezzza Aug 27, 2024
b40763f
chore: refactoring
kobezzza Aug 28, 2024
d835660
chore: optimization
kobezzza Aug 28, 2024
8ecb476
chore: fixes TS
kobezzza Aug 28, 2024
9bb97ef
refactor: better naming & structure
kobezzza Aug 28, 2024
5d3e2c0
refactor: improved doc
kobezzza Aug 28, 2024
8740500
chore: optimization
kobezzza Aug 28, 2024
5a99125
chore: rebuild /lib
kobezzza Aug 28, 2024
0fac26d
chore: reverted refactoring
kobezzza Aug 29, 2024
5fee52d
chore: fixes after refactoring
kobezzza Aug 29, 2024
db2d9b3
chore: fixes after refactoring
kobezzza Aug 29, 2024
587449c
chore: fixes after refactoring
kobezzza Aug 29, 2024
9e24fe9
chore: stylish fixes
kobezzza Aug 29, 2024
e16ae00
chore: stylish fixes
kobezzza Aug 29, 2024
2c0e913
chore: updated log
kobezzza Sep 3, 2024
7990130
chore: removed redundant async contexts
kobezzza Sep 10, 2024
301122b
Merge remote-tracking branch 'origin/v4' into speedup
kobezzza Sep 19, 2024
c11c830
chore: rebuild lib
kobezzza Sep 19, 2024
967eedf
Merge remote-tracking branch 'origin/v4' into speedup
kobezzza Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .tsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"strictPropertyInitialization": true,

"noImplicitOverride": true,
"importsNotUsedAsValues": "error"
"importsNotUsedAsValues": "error",

"isolatedModules": false
},

"include": [
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.?? (2024-??-??)

#### :boom: Breaking Change

* `core/async`:
* Moved code from `V4/Client`
* Removed deprecated API and refactored internal structures

#### :rocket: New Feature

* Added a new method `Array.toArray` `core/prelude`
* Added support for baked symbols `core/symbol`

#### :house: Internal

* Conduct refactoring and optimization of the module `core/async`
* Various performance optimizations

## v4.0.0-alpha.46 (2024-09-25)

#### :boom: breaking change
Expand Down
88 changes: 48 additions & 40 deletions lib/core/async/const.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,51 @@
* Released under the MIT license
* https://github.com/V4Fire/Core/blob/master/LICENSE
*/
export declare const namespaces: {
[x: number]: number;
readonly proxy: "proxy";
readonly proxyPromise: "proxyPromise";
readonly promise: "promise";
readonly iterable: "iterable";
readonly request: "request";
readonly idleCallback: "idleCallback";
readonly idleCallbackPromise: "idleCallbackPromise";
readonly timeout: "timeout";
readonly timeoutPromise: "timeoutPromise";
readonly interval: "interval";
readonly intervalPromise: "intervalPromise";
readonly immediate: "immediate";
readonly immediatePromise: "immediatePromise";
readonly worker: "worker";
readonly eventListener: "eventListener";
readonly eventListenerPromise: "eventListenerPromise";
},
/** @deprecated */
linkNamesDictionary: {
[x: number]: number;
readonly proxy: "proxy";
readonly proxyPromise: "proxyPromise";
readonly promise: "promise";
readonly iterable: "iterable";
readonly request: "request";
readonly idleCallback: "idleCallback";
readonly idleCallbackPromise: "idleCallbackPromise";
readonly timeout: "timeout";
readonly timeoutPromise: "timeoutPromise";
readonly interval: "interval";
readonly intervalPromise: "intervalPromise";
readonly immediate: "immediate";
readonly immediatePromise: "immediatePromise";
readonly worker: "worker";
readonly eventListener: "eventListener";
readonly eventListenerPromise: "eventListenerPromise";
};
export declare type NamespacesDictionary = typeof namespaces;
export declare enum Namespaces {
proxy = 0,
promise = 1,
iterable = 2,
request = 3,
idleCallback = 4,
timeout = 5,
interval = 6,
immediate = 7,
worker = 8,
eventListener = 9,
animationFrame = 10,
proxyPromise = 11,
timeoutPromise = 12,
intervalPromise = 13,
immediatePromise = 14,
idleCallbackPromise = 15,
animationFramePromise = 16,
eventListenerPromise = 17,
length = 18
}
export declare const enum PrimitiveNamespaces {
proxy = 0,
promise = 1,
iterable = 2,
request = 3,
idleCallback = 4,
timeout = 5,
interval = 6,
immediate = 7,
worker = 8,
eventListener = 9,
animationFrame = 10,
length = 11
}
export declare const enum PromiseNamespaces {
first = 10,
proxyPromise = 11,
timeoutPromise = 12,
intervalPromise = 13,
immediatePromise = 14,
idleCallbackPromise = 15,
animationFramePromise = 16,
eventListenerPromise = 17,
length = 18
}
export declare const usedNamespaces: any[];
export declare const namespacesCache: any[];
63 changes: 57 additions & 6 deletions lib/core/async/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,60 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.namespaces = exports.linkNamesDictionary = void 0;
var _interface = require("../../core/async/interface");
const namespaces = Object.convertEnumToDict(_interface.Namespaces),
linkNamesDictionary = namespaces;
exports.linkNamesDictionary = linkNamesDictionary;
exports.namespaces = namespaces;
exports.usedNamespaces = exports.namespacesCache = exports.PromiseNamespaces = exports.PrimitiveNamespaces = exports.Namespaces = void 0;
let Namespaces = function (Namespaces) {
Namespaces[Namespaces["proxy"] = 0] = "proxy";
Namespaces[Namespaces["promise"] = 1] = "promise";
Namespaces[Namespaces["iterable"] = 2] = "iterable";
Namespaces[Namespaces["request"] = 3] = "request";
Namespaces[Namespaces["idleCallback"] = 4] = "idleCallback";
Namespaces[Namespaces["timeout"] = 5] = "timeout";
Namespaces[Namespaces["interval"] = 6] = "interval";
Namespaces[Namespaces["immediate"] = 7] = "immediate";
Namespaces[Namespaces["worker"] = 8] = "worker";
Namespaces[Namespaces["eventListener"] = 9] = "eventListener";
Namespaces[Namespaces["animationFrame"] = 10] = "animationFrame";
Namespaces[Namespaces["proxyPromise"] = 11] = "proxyPromise";
Namespaces[Namespaces["timeoutPromise"] = 12] = "timeoutPromise";
Namespaces[Namespaces["intervalPromise"] = 13] = "intervalPromise";
Namespaces[Namespaces["immediatePromise"] = 14] = "immediatePromise";
Namespaces[Namespaces["idleCallbackPromise"] = 15] = "idleCallbackPromise";
Namespaces[Namespaces["animationFramePromise"] = 16] = "animationFramePromise";
Namespaces[Namespaces["eventListenerPromise"] = 17] = "eventListenerPromise";
Namespaces[Namespaces["length"] = 18] = "length";
return Namespaces;
}({});
exports.Namespaces = Namespaces;
let PrimitiveNamespaces = function (PrimitiveNamespaces) {
PrimitiveNamespaces[PrimitiveNamespaces["proxy"] = 0] = "proxy";
PrimitiveNamespaces[PrimitiveNamespaces["promise"] = 1] = "promise";
PrimitiveNamespaces[PrimitiveNamespaces["iterable"] = 2] = "iterable";
PrimitiveNamespaces[PrimitiveNamespaces["request"] = 3] = "request";
PrimitiveNamespaces[PrimitiveNamespaces["idleCallback"] = 4] = "idleCallback";
PrimitiveNamespaces[PrimitiveNamespaces["timeout"] = 5] = "timeout";
PrimitiveNamespaces[PrimitiveNamespaces["interval"] = 6] = "interval";
PrimitiveNamespaces[PrimitiveNamespaces["immediate"] = 7] = "immediate";
PrimitiveNamespaces[PrimitiveNamespaces["worker"] = 8] = "worker";
PrimitiveNamespaces[PrimitiveNamespaces["eventListener"] = 9] = "eventListener";
PrimitiveNamespaces[PrimitiveNamespaces["animationFrame"] = 10] = "animationFrame";
PrimitiveNamespaces[PrimitiveNamespaces["length"] = 11] = "length";
return PrimitiveNamespaces;
}({});
exports.PrimitiveNamespaces = PrimitiveNamespaces;
let PromiseNamespaces = function (PromiseNamespaces) {
PromiseNamespaces[PromiseNamespaces["first"] = 10] = "first";
PromiseNamespaces[PromiseNamespaces["proxyPromise"] = 11] = "proxyPromise";
PromiseNamespaces[PromiseNamespaces["timeoutPromise"] = 12] = "timeoutPromise";
PromiseNamespaces[PromiseNamespaces["intervalPromise"] = 13] = "intervalPromise";
PromiseNamespaces[PromiseNamespaces["immediatePromise"] = 14] = "immediatePromise";
PromiseNamespaces[PromiseNamespaces["idleCallbackPromise"] = 15] = "idleCallbackPromise";
PromiseNamespaces[PromiseNamespaces["animationFramePromise"] = 16] = "animationFramePromise";
PromiseNamespaces[PromiseNamespaces["eventListenerPromise"] = 17] = "eventListenerPromise";
PromiseNamespaces[PromiseNamespaces["length"] = 18] = "length";
return PromiseNamespaces;
}({});
exports.PromiseNamespaces = PromiseNamespaces;
const usedNamespaces = new Array(Namespaces.length).fill(false);
exports.usedNamespaces = usedNamespaces;
const namespacesCache = new Array(Namespaces.length).fill(null);
exports.namespacesCache = namespacesCache;
36 changes: 36 additions & 0 deletions lib/core/async/core/api.d.ts
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;
}
79 changes: 79 additions & 0 deletions lib/core/async/core/api.js
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;
15 changes: 15 additions & 0 deletions lib/core/async/core/const.d.ts
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;
};
21 changes: 21 additions & 0 deletions lib/core/async/core/const.js
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;
Loading
Loading