abetomo
null+****@clear*****
Thu Sep 21 15:56:41 JST 2017
abetomo 2017-09-21 15:56:41 +0900 (Thu, 21 Sep 2017) New Revision: 1d6578abed4ead05fe44cf88d76a092c530d5c24 https://github.com/nroonga/nroonga/commit/1d6578abed4ead05fe44cf88d76a092c530d5c24 Merged 5a6fc95: Merge pull request #28 from abetomo/fix_to_parse_json_with_addon Message: Remove unnecessary code, because no longer need to parse json Modified files: lib/nroonga.js Modified: lib/nroonga.js (+2 -24) =================================================================== --- lib/nroonga.js 2017-09-21 15:51:02 +0900 (774e227) +++ lib/nroonga.js 2017-09-21 15:56:41 +0900 (747464f) @@ -25,43 +25,21 @@ const overrideOutputType = (optionsGiven, type) => { return options } -const formatResult = (result, command) => { - if (command === 'dump') { - return result - } - if (result.length > 0) { - return JSON.parse(result) - } - return null -} - nroonga.Database.prototype.commandSync = function (command, options) { const overridedOptions = overrideOutputType(options || {}, 'json') const commandString = optionsToCommandString(command, overridedOptions) - const result = this.commandSyncString(commandString) - return formatResult(result, command) + return this.commandSyncString(commandString) } nroonga.Database.prototype.command = function (command, options, callback) { - let wrappedCallback = null - if (arguments.length === 2) { callback = options options = {} } - if (callback) { - wrappedCallback = (error, data) => { - if (error) { - return callback(error) - } - return callback(null, formatResult(data, command)) - } - } - const overridedOptions = overrideOutputType(options, 'json') const commandString = optionsToCommandString(command, overridedOptions) - return this.commandString(commandString, wrappedCallback) + return this.commandString(commandString, callback) } -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170921/79c0403c/attachment-0001.htm