@notchjs/core 0.8.4 → 0.8.5

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.
@@ -6,4 +6,5 @@ export declare class HookFactory {
6
6
  prepare(hook: any): HookRecord | HookRecord[];
7
7
  lazy<T>(hook: string | symbol): T;
8
8
  pipeline(hooks: any[]): any[];
9
+ private isClass;
9
10
  }
@@ -17,15 +17,13 @@ class HookFactory {
17
17
  hook: hook,
18
18
  };
19
19
  }
20
+ if (this.isClass(hook)) {
21
+ return {
22
+ name: hook.name,
23
+ hook: new hook(),
24
+ };
25
+ }
20
26
  if ((0, notions_1.isFunction)(hook)) {
21
- const funcAsString = hook.toString();
22
- const isClass = /^class\s/.test(funcAsString);
23
- if (isClass) {
24
- return {
25
- name: hook.name,
26
- hook: new hook(),
27
- };
28
- }
29
27
  return {
30
28
  name: hook.name,
31
29
  hook: hook(),
@@ -45,5 +43,12 @@ class HookFactory {
45
43
  pipeline(hooks) {
46
44
  return hooks.map((hook) => this.prepare(hook));
47
45
  }
46
+ isClass(hook) {
47
+ const hookStr = hook.toString();
48
+ if (hookStr.substring(0, 5) === 'class') {
49
+ return true;
50
+ }
51
+ return false;
52
+ }
48
53
  }
49
54
  exports.HookFactory = HookFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notchjs/core",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "A dependency injection based web framework (Node.js)",
5
5
  "license": "MIT",
6
6
  "author": "Augustus Kamau",
@@ -18,14 +18,14 @@
18
18
  "test": "jest --detectOpenHandles"
19
19
  },
20
20
  "dependencies": {
21
- "@hemjs/notions": "1.0.10",
22
- "@notchjs/util": "^0.8.1",
21
+ "@hemjs/notions": "1.1.0",
22
+ "@notchjs/util": "^0.8.5",
23
23
  "iterare": "1.2.1",
24
- "tslib": "2.7.0"
24
+ "tslib": "2.8.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@notchjs/express": "^0.8.4",
28
- "@notchjs/http": "^0.8.1",
27
+ "@notchjs/express": "^0.8.5",
28
+ "@notchjs/http": "^0.8.5",
29
29
  "@notchjs/types": "^0.8.0"
30
30
  },
31
31
  "homepage": "https://github.com/notchjs/notch",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "cd4ae20df8a9194cc7285c81ff8dcafe574ec038"
45
+ "gitHead": "ebfba8c794edf964f3fe0950fb54df02cd45d8e1"
46
46
  }