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
package/src/util/Function.mjs
CHANGED
|
@@ -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
|