diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-01-06 00:12:53 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-01-06 00:12:53 +0000 |
| commit | 2d98749abf835da29452a233d80cf913485cf134 (patch) | |
| tree | 8a57cc4ae5dc04d17a6c34133843f5bca0d6e6b8 /lib | |
| parent | b8f19a140539e417759f32a89ccfbe89a4a43d0b (diff) | |
Create separate callbackify function
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/browser.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/browser.js b/lib/browser.js index a7f0039..bd34c13 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -7,11 +7,15 @@ exports.readFileInputOnChange = readFileInputOnChange; exports.standardOptions = mammoth.standardOptions; exports.htmlPaths = mammoth.htmlPaths; -exports.convertDocumentToHtml = function() { - var args = Array.slice(arguments, 0, arguments.length - 1); - var callback = arguments[arguments.length - 1]; - satisfyCallback(mammoth.convertDocumentToHtml.apply(this, arguments), callback); -}; +exports.convertDocumentToHtml = callbackify(mammoth.convertDocumentToHtml); + +function callbackify(func) { + return function() { + var args = Array.prototype.slice.call(arguments, 0, arguments.length - 1); + var callback = arguments[arguments.length - 1]; + satisfyCallback(func.apply(this, args), callback); + }; +} function readFileInputOnChange(inputElement, callback) { function handleFileSelect(event) { |
