diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 00000000..0c992ad4 --- /dev/null +++ b/lib/utils.js @@ -0,0 +1,14 @@ +var utils = { + /* + * Takes a dot-notation object string and call the function + * that it points to with the correct value for 'this'. + */ + invokeCommandString: function(str, argArray) { + var components = str.split('.'); + var obj = window; + for (var i = 0; i < components.length - 1; i++) + obj = obj[components[i]]; + var func = obj[components.pop()]; + return func.apply(obj, argArray); + }, +}; |
