alemonjs 2.1.19 → 2.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,6 @@ const lazy = (fnc) => {
5
5
  return c;
6
6
  }
7
7
  const mod = await fnc();
8
- console.warn('Lazy load module:', mod);
9
8
  if (!mod || !mod.default) ;
10
9
  c = mod.default;
11
10
  return c;
@@ -4,13 +4,13 @@ import 'path';
4
4
  import 'yaml';
5
5
  import { showErrorModule } from '../core/utils.js';
6
6
 
7
- function isPromise(value) {
8
- return value !== null && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';
9
- }
10
7
  function isAsyncFunction(fn) {
11
8
  const AsyncFunction = (async () => { }).constructor;
12
9
  return fn instanceof AsyncFunction;
13
10
  }
11
+ function isFunction(value) {
12
+ return isAsyncFunction(value) || typeof value === 'function' || value instanceof Function;
13
+ }
14
14
  const createRouteProcessChildren = (valueEvent, select, nextCycle, callHandler) => {
15
15
  const processChildren = (nodes, middleware, next) => {
16
16
  if (!nodes || nodes.length === 0) {
@@ -67,7 +67,7 @@ const createRouteProcessChildren = (valueEvent, select, nextCycle, callHandler)
67
67
  const currents = [];
68
68
  for (const item of currentsAndMiddleware) {
69
69
  const app = await item();
70
- if (isPromise(app) || isAsyncFunction(app)) {
70
+ if (isFunction(app)) {
71
71
  currents.push(app);
72
72
  continue;
73
73
  }
@@ -71,9 +71,9 @@ export declare function createEvent<T extends EventKeys>(options: {
71
71
  regular?: RegExp;
72
72
  prefix?: string;
73
73
  exact?: string;
74
- }): (Events[T] & {
74
+ }): Events[T] & {
75
75
  selects: boolean;
76
76
  regular: boolean;
77
77
  prefix: boolean;
78
78
  exact: boolean;
79
- });
79
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.1.19",
3
+ "version": "2.1.20",
4
4
  "description": "bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",