I am trying to figure out what does cordova/argscheck do. I was not able to find any documentation that describes what is it used for nor how to use it.
我想弄清楚cordova / argscheck做了什么。我无法找到任何描述其用途以及如何使用它的文档。
I managed to find its git repo however no comments are mentioned in the code. I have also taken a look at a couple of plugins and they seem to use it as follows:
我设法找到它的git repo但是代码中没有提到任何评论。我还看了几个插件,他们似乎使用它如下:
Device.prototype.getInfo = function(successCallback, errorCallback) {
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
};
This code has been taken from the Device plugin. Find the git repo here.
此代码取自Device插件。在这里找到git repo。
1 个解决方案
#1
6
I have figured it out is seems that the function is used to check the parameters to make sure that they are one of the following:
我已经想到它似乎该函数用于检查参数,以确保它们是以下之一:
'A'=> 'Array'
'D'=> 'Date'
'N'=> 'Number'
'S'=> 'String'
'F'=> 'Function'
'O'=> 'Object'
'*'=> 'Anything goes'
This check is done to make sure that the java calls that will be called using the exec function will not throw any errors because of bad parameter types.
执行此检查是为了确保使用exec函数调用的java调用不会因为错误的参数类型而抛出任何错误。
#1
6
I have figured it out is seems that the function is used to check the parameters to make sure that they are one of the following:
我已经想到它似乎该函数用于检查参数,以确保它们是以下之一:
'A'=> 'Array'
'D'=> 'Date'
'N'=> 'Number'
'S'=> 'String'
'F'=> 'Function'
'O'=> 'Object'
'*'=> 'Anything goes'
This check is done to make sure that the java calls that will be called using the exec function will not throw any errors because of bad parameter types.
执行此检查是为了确保使用exec函数调用的java调用不会因为错误的参数类型而抛出任何错误。