Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-object

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-object - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

README.md

75

lib/util.js

@@ -234,3 +234,78 @@ /** `Object#toString` result shortcuts */

return result;
},
/*
@desc inject the function
@param aOrgFunc the original function to be injected.
@param aBeforeExec this is called before the execution of the aOrgFunc.
you must return the arguments(new Arguments(arguments))
if you wanna modify the arguments value of the aOrgFunc.
it will stop the execution of the aOrgFunc if you return
a value not an Arguments object nor a undefined value
@param aAtferExec this is called after the execution of the aOrgFunc.
you must add a result argument at the last argument of the
aAtferExec function if you wanna get the result value of the aOrgFunc.
you must add a isDenied argument following the result argument if you
wanna know whether the aOrgFunc is executed.
you must return the result if you wanna modify the result value of the aOrgFunc .
@Usage Obj.prototype.Method = inject(Obj.prototype.Method, aFunctionBeforeExec[, aFunctionAtferExec]);
@version 1.1
@author Aimingoo&Riceball
@history
V1.0 -- first released.
V1.1 --
Supports to denie the aOrgFunc execution in aBeforeExec.
Supports around in the aAtferExec, the aAtferExec be always executed even though
denie the aOrgFunc execution in aBeforeExec.
+ isDenied argument to the aAtferExec function. notice the aAtferExec whether
the aOrgFunc is executed
eg:
var doTest = function (a) {return a};
function beforeTest(a) {
alert('before exec: a='+a);
a += 3;
return arguments;
};
function afterTest(a, result, isDenied) {
alert('after exec: a='+a+';result='+result+';isDenied='+isDenied);
return result+5;
};
doTest = inject(doTest, beforeTest, afterTest);
alert (doTest(2));
the result should be 10.
*/
inject: function ( aOrgFunc, aBeforeExec, aAtferExec ) {
var arraySlice = Array.prototype.slice;
return function() {
var Result, isDenied=false, args=arraySlice.call(arguments);
if (typeof(aBeforeExec) === 'function') {
//the result
// * a return value instead of original function.
// * an arguments pass to original function.
// * whether deny the original function.
// * return the arguments to allow execution
// * return undefined to allow execution
Result = aBeforeExec.apply(this, args);
if (util.isArguments(Result)) {
args = arraySlice.call(Result)
}
else if (isDenied = Result !== undefined)
args.push(Result)
}
!isDenied && args.push(aOrgFunc.apply(this, args)); //if (!isDenied) args.push(aOrgFunc.apply(this, args));
if (typeof(aAtferExec) === 'function') {
Result = aAtferExec.apply(this, args.concat(isDenied));
}
else
Result = undefined;
return (Result !== undefined ? Result : args.pop());
}
}
}

2

package.json
{
"name": "abstract-object",
"version": "1.3.5",
"version": "1.3.6",
"description": "AbstractObject with Object State Events Support, RefObject with RefCount and AddRef/Release Support.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/snowyu/abstract-object",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc