@axiosleo/orm-mysql 0.6.2 → 0.6.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/hook.js +13 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
package/src/hook.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const EventEmitter = require('events');
4
4
 
5
- const events = new Map(); // event tree
5
+ const events = {}; // event tree
6
6
  const hook = new EventEmitter();
7
7
 
8
8
  const push = (callback, trace = []) => {
@@ -15,10 +15,10 @@ const push = (callback, trace = []) => {
15
15
  curr_key = '*';
16
16
  }
17
17
  event_name_items.push(curr_key);
18
- if (!curr.has(curr_key)) {
19
- curr.set(curr_key, new Map());
18
+ if (!curr[curr_key]) {
19
+ curr[curr_key] = {};
20
20
  }
21
- curr = curr.get(curr_key);
21
+ curr = curr[curr_key];
22
22
  step++;
23
23
  }
24
24
  let event_name = event_name_items.join('::');
@@ -33,6 +33,14 @@ const pushEvent = (options = {}) => {
33
33
  return { event_name, label, table, opt, callback };
34
34
  };
35
35
 
36
+ /**
37
+ * @param {Map} curr
38
+ * @param {*} trace
39
+ * @param {*} step
40
+ * @param {*} paths
41
+ * @param {*} args
42
+ * @returns
43
+ */
36
44
  const eventRecur = (curr, trace, step, paths, args) => {
37
45
  if (step === trace.length) {
38
46
  hook.emit(paths.join('::'), ...args);
@@ -41,7 +49,7 @@ const eventRecur = (curr, trace, step, paths, args) => {
41
49
  const t = trace[step];
42
50
  if (curr['*']) {
43
51
  paths[step] = '*';
44
- eventRecur(curr[t], trace, step + 1, paths, args);
52
+ eventRecur(curr['*'], trace, step + 1, paths, args);
45
53
  }
46
54
  if (curr[t]) {
47
55
  paths[step] = t;