Permalink
Browse files

Stop using CoffeeScript for production codes

  • Loading branch information...
1 parent 192a647 commit ee56bd4df27755768b48e5e24580b3c2c5c48b4d @darashi darashi committed Aug 14, 2012
Showing with 0 additions and 51 deletions.
  1. +0 −2 package.json
  2. +0 −49 src/nroonga.coffee
View
2 package.json
@@ -22,8 +22,6 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha --reporter list -r should --compilers coffee:coffee-script",
- "watch": "coffee -c -w -o lib src",
- "coffee": "coffee -c -o lib src",
"install": "node-gyp rebuild"
},
"main": "./lib/nroonga",
View
49 src/nroonga.coffee
@@ -1,49 +0,0 @@
-nroonga = module.exports = require('../build/Release/nroonga_bindings.node')
-msgpack = require('msgpack2')
-
-optionsToCommandString = (command, options) ->
- args = [command]
- if options?
- for key, value of options
- if value?
- args.push '--' + key
- args.push JSON.stringify(value)
- args.join(' ')
-
-overrideOutputType = (optionsGiven, type) ->
- options = {}
- for key, value of optionsGiven
- options[key] = value
- options.output_type = type
- options
-
-formatResult = (result, command) ->
- if command == 'dump'
- result.toString('UTF-8')
- else
- if result.length > 0
- msgpack.unpack(result)
- else
- undefined
-
-nroonga.Database.prototype.commandSync = (command, options={}) ->
- options = overrideOutputType(options, 'msgpack')
- result = this.commandSyncString(optionsToCommandString(command, options))
- formatResult(result, command)
-
-nroonga.Database.prototype.command = (command, options, callback) ->
- if arguments.length == 2
- callback = options
- options = {}
- options = overrideOutputType(options, 'msgpack')
-
- wrappedCallback = if callback?
- (error, data) ->
- if error?
- callback error
- else
- callback undefined, formatResult(data, command)
- else
- undefined
-
- this.commandString optionsToCommandString(command, options), wrappedCallback

0 comments on commit ee56bd4

Please sign in to comment.