From 2d98749abf835da29452a233d80cf913485cf134 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 6 Jan 2014 00:12:53 +0000 Subject: Create separate callbackify function --- lib/browser.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib') 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) { -- cgit v1.2.3