neo.mjs 4.0.6 → 4.0.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -112,7 +112,7 @@ class Socket extends Base {
112
112
  onopen : me.onOpen .bind(me)
113
113
  });
114
114
 
115
- NeoFunction.intercept(value, 'send', me.beforeSend, me);
115
+ NeoFunction.createInterceptor(value, 'send', me.beforeSend, me);
116
116
  }
117
117
 
118
118
  return value;
@@ -27,6 +27,22 @@ class NeoFunction extends Base {
27
27
  }
28
28
  }
29
29
 
30
+ /**
31
+ * Intended for functions with 1 param where the interceptor can change the value
32
+ * @param {Object} target
33
+ * @param {String} targetMethodName
34
+ * @param {Function} interceptFunction
35
+ * @param {Object} scope=target
36
+ * @returns {Function}
37
+ */
38
+ static createInterceptor(target, targetMethodName, interceptFunction, scope) {
39
+ let targetMethod = target[targetMethodName];
40
+
41
+ return (target[targetMethodName] = function(value) {
42
+ return targetMethod.call(target, interceptFunction.call(scope || target, value));
43
+ });
44
+ }
45
+
30
46
  /**
31
47
  * @param {Neo.core.Base} target
32
48
  * @param {String} methodName
@@ -44,6 +60,7 @@ class NeoFunction extends Base {
44
60
  }
45
61
 
46
62
  /**
63
+ * The interceptor can prevent the targetMethod from getting executed in case it returns false.
47
64
  * @param {Object} target
48
65
  * @param {String} targetMethodName
49
66
  * @param {Function} interceptFunction