Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = React.createClass
  displayName: 'snippet-editor'
  mixins: [ PureRenderMixin ]

  propTypes:
    _toId: T.string
    _roomId: T.string
    _teamId: T.string
    _storyId: T.string
    draftMode: T.bool
    onClose: T.func.isRequired
    onSubmit: T.func.isRequired
    attachment: T.object

  getInitialState: ->
    data: Immutable.fromJS
      text: @props.attachment?.text or ''
      title: @props.attachment?.title or ''
      codeType: @props.attachment?.codeType or 'txt'

  componentDidMount: ->
    lazyModules.ensureCodeEditor =>
      isLoadedCodeEditor = true
      @debounceSaveDraft = debounce @saveDraft, 500
      @forceUpdate()

  componentWillUnmount: ->
    @debounceSaveDraft = null

  saveDraft: (snippetDraft) ->
    _channelId = @props._roomId or @props._toId or @props._storyId
    hasDraft = @state.data.get('text').length or @state.data.get('title').length

    if _channelId?
      if hasDraft
        draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()
      else
        draftActions.clearSnippet @props._teamId, _channelId

  saveState: (data) ->
    @setState
      data: data
    , =>
      @debounceSaveDraft data

  handleEditorChange: (text) ->
    data = @state.data.set 'text', text
    @saveState data

  handleSelectorChange: (codeType) ->
```

Response:
module.exports = React.createClass({
  displayName: 'snippet-editor',
  mixins: [PureRenderMixin],
  propTypes: {
    _toId: T.string,
    _roomId: T.string,
    _teamId: T.string,
    _storyId: T.string,
    draftMode: T.bool,
    onClose: T.func.isRequired,
    onSubmit: T.func.isRequired,
    attachment: T.object
  },
  getInitialState: function() {
    var ref, ref1, ref2;
    return {
      data: Immutable.fromJS({
        text: ((ref = this.props.attachment) != null ? ref.text : void 0) || '',
        title: ((ref1 = this.props.attachment) != null ? ref1.title : void 0) || '',
        codeType: ((ref2 = this.props.attachment) != null ? ref2.codeType : void 0) || 'txt'
      })
    };
  },
  componentDidMount: function() {
    return lazyModules.ensureCodeEditor(() => {
      var isLoadedCodeEditor;
      isLoadedCodeEditor = true;
      this.debounceSaveDraft = debounce(this.saveDraft, 500);
      return this.forceUpdate();
    });
  },
  componentWillUnmount: function() {
    return this.debounceSaveDraft = null;
  },
  saveDraft: function(snippetDraft) {
    var _channelId, hasDraft;
    _channelId = this.props._roomId || this.props._toId || this.props._storyId;
    hasDraft = this.state.data.get('text').length || this.state.data.get('title').length;
    if (_channelId != null) {
      if (hasDraft) {
        return draftActions.saveSnippet(this.props._teamId, _channelId, snippetDraft.toJS());
      } else {
        return draftActions.clearSnippet(this.props._teamId, _channelId);
      }
    }
  },
  saveState: function(data) {
    return this.setState({
      data: data
    }, () => {
      return this.debounceSaveDraft(data);
    });
  },
  handleEditorChange: function(text) {
    var data;
    data = this.state.data.set('text', text);
    return this.saveState(data);
  },
  handleSelectorChange: function(codeType) {}
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
module.exports = React.createClass({
  displayName: 'snippet-editor',
  mixins: [PureRenderMixin],
  propTypes: {
    _toId: T.string,
    _roomId: T.string,
    _teamId: T.string,
    _storyId: T.string,
    draftMode: T.bool,
    onClose: T.func.isRequired,
    onSubmit: T.func.isRequired,
    attachment: T.object
  },
  getInitialState: function() {
    var ref, ref1, ref2;
    return {
      data: Immutable.fromJS({
        text: ((ref = this.props.attachment) != null ? ref.text : void 0) || '',
        title: ((ref1 = this.props.attachment) != null ? ref1.title : void 0) || '',
        codeType: ((ref2 = this.props.attachment) != null ? ref2.codeType : void 0) || 'txt'
      })
    };
  },
  componentDidMount: function() {
    return lazyModules.ensureCodeEditor(() => {
      var isLoadedCodeEditor;
      isLoadedCodeEditor = true;
      this.debounceSaveDraft = debounce(this.saveDraft, 500);
      return this.forceUpdate();
    });
  },
  componentWillUnmount: function() {
    return this.debounceSaveDraft = null;
  },
  saveDraft: function(snippetDraft) {
    var _channelId, hasDraft;
    _channelId = this.props._roomId || this.props._toId || this.props._storyId;
    hasDraft = this.state.data.get('text').length || this.state.data.get('title').length;
    if (_channelId != null) {
      if (hasDraft) {
        return draftActions.saveSnippet(this.props._teamId, _channelId, snippetDraft.toJS());
      } else {
        return draftActions.clearSnippet(this.props._teamId, _channelId);
      }
    }
  },
  saveState: function(data) {
    return this.setState({
      data: data
    }, () => {
      return this.debounceSaveDraft(data);
    });
  },
  handleEditorChange: function(text) {
    var data;
    data = this.state.data.set('text', text);
    return this.saveState(data);
  },
  handleSelectorChange: function(codeType) {}
});
```

Response:
module.exports = React.createClass
  displayName: 'snippet-editor'
  mixins: [ PureRenderMixin ]

  propTypes:
    _toId: T.string
    _roomId: T.string
    _teamId: T.string
    _storyId: T.string
    draftMode: T.bool
    onClose: T.func.isRequired
    onSubmit: T.func.isRequired
    attachment: T.object

  getInitialState: ->
    data: Immutable.fromJS
      text: @props.attachment?.text or ''
      title: @props.attachment?.title or ''
      codeType: @props.attachment?.codeType or 'txt'

  componentDidMount: ->
    lazyModules.ensureCodeEditor =>
      isLoadedCodeEditor = true
      @debounceSaveDraft = debounce @saveDraft, 500
      @forceUpdate()

  componentWillUnmount: ->
    @debounceSaveDraft = null

  saveDraft: (snippetDraft) ->
    _channelId = @props._roomId or @props._toId or @props._storyId
    hasDraft = @state.data.get('text').length or @state.data.get('title').length

    if _channelId?
      if hasDraft
        draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()
      else
        draftActions.clearSnippet @props._teamId, _channelId

  saveState: (data) ->
    @setState
      data: data
    , =>
      @debounceSaveDraft data

  handleEditorChange: (text) ->
    data = @state.data.set 'text', text
    @saveState data

  handleSelectorChange: (codeType) ->


Prompt:
module.exports = React.createClass
  displayName: 'snippet-editor'
  mixins: [ PureRenderMixin ]

  propTypes:
    _toId: T.string
    _roomId: T.string
    _teamId: T.string
    _storyId: T.string
    draftMode: T.bool
    onClose: T.func.isRequired
    onSubmit: T.func.isRequired
    attachment: T.object

  getInitialState: ->
    data: Immutable.fromJS
      text: @props.attachment?.text or ''
      title: @props.attachment?.title or ''
      codeType: @props.attachment?.codeType or 'txt'

  componentDidMount: ->
    lazyModules.ensureCodeEditor =>
      isLoadedCodeEditor = true
      @debounceSaveDraft = debounce @saveDraft, 500
      @forceUpdate()

Response:
componentWillUnmount: ->
    @debounceSaveDraft = null

  saveDraft: (snippetDraft) ->
    _channelId = @props._roomId or @props._toId or @props._storyId
    hasDraft = @state.data.get('text').length or @state.data.get('title').length

    if _channelId?
      if hasDraft
        draftActions.saveSnippet @props._teamId, _channelId, snippetDraft.toJS()
      else
        draftActions.clearSnippet @props._teamId, _channelId

  saveState: (data) ->
    @setState
      data: data
    , =>
      @debounceSaveDraft data

  handleEditorChange: (text) ->
    data = @state.data.set 'text', text
    @saveState data

  handleSelectorChange: (codeType) ->


Response:
data = @state.data.set 'codeType', codeType
    @saveState data

  handleTitleChange: (event) ->
    data = @state.data.set 'title', event.target.value
    @saveState data

  onSubmit: ->
    isEmpty = @state.data.get('text')?.trim().length is 0

    if isEmpty
      notifyActions.error lang.getText 'snippet-send-empty'
      return

    @props.onSubmit @state.data.toJS()

  renderCodeEditor: ->
    codeEditor = lazyModules.load 'code-editor'

    codeEditor
      text: @state.data.get 'text'
      codeType: snippetUtil.getCodemirror @state.data.get 'codeType'
      onChange: @handleEditorChange
      placeholder: lang.getText 'snippet-editor-placeholder'

  renderSelector: ->
    snippetSelector = lazyModules.load 'snippet-selector'

    snippetSelector
      onClick: @handleSelectorChange
      codeType: @state.data.get 'codeType'
      codeAssets: snippetUtil.getAssets()

  renderTitle: ->
    div className: 'title',
      input
        type: 'text', className: 'input'
        onChange: @handleTitleChange
        placeholder: lang.getText 'snippet-editor-title-placeholder'
        defaultValue: @state.data.get 'title'

  render: ->
    return null if not isLoadedCodeEditor

    isEmpty = @state.data.get('text')?.trim().length is 0
    buttonClassName = cx 'button',
      'is-primary': not isEmpty
      'is-disabled': isEmpty

    div className: 'snippet-editor', onClick: @onClick,


Prompt:
data = @state.data.set 'codeType', codeType
    @saveState data

  handleTitleChange: (event) ->
    data = @state.data.set 'title', event.target.value
    @saveState data

  onSubmit: ->
    isEmpty = @state.data.get('text')?.trim().length is 0

    if isEmpty
      notifyActions.error lang.getText 'snippet-send-empty'
      return

    @props.onSubmit @state.data.toJS()

  renderCodeEditor: ->
    codeEditor = lazyModules.load 'code-editor'

    codeEditor
      text: @state.data.get 'text'
      codeType: snippetUtil.getCodemirror @state.data.get 'codeType'
      onChange: @handleEditorChange
      placeholder: lang.getText 'snippet-editor-placeholder'

Response:
renderSelector: ->
    snippetSelector = lazyModules.load 'snippet-selector'

    snippetSelector
      onClick: @handleSelectorChange
      codeType: @state.data.get 'codeType'
      codeAssets: snippetUtil.getAssets()

  renderTitle: ->
    div className: 'title',
      input
        type: 'text', className: 'input'
        onChange: @handleTitleChange
        placeholder: lang.getText 'snippet-editor-title-placeholder'
        defaultValue: @state.data.get 'title'

  render: ->
    return null if not isLoadedCodeEditor

    isEmpty = @state.data.get('text')?.trim().length is 0
    buttonClassName = cx 'button',
      'is-primary': not isEmpty
      'is-disabled': isEmpty

    div className: 'snippet-editor', onClick: @onClick,


Response:
div className: 'header line',
        lang.getText 'snippet-editor'
        Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose
      div className: 'body',
        @renderTitle()
        @renderCodeEditor()
      div ref: 'footer', className: 'footer',
        @renderSelector()
        div className: 'buttons line',
          button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,
            if @props.draftMode
              lang.getText 'send'
            else
              lang.getText 'save'


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
div className: 'header line',
        lang.getText 'snippet-editor'
        Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose
      div className: 'body',
        @renderTitle()
        @renderCodeEditor()
      div ref: 'footer', className: 'footer',
        @renderSelector()
        div className: 'buttons line',
          button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,
            if @props.draftMode
              lang.getText 'send'
            else
              lang.getText 'save'
```

Response:
div({
  className: 'header line'
}, lang.getText('snippet-editor'), Icon({
  name: 'remove',
  className: 'button-close',
  size: 20,
  onClick: this.props.onClose
}));

div({
  className: 'body'
}, this.renderTitle(), this.renderCodeEditor());

div({
  ref: 'footer',
  className: 'footer'
}, this.renderSelector(), div({
  className: 'buttons line'
}, button({
  className: buttonClassName,
  onClick: this.onSubmit,
  disabled: isEmpty
}, this.props.draftMode ? lang.getText('send') : lang.getText('save'))));


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
div({
  className: 'header line'
}, lang.getText('snippet-editor'), Icon({
  name: 'remove',
  className: 'button-close',
  size: 20,
  onClick: this.props.onClose
}));

div({
  className: 'body'
}, this.renderTitle(), this.renderCodeEditor());

div({
  ref: 'footer',
  className: 'footer'
}, this.renderSelector(), div({
  className: 'buttons line'
}, button({
  className: buttonClassName,
  onClick: this.onSubmit,
  disabled: isEmpty
}, this.props.draftMode ? lang.getText('send') : lang.getText('save'))));
```

Response:
div className: 'header line',
        lang.getText 'snippet-editor'
        Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose
      div className: 'body',
        @renderTitle()
        @renderCodeEditor()
      div ref: 'footer', className: 'footer',
        @renderSelector()
        div className: 'buttons line',
          button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,
            if @props.draftMode
              lang.getText 'send'
            else
              lang.getText 'save'


Prompt:
div className: 'header line',
        lang.getText 'snippet-editor'
        Icon name: 'remove', className: 'button-close', size: 20, onClick: @props.onClose
      div className: 'body',
        @renderTitle()
        @renderCodeEditor()
      div ref: 'footer', className: 'footer',

Response:
@renderSelector()
        div className: 'buttons line',
          button className: buttonClassName, onClick: @onSubmit, disabled: isEmpty,
            if @props.draftMode
              lang.getText 'send'
            else
              lang.getText 'save'


Response:
### Improved Euler Integrator ###

class ImprovedEuler extends Integrator

    # x += (v * dt) + (a * 0.5 * dt * dt)
    # v += a * dt

    integrate: (particles, dt, drag) ->

        acc = new Vector()
        vel = new Vector()

        dtSq = dt * dt

        for p in particles when not p.fixed

            # Store previous location.
            p.old.pos.copy p.pos

            # Scale force to mass.
            p.acc.scale p.massInv

            # Duplicate velocity to preserve momentum.
            vel.copy p.vel

            # Duplicate force.
            acc.copy p.acc

            # Update position.
            p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)

            # Update velocity.
            p.vel.add p.acc.scale dt

            # Apply friction.
            if drag then p.vel.scale drag

            # Reset forces.
            p.acc.clear()


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
### Improved Euler Integrator ###

class ImprovedEuler extends Integrator

    # x += (v * dt) + (a * 0.5 * dt * dt)
    # v += a * dt

    integrate: (particles, dt, drag) ->

        acc = new Vector()
        vel = new Vector()

        dtSq = dt * dt

        for p in particles when not p.fixed

            # Store previous location.
            p.old.pos.copy p.pos

            # Scale force to mass.
            p.acc.scale p.massInv

            # Duplicate velocity to preserve momentum.
            vel.copy p.vel

            # Duplicate force.
            acc.copy p.acc

            # Update position.
            p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)

            # Update velocity.
            p.vel.add p.acc.scale dt

            # Apply friction.
            if drag then p.vel.scale drag

            # Reset forces.
            p.acc.clear()
```

Response:
/* Improved Euler Integrator */
var ImprovedEuler;

ImprovedEuler = class ImprovedEuler extends Integrator {
  // x += (v * dt) + (a * 0.5 * dt * dt)
  // v += a * dt
  integrate(particles, dt, drag) {
    var acc, dtSq, i, len, p, results, vel;
    acc = new Vector();
    vel = new Vector();
    dtSq = dt * dt;
    results = [];
    for (i = 0, len = particles.length; i < len; i++) {
      p = particles[i];
      if (!(!p.fixed)) {
        continue;
      }
      // Store previous location.
      p.old.pos.copy(p.pos);
      // Scale force to mass.
      p.acc.scale(p.massInv);
      // Duplicate velocity to preserve momentum.
      vel.copy(p.vel);
      // Duplicate force.
      acc.copy(p.acc);
      // Update position.
      p.pos.add((vel.scale(dt)).add(acc.scale(0.5 * dtSq)));
      // Update velocity.
      p.vel.add(p.acc.scale(dt));
      // Apply friction.
      if (drag) {
        p.vel.scale(drag);
      }
      // Reset forces.
      results.push(p.acc.clear());
    }
    return results;
  }

};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
/* Improved Euler Integrator */
var ImprovedEuler;

ImprovedEuler = class ImprovedEuler extends Integrator {
  // x += (v * dt) + (a * 0.5 * dt * dt)
  // v += a * dt
  integrate(particles, dt, drag) {
    var acc, dtSq, i, len, p, results, vel;
    acc = new Vector();
    vel = new Vector();
    dtSq = dt * dt;
    results = [];
    for (i = 0, len = particles.length; i < len; i++) {
      p = particles[i];
      if (!(!p.fixed)) {
        continue;
      }
      // Store previous location.
      p.old.pos.copy(p.pos);
      // Scale force to mass.
      p.acc.scale(p.massInv);
      // Duplicate velocity to preserve momentum.
      vel.copy(p.vel);
      // Duplicate force.
      acc.copy(p.acc);
      // Update position.
      p.pos.add((vel.scale(dt)).add(acc.scale(0.5 * dtSq)));
      // Update velocity.
      p.vel.add(p.acc.scale(dt));
      // Apply friction.
      if (drag) {
        p.vel.scale(drag);
      }
      // Reset forces.
      results.push(p.acc.clear());
    }
    return results;
  }

};
```

Response:
### Improved Euler Integrator ###

class ImprovedEuler extends Integrator

    # x += (v * dt) + (a * 0.5 * dt * dt)
    # v += a * dt

    integrate: (particles, dt, drag) ->

        acc = new Vector()
        vel = new Vector()

        dtSq = dt * dt

        for p in particles when not p.fixed

            # Store previous location.
            p.old.pos.copy p.pos

            # Scale force to mass.
            p.acc.scale p.massInv

            # Duplicate velocity to preserve momentum.
            vel.copy p.vel

            # Duplicate force.
            acc.copy p.acc

            # Update position.
            p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)

            # Update velocity.
            p.vel.add p.acc.scale dt

            # Apply friction.
            if drag then p.vel.scale drag

            # Reset forces.
            p.acc.clear()


Prompt:
### Improved Euler Integrator ###

class ImprovedEuler extends Integrator

    # x += (v * dt) + (a * 0.5 * dt * dt)
    # v += a * dt

    integrate: (particles, dt, drag) ->

        acc = new Vector()
        vel = new Vector()

        dtSq = dt * dt

        for p in particles when not p.fixed

            # Store previous location.
            p.old.pos.copy p.pos

Response:
# Scale force to mass.
            p.acc.scale p.massInv

            # Duplicate velocity to preserve momentum.
            vel.copy p.vel

            # Duplicate force.
            acc.copy p.acc

            # Update position.
            p.pos.add (vel.scale dt).add (acc.scale 0.5 * dtSq)

            # Update velocity.
            p.vel.add p.acc.scale dt

            # Apply friction.
            if drag then p.vel.scale drag

            # Reset forces.
            p.acc.clear()


Response:
Err = require 'err1st'
config = require 'config'
logger = require 'graceful-logger'
recorder = require 'actions-recorder'
Immutable = require 'immutable'

routes = require '../routes'
schema = require '../schema'
locales = require '../locales'
template = require './template'

routerUtil = require 'router-view/lib/path'

module.exports = (req, res) ->
  router = routerUtil.getCurrentInfo routes, req.originalUrl
  next_url = req.cookies?.next_url

  {accounts, user} = req.get()

  store = schema.store
  # 设置用户信息
  .set 'user', Immutable.fromJS user
  # 设置路由
  .set 'router', router
  # configured siteUrl for redirecting
  .setIn ['client', 'siteUrl'], config.siteUrl
  .setIn ['config', 'siteUrl'], config.siteUrl
  .setIn ['config', 'accountUrl'], config.accountUrl
  .setIn ['config', 'cookieDomain'], config.cookieDomain
  .setIn ['config', 'weiboLogin'], config.weiboLogin
  .setIn ['config', 'firimLogin'], config.firimLogin
  .setIn ['config', 'githubLogin'], config.githubLogin
  .setIn ['config', 'trelloLogin'], config.trelloLogin
  .setIn ['config', 'teambitionLogin'], config.teambitionLogin
  # language detected from cookie and headers
  .setIn ['client', 'language'], req.getLocale()
  # /bind-thirdparty need an `method` for further behaviors
  .setIn ['client', 'serverAction'], (req.cookies?.method or null)
  # remember refer, client router will probably rewrite `query`
  .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url
  # page of /accounts renders a list of accounts
  .setIn ['page', 'accounts'], Immutable.fromJS(accounts)
  .setIn ['client', 'captchaService'], config.captchaService

  if res.err?
    if res.err.code is 404
      res.status res.err.status
      store = store.set 'serverError', Immutable.fromJS
        status: 404
        message: locales.get('pageNotFound', req.getLocale())


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Err = require 'err1st'
config = require 'config'
logger = require 'graceful-logger'
recorder = require 'actions-recorder'
Immutable = require 'immutable'

routes = require '../routes'
schema = require '../schema'
locales = require '../locales'
template = require './template'

routerUtil = require 'router-view/lib/path'

module.exports = (req, res) ->
  router = routerUtil.getCurrentInfo routes, req.originalUrl
  next_url = req.cookies?.next_url

  {accounts, user} = req.get()

  store = schema.store
  # 设置用户信息
  .set 'user', Immutable.fromJS user
  # 设置路由
  .set 'router', router
  # configured siteUrl for redirecting
  .setIn ['client', 'siteUrl'], config.siteUrl
  .setIn ['config', 'siteUrl'], config.siteUrl
  .setIn ['config', 'accountUrl'], config.accountUrl
  .setIn ['config', 'cookieDomain'], config.cookieDomain
  .setIn ['config', 'weiboLogin'], config.weiboLogin
  .setIn ['config', 'firimLogin'], config.firimLogin
  .setIn ['config', 'githubLogin'], config.githubLogin
  .setIn ['config', 'trelloLogin'], config.trelloLogin
  .setIn ['config', 'teambitionLogin'], config.teambitionLogin
  # language detected from cookie and headers
  .setIn ['client', 'language'], req.getLocale()
  # /bind-thirdparty need an `method` for further behaviors
  .setIn ['client', 'serverAction'], (req.cookies?.method or null)
  # remember refer, client router will probably rewrite `query`
  .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url
  # page of /accounts renders a list of accounts
  .setIn ['page', 'accounts'], Immutable.fromJS(accounts)
  .setIn ['client', 'captchaService'], config.captchaService

  if res.err?
    if res.err.code is 404
      res.status res.err.status
      store = store.set 'serverError', Immutable.fromJS
        status: 404
        message: locales.get('pageNotFound', req.getLocale())
```

Response:
var Err, Immutable, config, locales, logger, recorder, routerUtil, routes, schema, template;

Err = require('err1st');

config = require('config');

logger = require('graceful-logger');

recorder = require('actions-recorder');

Immutable = require('immutable');

routes = require('../routes');

schema = require('../schema');

locales = require('../locales');

template = require('./template');

routerUtil = require('router-view/lib/path');

module.exports = function(req, res) {
  var accounts, next_url, ref, ref1, router, store, user;
  router = routerUtil.getCurrentInfo(routes, req.originalUrl);
  next_url = (ref = req.cookies) != null ? ref.next_url : void 0;
  ({accounts, user} = req.get());
  // 设置用户信息
  // 设置路由
  // configured siteUrl for redirecting
  // language detected from cookie and headers
  // /bind-thirdparty need an `method` for further behaviors
  // remember refer, client router will probably rewrite `query`
  // page of /accounts renders a list of accounts
  store = schema.store.set('user', Immutable.fromJS(user)).set('router', router).setIn(['client', 'siteUrl'], config.siteUrl).setIn(['config', 'siteUrl'], config.siteUrl).setIn(['config', 'accountUrl'], config.accountUrl).setIn(['config', 'cookieDomain'], config.cookieDomain).setIn(['config', 'weiboLogin'], config.weiboLogin).setIn(['config', 'firimLogin'], config.firimLogin).setIn(['config', 'githubLogin'], config.githubLogin).setIn(['config', 'trelloLogin'], config.trelloLogin).setIn(['config', 'teambitionLogin'], config.teambitionLogin).setIn(['client', 'language'], req.getLocale()).setIn(['client', 'serverAction'], ((ref1 = req.cookies) != null ? ref1.method : void 0) || null).setIn(['client', 'referer'], router.getIn(['query', 'next_url']) || next_url).setIn(['page', 'accounts'], Immutable.fromJS(accounts)).setIn(['client', 'captchaService'], config.captchaService);
  if (res.err != null) {
    if (res.err.code === 404) {
      res.status(res.err.status);
      return store = store.set('serverError', Immutable.fromJS({
        status: 404,
        message: locales.get('pageNotFound', req.getLocale())
      }));
    }
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Err, Immutable, config, locales, logger, recorder, routerUtil, routes, schema, template;

Err = require('err1st');

config = require('config');

logger = require('graceful-logger');

recorder = require('actions-recorder');

Immutable = require('immutable');

routes = require('../routes');

schema = require('../schema');

locales = require('../locales');

template = require('./template');

routerUtil = require('router-view/lib/path');

module.exports = function(req, res) {
  var accounts, next_url, ref, ref1, router, store, user;
  router = routerUtil.getCurrentInfo(routes, req.originalUrl);
  next_url = (ref = req.cookies) != null ? ref.next_url : void 0;
  ({accounts, user} = req.get());
  // 设置用户信息
  // 设置路由
  // configured siteUrl for redirecting
  // language detected from cookie and headers
  // /bind-thirdparty need an `method` for further behaviors
  // remember refer, client router will probably rewrite `query`
  // page of /accounts renders a list of accounts
  store = schema.store.set('user', Immutable.fromJS(user)).set('router', router).setIn(['client', 'siteUrl'], config.siteUrl).setIn(['config', 'siteUrl'], config.siteUrl).setIn(['config', 'accountUrl'], config.accountUrl).setIn(['config', 'cookieDomain'], config.cookieDomain).setIn(['config', 'weiboLogin'], config.weiboLogin).setIn(['config', 'firimLogin'], config.firimLogin).setIn(['config', 'githubLogin'], config.githubLogin).setIn(['config', 'trelloLogin'], config.trelloLogin).setIn(['config', 'teambitionLogin'], config.teambitionLogin).setIn(['client', 'language'], req.getLocale()).setIn(['client', 'serverAction'], ((ref1 = req.cookies) != null ? ref1.method : void 0) || null).setIn(['client', 'referer'], router.getIn(['query', 'next_url']) || next_url).setIn(['page', 'accounts'], Immutable.fromJS(accounts)).setIn(['client', 'captchaService'], config.captchaService);
  if (res.err != null) {
    if (res.err.code === 404) {
      res.status(res.err.status);
      return store = store.set('serverError', Immutable.fromJS({
        status: 404,
        message: locales.get('pageNotFound', req.getLocale())
      }));
    }
  }
};
```

Response:
Err = require 'err1st'
config = require 'config'
logger = require 'graceful-logger'
recorder = require 'actions-recorder'
Immutable = require 'immutable'

routes = require '../routes'
schema = require '../schema'
locales = require '../locales'
template = require './template'

routerUtil = require 'router-view/lib/path'

module.exports = (req, res) ->
  router = routerUtil.getCurrentInfo routes, req.originalUrl
  next_url = req.cookies?.next_url

  {accounts, user} = req.get()

  store = schema.store
  # 设置用户信息
  .set 'user', Immutable.fromJS user
  # 设置路由
  .set 'router', router
  # configured siteUrl for redirecting
  .setIn ['client', 'siteUrl'], config.siteUrl
  .setIn ['config', 'siteUrl'], config.siteUrl
  .setIn ['config', 'accountUrl'], config.accountUrl
  .setIn ['config', 'cookieDomain'], config.cookieDomain
  .setIn ['config', 'weiboLogin'], config.weiboLogin
  .setIn ['config', 'firimLogin'], config.firimLogin
  .setIn ['config', 'githubLogin'], config.githubLogin
  .setIn ['config', 'trelloLogin'], config.trelloLogin
  .setIn ['config', 'teambitionLogin'], config.teambitionLogin
  # language detected from cookie and headers
  .setIn ['client', 'language'], req.getLocale()
  # /bind-thirdparty need an `method` for further behaviors
  .setIn ['client', 'serverAction'], (req.cookies?.method or null)
  # remember refer, client router will probably rewrite `query`
  .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url
  # page of /accounts renders a list of accounts
  .setIn ['page', 'accounts'], Immutable.fromJS(accounts)
  .setIn ['client', 'captchaService'], config.captchaService

  if res.err?
    if res.err.code is 404
      res.status res.err.status
      store = store.set 'serverError', Immutable.fromJS
        status: 404
        message: locales.get('pageNotFound', req.getLocale())


Prompt:
Err = require 'err1st'
config = require 'config'
logger = require 'graceful-logger'
recorder = require 'actions-recorder'
Immutable = require 'immutable'

routes = require '../routes'
schema = require '../schema'
locales = require '../locales'
template = require './template'

routerUtil = require 'router-view/lib/path'

module.exports = (req, res) ->
  router = routerUtil.getCurrentInfo routes, req.originalUrl
  next_url = req.cookies?.next_url

  {accounts, user} = req.get()

  store = schema.store
  # 设置用户信息
  .set 'user', Immutable.fromJS user
  # 设置路由
  .set 'router', router
  # configured siteUrl for redirecting

Response:
.setIn ['client', 'siteUrl'], config.siteUrl
  .setIn ['config', 'siteUrl'], config.siteUrl
  .setIn ['config', 'accountUrl'], config.accountUrl
  .setIn ['config', 'cookieDomain'], config.cookieDomain
  .setIn ['config', 'weiboLogin'], config.weiboLogin
  .setIn ['config', 'firimLogin'], config.firimLogin
  .setIn ['config', 'githubLogin'], config.githubLogin
  .setIn ['config', 'trelloLogin'], config.trelloLogin
  .setIn ['config', 'teambitionLogin'], config.teambitionLogin
  # language detected from cookie and headers
  .setIn ['client', 'language'], req.getLocale()
  # /bind-thirdparty need an `method` for further behaviors
  .setIn ['client', 'serverAction'], (req.cookies?.method or null)
  # remember refer, client router will probably rewrite `query`
  .setIn ['client', 'referer'], router.getIn(['query', 'next_url']) or next_url
  # page of /accounts renders a list of accounts
  .setIn ['page', 'accounts'], Immutable.fromJS(accounts)
  .setIn ['client', 'captchaService'], config.captchaService

  if res.err?
    if res.err.code is 404
      res.status res.err.status
      store = store.set 'serverError', Immutable.fromJS
        status: 404
        message: locales.get('pageNotFound', req.getLocale())


Response:
else
      err = new Err(res.err) unless res.err instanceof Err
      # copied logics to write status code
      logger.warn err.stack if config.debug or err.code is 100
      res.status err.status
      store = store.set 'serverError', Immutable.fromJS
        status: err.status
        message: err.message

  recorder.setup initial: store
  res.end template.render(recorder.getCore())


Prompt:
else
      err = new Err(res.err) unless res.err instanceof Err
      # copied logics to write status code
      logger.warn err.stack if config.debug or err.code is 100
      res.status err.status

Response:
store = store.set 'serverError', Immutable.fromJS
        status: err.status
        message: err.message

  recorder.setup initial: store
  res.end template.render(recorder.getCore())


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) ->
          try
            v = text.match(/uncrustify (\d+\.\d+)/)[1]
          catch error
            @error(error)
            v = text.match(/Uncrustify-(\d+\.\d+)/)[1] if not v?
          if v
            return v + ".0"
      }
      docker: {
        image: "unibeautify/uncrustify"
      }
    }
  ]

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options, context) ->
    fileExtension = context.fileExtension

    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) ->
          try
            v = text.match(/uncrustify (\d+\.\d+)/)[1]
          catch error
            @error(error)
            v = text.match(/Uncrustify-(\d+\.\d+)/)[1] if not v?
          if v
            return v + ".0"
      }
      docker: {
        image: "unibeautify/uncrustify"
      }
    }
  ]

Response:
options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options, context) ->
    fileExtension = context.fileExtension

    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath


Response:
else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text, fileExtension and ".#{fileExtension}")
        "-o"
        outputFile = @tempFile("output", text, fileExtension and ".#{fileExtension}")
        "-l"
        lang
        ])
        .then(=>


Prompt:
else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"

Response:
lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text, fileExtension and ".#{fileExtension}")
        "-o"
        outputFile = @tempFile("output", text, fileExtension and ".#{fileExtension}")
        "-l"
        lang
        ])
        .then(=>


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) ->
          try
            v = text.match(/uncrustify (\d+\.\d+)/)[1]
          catch error
            @error(error)
            v = text.match(/Uncrustify-(\d+\.\d+)/)[1] if not v?
          if v
            return v + ".0"
      }
      docker: {
        image: "unibeautify/uncrustify"
      }
    }
  ]

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) ->
          try
            v = text.match(/uncrustify (\d+\.\d+)/)[1]
          catch error
            @error(error)
            v = text.match(/Uncrustify-(\d+\.\d+)/)[1] if not v?
          if v
            return v + ".0"
      }
      docker: {
        image: "unibeautify/uncrustify"
      }
    }
  ]

Response:
options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path


Response:
editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ])
        .then(=>
          @readFile(outputFile)
        )


Prompt:
editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"

Response:
lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ])
        .then(=>
          @readFile(outputFile)
        )


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) ->
          try
            v = text.match(/uncrustify (\d+\.\d+)/)[1]
          catch error
            @error(error)
            v = text.match(/Uncrustify-(\d+\.\d+)/)[1] if not v?
          if v
            return v + ".0"
      }
    }
  ]

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) ->
          try
            v = text.match(/uncrustify (\d+\.\d+)/)[1]
          catch error
            @error(error)
            v = text.match(/Uncrustify-(\d+\.\d+)/)[1] if not v?
          if v
            return v + ".0"
      }
    }
  ]

  options: {
    Apex: true
    C: true

Response:
"C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())


Response:
projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ])
        .then(=>
          @readFile(outputFile)
        )
    )


Prompt:
projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"

Response:
lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ])
        .then(=>
          @readFile(outputFile)
        )
    )


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) -> text.match(/uncrustify (\d+\.\d+)/)[1] + ".0"
      }
    }
  ]

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  executables: [
    {
      name: "Uncrustify"
      cmd: "uncrustify"
      homepage: "http://uncrustify.sourceforge.net/"
      installation: "https://github.com/uncrustify/uncrustify"
      version: {
        parse: (text) -> text.match(/uncrustify (\d+\.\d+)/)[1] + ".0"
      }
    }
  ]

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true

Response:
Arduino: true
  }

  beautify: (text, language, options) ->
    uncrustify = @exe("uncrustify")
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else


Response:
reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Prompt:
reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>
      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"

Response:
lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      uncrustify.run([
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  isPreInstalled: false

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>

      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  isPreInstalled: false

  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->

Response:
throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>

      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"


Response:
lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      @run("uncrustify", [
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Prompt:
lang = "C"
        when "C++"
          lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

Response:
@run("uncrustify", [
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>

      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  link: "https://github.com/uncrustify/uncrustify"
  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath

Response:
else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>

      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"


Response:
lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      @run("uncrustify", [
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Prompt:
lang = "CPP"
        when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

Response:
@run("uncrustify", [
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Response:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else
        # Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>

      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"


Prompt:
module.exports = class Uncrustify extends Beautifier
  name: "Uncrustify"
  options: {
    Apex: true
    C: true
    "C++": true
    "C#": true
    "Objective-C": true
    D: true
    Pawn: true
    Vala: true
    Java: true
    Arduino: true
  }

  beautify: (text, language, options) ->
    # console.log('uncrustify.beautify', language, options)
    return new @Promise((resolve, reject) ->
      configPath = options.configPath
      unless configPath
        # No custom config path
        cfg options, (error, cPath) ->
          throw error if error
          resolve cPath
      else

Response:
# Has custom config path
        editor = atom.workspace.getActiveTextEditor()
        if editor?
          basePath = path.dirname(editor.getPath())
          projectPath = atom.workspace.project.getPaths()[0]
          # console.log(basePath);
          # Expand Home Directory in Config Path
          expandedConfigPath = expandHomeDir(configPath)
          configPath = path.resolve(projectPath, expandedConfigPath)
          resolve configPath
        else
          reject(new Error("No Uncrustify Config Path set! Please configure Uncrustify with Atom Beautify."))
    )
    .then((configPath) =>

      # Select Uncrustify language
      lang = "C" # Default is C
      switch language
        when "Apex"
          lang = "Apex"
        when "C"
          lang = "C"
        when "C++"
          lang = "CPP"


Response:
when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

      @run("uncrustify", [
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Prompt:
when "C#"
          lang = "CS"
        when "Objective-C", "Objective-C++"
          lang = "OC+"
        when "D"
          lang = "D"
        when "Pawn"
          lang = "PAWN"
        when "Vala"
          lang = "VALA"
        when "Java"
          lang = "JAVA"
        when "Arduino"
          lang = "CPP"

Response:
@run("uncrustify", [
        "-c"
        configPath
        "-f"
        @tempFile("input", text)
        "-o"
        outputFile = @tempFile("output", text)
        "-l"
        lang
        ], help: {
          link: "http://sourceforge.net/projects/uncrustify/"
        })
        .then(=>
          @readFile(outputFile)
        )
    )


Response:
# RTSP spec:
#   RFC 2326  http://www.ietf.org/rfc/rfc2326.txt

api =
  INTERLEAVED_SIGN: 0x24  # '$' (dollar sign)
  INTERLEAVED_HEADER_LEN: 4

  # Creates an interleaved header and returns the buffer.
  #
  # opts:
  #   channel: <number> channel identifier
  #   payloadLength: <number> payload length
  createInterleavedHeader: (opts) ->
    if not opts?.channel?
      throw new Error "createInterleavedHeader: channel is required"
    if not opts?.payloadLength?
      throw new Error "createInterleavedHeader: payloadLength is required"

    return new Buffer [
      api.INTERLEAVED_SIGN,
      opts.channel,
      opts.payloadLength >> 8, opts.payloadLength & 0xff,
    ]

  # Parses and returns an interleaved header.
  #
  # If the buffer doesn't have enough length for an interleaved header,
  # returns null.
  parseInterleavedHeader: (buf) ->
    if buf.length < api.INTERLEAVED_HEADER_LEN
      # not enough buffer
      return null

    if buf[0] isnt api.INTERLEAVED_SIGN
      throw new Error "The buffer is not an interleaved data"

    info = {}
    info.channel = buf[1]
    info.payloadLength = (buf[2] << 8) | buf[3]
    info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength
    return info

  # Parses and returns the information of complete interleaved data.
  #
  # If parsing failed or buf doesn't have enough length for
  # the payload, returns null.
  getInterleavedData: (buf) ->
    info = api.parseInterleavedHeader buf
    if not info?
      return null


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
# RTSP spec:
#   RFC 2326  http://www.ietf.org/rfc/rfc2326.txt

api =
  INTERLEAVED_SIGN: 0x24  # '$' (dollar sign)
  INTERLEAVED_HEADER_LEN: 4

  # Creates an interleaved header and returns the buffer.
  #
  # opts:
  #   channel: <number> channel identifier
  #   payloadLength: <number> payload length
  createInterleavedHeader: (opts) ->
    if not opts?.channel?
      throw new Error "createInterleavedHeader: channel is required"
    if not opts?.payloadLength?
      throw new Error "createInterleavedHeader: payloadLength is required"

    return new Buffer [
      api.INTERLEAVED_SIGN,
      opts.channel,
      opts.payloadLength >> 8, opts.payloadLength & 0xff,
    ]

  # Parses and returns an interleaved header.
  #
  # If the buffer doesn't have enough length for an interleaved header,
  # returns null.
  parseInterleavedHeader: (buf) ->
    if buf.length < api.INTERLEAVED_HEADER_LEN
      # not enough buffer
      return null

    if buf[0] isnt api.INTERLEAVED_SIGN
      throw new Error "The buffer is not an interleaved data"

    info = {}
    info.channel = buf[1]
    info.payloadLength = (buf[2] << 8) | buf[3]
    info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength
    return info

  # Parses and returns the information of complete interleaved data.
  #
  # If parsing failed or buf doesn't have enough length for
  # the payload, returns null.
  getInterleavedData: (buf) ->
    info = api.parseInterleavedHeader buf
    if not info?
      return null
```

Response:
// RTSP spec:
//   RFC 2326  http://www.ietf.org/rfc/rfc2326.txt
var api;

api = {
  INTERLEAVED_SIGN: 0x24, // '$' (dollar sign)
  INTERLEAVED_HEADER_LEN: 4,
  // Creates an interleaved header and returns the buffer.

  // opts:
  //   channel: <number> channel identifier
  //   payloadLength: <number> payload length
  createInterleavedHeader: function(opts) {
    if ((opts != null ? opts.channel : void 0) == null) {
      throw new Error("createInterleavedHeader: channel is required");
    }
    if ((opts != null ? opts.payloadLength : void 0) == null) {
      throw new Error("createInterleavedHeader: payloadLength is required");
    }
    return new Buffer([api.INTERLEAVED_SIGN, opts.channel, opts.payloadLength >> 8, opts.payloadLength & 0xff]);
  },
  // Parses and returns an interleaved header.

  // If the buffer doesn't have enough length for an interleaved header,
  // returns null.
  parseInterleavedHeader: function(buf) {
    var info;
    if (buf.length < api.INTERLEAVED_HEADER_LEN) {
      // not enough buffer
      return null;
    }
    if (buf[0] !== api.INTERLEAVED_SIGN) {
      throw new Error("The buffer is not an interleaved data");
    }
    info = {};
    info.channel = buf[1];
    info.payloadLength = (buf[2] << 8) | buf[3];
    info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength;
    return info;
  },
  // Parses and returns the information of complete interleaved data.

  // If parsing failed or buf doesn't have enough length for
  // the payload, returns null.
  getInterleavedData: function(buf) {
    var info;
    info = api.parseInterleavedHeader(buf);
    if (info == null) {
      return null;
    }
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
// RTSP spec:
//   RFC 2326  http://www.ietf.org/rfc/rfc2326.txt
var api;

api = {
  INTERLEAVED_SIGN: 0x24, // '$' (dollar sign)
  INTERLEAVED_HEADER_LEN: 4,
  // Creates an interleaved header and returns the buffer.

  // opts:
  //   channel: <number> channel identifier
  //   payloadLength: <number> payload length
  createInterleavedHeader: function(opts) {
    if ((opts != null ? opts.channel : void 0) == null) {
      throw new Error("createInterleavedHeader: channel is required");
    }
    if ((opts != null ? opts.payloadLength : void 0) == null) {
      throw new Error("createInterleavedHeader: payloadLength is required");
    }
    return new Buffer([api.INTERLEAVED_SIGN, opts.channel, opts.payloadLength >> 8, opts.payloadLength & 0xff]);
  },
  // Parses and returns an interleaved header.

  // If the buffer doesn't have enough length for an interleaved header,
  // returns null.
  parseInterleavedHeader: function(buf) {
    var info;
    if (buf.length < api.INTERLEAVED_HEADER_LEN) {
      // not enough buffer
      return null;
    }
    if (buf[0] !== api.INTERLEAVED_SIGN) {
      throw new Error("The buffer is not an interleaved data");
    }
    info = {};
    info.channel = buf[1];
    info.payloadLength = (buf[2] << 8) | buf[3];
    info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength;
    return info;
  },
  // Parses and returns the information of complete interleaved data.

  // If parsing failed or buf doesn't have enough length for
  // the payload, returns null.
  getInterleavedData: function(buf) {
    var info;
    info = api.parseInterleavedHeader(buf);
    if (info == null) {
      return null;
    }
  }
};
```

Response:
# RTSP spec:
#   RFC 2326  http://www.ietf.org/rfc/rfc2326.txt

api =
  INTERLEAVED_SIGN: 0x24  # '$' (dollar sign)
  INTERLEAVED_HEADER_LEN: 4

  # Creates an interleaved header and returns the buffer.
  #
  # opts:
  #   channel: <number> channel identifier
  #   payloadLength: <number> payload length
  createInterleavedHeader: (opts) ->
    if not opts?.channel?
      throw new Error "createInterleavedHeader: channel is required"
    if not opts?.payloadLength?
      throw new Error "createInterleavedHeader: payloadLength is required"

    return new Buffer [
      api.INTERLEAVED_SIGN,
      opts.channel,
      opts.payloadLength >> 8, opts.payloadLength & 0xff,
    ]

  # Parses and returns an interleaved header.
  #
  # If the buffer doesn't have enough length for an interleaved header,
  # returns null.
  parseInterleavedHeader: (buf) ->
    if buf.length < api.INTERLEAVED_HEADER_LEN
      # not enough buffer
      return null

    if buf[0] isnt api.INTERLEAVED_SIGN
      throw new Error "The buffer is not an interleaved data"

    info = {}
    info.channel = buf[1]
    info.payloadLength = (buf[2] << 8) | buf[3]
    info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength
    return info

  # Parses and returns the information of complete interleaved data.
  #
  # If parsing failed or buf doesn't have enough length for
  # the payload, returns null.
  getInterleavedData: (buf) ->
    info = api.parseInterleavedHeader buf
    if not info?
      return null


Prompt:
# RTSP spec:
#   RFC 2326  http://www.ietf.org/rfc/rfc2326.txt

api =
  INTERLEAVED_SIGN: 0x24  # '$' (dollar sign)
  INTERLEAVED_HEADER_LEN: 4

  # Creates an interleaved header and returns the buffer.
  #
  # opts:
  #   channel: <number> channel identifier
  #   payloadLength: <number> payload length
  createInterleavedHeader: (opts) ->
    if not opts?.channel?
      throw new Error "createInterleavedHeader: channel is required"
    if not opts?.payloadLength?
      throw new Error "createInterleavedHeader: payloadLength is required"

    return new Buffer [
      api.INTERLEAVED_SIGN,
      opts.channel,
      opts.payloadLength >> 8, opts.payloadLength & 0xff,
    ]

  # Parses and returns an interleaved header.

Response:
#
  # If the buffer doesn't have enough length for an interleaved header,
  # returns null.
  parseInterleavedHeader: (buf) ->
    if buf.length < api.INTERLEAVED_HEADER_LEN
      # not enough buffer
      return null

    if buf[0] isnt api.INTERLEAVED_SIGN
      throw new Error "The buffer is not an interleaved data"

    info = {}
    info.channel = buf[1]
    info.payloadLength = (buf[2] << 8) | buf[3]
    info.totalLength = api.INTERLEAVED_HEADER_LEN + info.payloadLength
    return info

  # Parses and returns the information of complete interleaved data.
  #
  # If parsing failed or buf doesn't have enough length for
  # the payload, returns null.
  getInterleavedData: (buf) ->
    info = api.parseInterleavedHeader buf
    if not info?
      return null


Response:
if buf.length < info.totalLength
      # not enough buffer
      return null

    info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]

    return info

module.exports = api


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
if buf.length < info.totalLength
      # not enough buffer
      return null

    info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]

    return info

module.exports = api
```

Response:
if (buf.length < info.totalLength) {
  // not enough buffer
  return null;
}

info.data = buf.slice(api.INTERLEAVED_HEADER_LEN, info.totalLength);

return info;

module.exports = api;


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
if (buf.length < info.totalLength) {
  // not enough buffer
  return null;
}

info.data = buf.slice(api.INTERLEAVED_HEADER_LEN, info.totalLength);

return info;

module.exports = api;
```

Response:
if buf.length < info.totalLength
      # not enough buffer
      return null

    info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]

    return info

module.exports = api


Prompt:
if buf.length < info.totalLength
      # not enough buffer
      return null

Response:
info.data = buf[api.INTERLEAVED_HEADER_LEN...info.totalLength]

    return info

module.exports = api


Response:
module.exports = React.createClass
  displayName: 'team-invite-batch'
  mixins: [ PureRenderMixin ]

  propTypes:
    _teamId: T.string.isRequired
    contacts: T.instanceOf(Immutable.List).isRequired
    onClose: T.func.isRequired

  getInitialState: ->
    invitees: ''

  makeInvitees: (data) ->
    arr = []
    data = data.split /\s|,|;/
    data.forEach (el) ->
      if el.length > 0
        arr.push el
    arr

  makeData: (data) ->
    data = Immutable.fromJS data
    data
    .groupBy (el) ->
      if util.isEmail el
        'emails'
      else if util.isMobile el
        'mobiles'
    .toJS()

  validInvitees: (data) ->
    data.every (el) ->
      util.isMobile(el) or util.isEmail(el)

  onBatchInvite: ->
    if @state.invitees.trim().length isnt 0
      invitees = @makeInvitees @state.invitees
      inviteesNew = []
      max = 100

      if (invitees.length is 0) or not @validInvitees invitees
        notifyActions.error l('room-members-invalid')
      else
        invitees.forEach (invitee) =>
          if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])
            inviteesNew.push invitee

        if inviteesNew.length > 0 and inviteesNew.length < max
          inviteesNew = @makeData inviteesNew
          teamActions.batchInvite @props._teamId, inviteesNew,


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = React.createClass
  displayName: 'team-invite-batch'
  mixins: [ PureRenderMixin ]

  propTypes:
    _teamId: T.string.isRequired
    contacts: T.instanceOf(Immutable.List).isRequired
    onClose: T.func.isRequired

  getInitialState: ->
    invitees: ''

  makeInvitees: (data) ->
    arr = []
    data = data.split /\s|,|;/
    data.forEach (el) ->
      if el.length > 0
        arr.push el
    arr

  makeData: (data) ->
    data = Immutable.fromJS data
    data
    .groupBy (el) ->
      if util.isEmail el
        'emails'
      else if util.isMobile el
        'mobiles'
    .toJS()

  validInvitees: (data) ->
    data.every (el) ->
      util.isMobile(el) or util.isEmail(el)

  onBatchInvite: ->
    if @state.invitees.trim().length isnt 0
      invitees = @makeInvitees @state.invitees
      inviteesNew = []
      max = 100

      if (invitees.length is 0) or not @validInvitees invitees
        notifyActions.error l('room-members-invalid')
      else
        invitees.forEach (invitee) =>
          if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])
            inviteesNew.push invitee

        if inviteesNew.length > 0 and inviteesNew.length < max
          inviteesNew = @makeData inviteesNew
          teamActions.batchInvite @props._teamId, inviteesNew,
```

Response:
module.exports = React.createClass({
  displayName: 'team-invite-batch',
  mixins: [PureRenderMixin],
  propTypes: {
    _teamId: T.string.isRequired,
    contacts: T.instanceOf(Immutable.List).isRequired,
    onClose: T.func.isRequired
  },
  getInitialState: function() {
    return {
      invitees: ''
    };
  },
  makeInvitees: function(data) {
    var arr;
    arr = [];
    data = data.split(/\s|,|;/);
    data.forEach(function(el) {
      if (el.length > 0) {
        return arr.push(el);
      }
    });
    return arr;
  },
  makeData: function(data) {
    data = Immutable.fromJS(data);
    return data.groupBy(function(el) {
      if (util.isEmail(el)) {
        return 'emails';
      } else if (util.isMobile(el)) {
        return 'mobiles';
      }
    }).toJS();
  },
  validInvitees: function(data) {
    return data.every(function(el) {
      return util.isMobile(el) || util.isEmail(el);
    });
  },
  onBatchInvite: function() {
    var invitees, inviteesNew, max;
    if (this.state.invitees.trim().length !== 0) {
      invitees = this.makeInvitees(this.state.invitees);
      inviteesNew = [];
      max = 100;
      if ((invitees.length === 0) || !this.validInvitees(invitees)) {
        return notifyActions.error(l('room-members-invalid'));
      } else {
        invitees.forEach((invitee) => {
          if (!this.props.contacts.some(function(x) {
            return invitee === x.get('email') || invitee === x.get('phoneForLogin');
          })) {
            return inviteesNew.push(invitee);
          }
        });
        if (inviteesNew.length > 0 && inviteesNew.length < max) {
          inviteesNew = this.makeData(inviteesNew);
          return teamActions.batchInvite(this.props._teamId, inviteesNew);
        }
      }
    }
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
module.exports = React.createClass({
  displayName: 'team-invite-batch',
  mixins: [PureRenderMixin],
  propTypes: {
    _teamId: T.string.isRequired,
    contacts: T.instanceOf(Immutable.List).isRequired,
    onClose: T.func.isRequired
  },
  getInitialState: function() {
    return {
      invitees: ''
    };
  },
  makeInvitees: function(data) {
    var arr;
    arr = [];
    data = data.split(/\s|,|;/);
    data.forEach(function(el) {
      if (el.length > 0) {
        return arr.push(el);
      }
    });
    return arr;
  },
  makeData: function(data) {
    data = Immutable.fromJS(data);
    return data.groupBy(function(el) {
      if (util.isEmail(el)) {
        return 'emails';
      } else if (util.isMobile(el)) {
        return 'mobiles';
      }
    }).toJS();
  },
  validInvitees: function(data) {
    return data.every(function(el) {
      return util.isMobile(el) || util.isEmail(el);
    });
  },
  onBatchInvite: function() {
    var invitees, inviteesNew, max;
    if (this.state.invitees.trim().length !== 0) {
      invitees = this.makeInvitees(this.state.invitees);
      inviteesNew = [];
      max = 100;
      if ((invitees.length === 0) || !this.validInvitees(invitees)) {
        return notifyActions.error(l('room-members-invalid'));
      } else {
        invitees.forEach((invitee) => {
          if (!this.props.contacts.some(function(x) {
            return invitee === x.get('email') || invitee === x.get('phoneForLogin');
          })) {
            return inviteesNew.push(invitee);
          }
        });
        if (inviteesNew.length > 0 && inviteesNew.length < max) {
          inviteesNew = this.makeData(inviteesNew);
          return teamActions.batchInvite(this.props._teamId, inviteesNew);
        }
      }
    }
  }
});
```

Response:
module.exports = React.createClass
  displayName: 'team-invite-batch'
  mixins: [ PureRenderMixin ]

  propTypes:
    _teamId: T.string.isRequired
    contacts: T.instanceOf(Immutable.List).isRequired
    onClose: T.func.isRequired

  getInitialState: ->
    invitees: ''

  makeInvitees: (data) ->
    arr = []
    data = data.split /\s|,|;/
    data.forEach (el) ->
      if el.length > 0
        arr.push el
    arr

  makeData: (data) ->
    data = Immutable.fromJS data
    data
    .groupBy (el) ->
      if util.isEmail el
        'emails'
      else if util.isMobile el
        'mobiles'
    .toJS()

  validInvitees: (data) ->
    data.every (el) ->
      util.isMobile(el) or util.isEmail(el)

  onBatchInvite: ->
    if @state.invitees.trim().length isnt 0
      invitees = @makeInvitees @state.invitees
      inviteesNew = []
      max = 100

      if (invitees.length is 0) or not @validInvitees invitees
        notifyActions.error l('room-members-invalid')
      else
        invitees.forEach (invitee) =>
          if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])
            inviteesNew.push invitee

        if inviteesNew.length > 0 and inviteesNew.length < max
          inviteesNew = @makeData inviteesNew
          teamActions.batchInvite @props._teamId, inviteesNew,


Prompt:
module.exports = React.createClass
  displayName: 'team-invite-batch'
  mixins: [ PureRenderMixin ]

  propTypes:
    _teamId: T.string.isRequired
    contacts: T.instanceOf(Immutable.List).isRequired
    onClose: T.func.isRequired

  getInitialState: ->
    invitees: ''

  makeInvitees: (data) ->
    arr = []
    data = data.split /\s|,|;/
    data.forEach (el) ->
      if el.length > 0
        arr.push el
    arr

  makeData: (data) ->
    data = Immutable.fromJS data
    data
    .groupBy (el) ->
      if util.isEmail el

Response:
'emails'
      else if util.isMobile el
        'mobiles'
    .toJS()

  validInvitees: (data) ->
    data.every (el) ->
      util.isMobile(el) or util.isEmail(el)

  onBatchInvite: ->
    if @state.invitees.trim().length isnt 0
      invitees = @makeInvitees @state.invitees
      inviteesNew = []
      max = 100

      if (invitees.length is 0) or not @validInvitees invitees
        notifyActions.error l('room-members-invalid')
      else
        invitees.forEach (invitee) =>
          if not @props.contacts.some((x) -> invitee in [x.get('email'), x.get('phoneForLogin')])
            inviteesNew.push invitee

        if inviteesNew.length > 0 and inviteesNew.length < max
          inviteesNew = @makeData inviteesNew
          teamActions.batchInvite @props._teamId, inviteesNew,


Response:
=>
              @setState invitees: ''
              @props.onClose()
              notifyActions.success l('room-members-success')
            ->
              notifyActions.error l('room-members-error')
        else if inviteesNew.length >= max
          notifyActions.error l('room-members-exceed-maximum').replace '%s', max
        else if invitees.length isnt inviteesNew.length
          notifyActions.error l('room-members-exists')

  onTextareaChange: (event) ->
    @setState invitees: event.target.value

  renderFooter: ->
    div className: 'footer',
      span className: 'button', onClick: @onBatchInvite, l('team-contacts-batch-invite-link')

  render: ->
    div className: 'team-invite-batch',
      div className: 'section',
        l('team-contacts-batch-invite')
        textarea
          autoFocus: true
          className: 'form-control is-static'
          placeholder: l('batch-invite-textarea')
          onChange: @onTextareaChange
      @renderFooter()


Prompt:
=>
              @setState invitees: ''
              @props.onClose()
              notifyActions.success l('room-members-success')
            ->
              notifyActions.error l('room-members-error')
        else if inviteesNew.length >= max
          notifyActions.error l('room-members-exceed-maximum').replace '%s', max
        else if invitees.length isnt inviteesNew.length
          notifyActions.error l('room-members-exists')

  onTextareaChange: (event) ->
    @setState invitees: event.target.value

Response:
renderFooter: ->
    div className: 'footer',
      span className: 'button', onClick: @onBatchInvite, l('team-contacts-batch-invite-link')

  render: ->
    div className: 'team-invite-batch',
      div className: 'section',
        l('team-contacts-batch-invite')
        textarea
          autoFocus: true
          className: 'form-control is-static'
          placeholder: l('batch-invite-textarea')
          onChange: @onTextareaChange
      @renderFooter()


Response:
Err = require 'err1st'
Promise = require 'bluebird'
requestAsync = Promise.promisify(require 'request')
config = require 'config'
moment = require 'moment'

module.exports =
  sendSMS: (mobile, text, options = {}, callback = ->) ->
    # @osv
    return callback(null, ok: 1)
    {redis} = require '../components'
    endOfToday = moment().endOf('day').valueOf()
    rateKey = "sms:#{mobile}:#{endOfToday}"

    if options.dailyRate
      $overRate = redis.getAsync rateKey

      .then (rateNum) ->
        return unless rateNum
        if Number(rateNum) > options.dailyRate
          throw new Err 'MOBILE_RATE_EXCEEDED'
        return

    else $overRate = Promise.resolve()

    $sendSMS = $overRate.then ->
      _options =
        method: 'POST'
        url: config.sms.host + '/send'
        json: true
        body:
          key: config.sms.key
          secret: config.sms.secret
          phone: mobile
          ip: options.ip
          _userId: options._userId
          refer: options.refer
          msg: text
          uid: options.uid or options._userId
      requestAsync _options
      .spread (res) ->
        throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200
        res.body

    $setRate = $sendSMS.then ->
      remainSeconds = Math.floor((endOfToday - Date.now())/1000)
      redis
        .multi()
        .incr rateKey
        .expire rateKey, remainSeconds


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Err = require 'err1st'
Promise = require 'bluebird'
requestAsync = Promise.promisify(require 'request')
config = require 'config'
moment = require 'moment'

module.exports =
  sendSMS: (mobile, text, options = {}, callback = ->) ->
    # @osv
    return callback(null, ok: 1)
    {redis} = require '../components'
    endOfToday = moment().endOf('day').valueOf()
    rateKey = "sms:#{mobile}:#{endOfToday}"

    if options.dailyRate
      $overRate = redis.getAsync rateKey

      .then (rateNum) ->
        return unless rateNum
        if Number(rateNum) > options.dailyRate
          throw new Err 'MOBILE_RATE_EXCEEDED'
        return

    else $overRate = Promise.resolve()

    $sendSMS = $overRate.then ->
      _options =
        method: 'POST'
        url: config.sms.host + '/send'
        json: true
        body:
          key: config.sms.key
          secret: config.sms.secret
          phone: mobile
          ip: options.ip
          _userId: options._userId
          refer: options.refer
          msg: text
          uid: options.uid or options._userId
      requestAsync _options
      .spread (res) ->
        throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200
        res.body

    $setRate = $sendSMS.then ->
      remainSeconds = Math.floor((endOfToday - Date.now())/1000)
      redis
        .multi()
        .incr rateKey
        .expire rateKey, remainSeconds
```

Response:
var Err, Promise, config, moment, requestAsync;

Err = require('err1st');

Promise = require('bluebird');

requestAsync = Promise.promisify(require('request'));

config = require('config');

moment = require('moment');

module.exports = {
  sendSMS: function(mobile, text, options = {}, callback = function() {}) {
    var $overRate, $sendSMS, $setRate, endOfToday, rateKey, redis;
    // @osv
    return callback(null, {
      ok: 1
    });
    ({redis} = require('../components'));
    endOfToday = moment().endOf('day').valueOf();
    rateKey = `sms:${mobile}:${endOfToday}`;
    if (options.dailyRate) {
      $overRate = redis.getAsync(rateKey).then(function(rateNum) {
        if (!rateNum) {
          return;
        }
        if (Number(rateNum) > options.dailyRate) {
          throw new Err('MOBILE_RATE_EXCEEDED');
        }
      });
    } else {
      $overRate = Promise.resolve();
    }
    $sendSMS = $overRate.then(function() {
      var _options;
      _options = {
        method: 'POST',
        url: config.sms.host + '/send',
        json: true,
        body: {
          key: config.sms.key,
          secret: config.sms.secret,
          phone: mobile,
          ip: options.ip,
          _userId: options._userId,
          refer: options.refer,
          msg: text,
          uid: options.uid || options._userId
        }
      };
      return requestAsync(_options).spread(function(res) {
        if ((res != null ? res.statusCode : void 0) !== 200) {
          throw new Err('SEND_SMS_ERROR');
        }
        return res.body;
      });
    });
    return $setRate = $sendSMS.then(function() {
      var remainSeconds;
      remainSeconds = Math.floor((endOfToday - Date.now()) / 1000);
      return redis.multi().incr(rateKey).expire(rateKey, remainSeconds);
    });
  }
};


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Err, Promise, config, moment, requestAsync;

Err = require('err1st');

Promise = require('bluebird');

requestAsync = Promise.promisify(require('request'));

config = require('config');

moment = require('moment');

module.exports = {
  sendSMS: function(mobile, text, options = {}, callback = function() {}) {
    var $overRate, $sendSMS, $setRate, endOfToday, rateKey, redis;
    // @osv
    return callback(null, {
      ok: 1
    });
    ({redis} = require('../components'));
    endOfToday = moment().endOf('day').valueOf();
    rateKey = `sms:${mobile}:${endOfToday}`;
    if (options.dailyRate) {
      $overRate = redis.getAsync(rateKey).then(function(rateNum) {
        if (!rateNum) {
          return;
        }
        if (Number(rateNum) > options.dailyRate) {
          throw new Err('MOBILE_RATE_EXCEEDED');
        }
      });
    } else {
      $overRate = Promise.resolve();
    }
    $sendSMS = $overRate.then(function() {
      var _options;
      _options = {
        method: 'POST',
        url: config.sms.host + '/send',
        json: true,
        body: {
          key: config.sms.key,
          secret: config.sms.secret,
          phone: mobile,
          ip: options.ip,
          _userId: options._userId,
          refer: options.refer,
          msg: text,
          uid: options.uid || options._userId
        }
      };
      return requestAsync(_options).spread(function(res) {
        if ((res != null ? res.statusCode : void 0) !== 200) {
          throw new Err('SEND_SMS_ERROR');
        }
        return res.body;
      });
    });
    return $setRate = $sendSMS.then(function() {
      var remainSeconds;
      remainSeconds = Math.floor((endOfToday - Date.now()) / 1000);
      return redis.multi().incr(rateKey).expire(rateKey, remainSeconds);
    });
  }
};
```

Response:
Err = require 'err1st'
Promise = require 'bluebird'
requestAsync = Promise.promisify(require 'request')
config = require 'config'
moment = require 'moment'

module.exports =
  sendSMS: (mobile, text, options = {}, callback = ->) ->
    # @osv
    return callback(null, ok: 1)
    {redis} = require '../components'
    endOfToday = moment().endOf('day').valueOf()
    rateKey = "sms:#{mobile}:#{endOfToday}"

    if options.dailyRate
      $overRate = redis.getAsync rateKey

      .then (rateNum) ->
        return unless rateNum
        if Number(rateNum) > options.dailyRate
          throw new Err 'MOBILE_RATE_EXCEEDED'
        return

    else $overRate = Promise.resolve()

    $sendSMS = $overRate.then ->
      _options =
        method: 'POST'
        url: config.sms.host + '/send'
        json: true
        body:
          key: config.sms.key
          secret: config.sms.secret
          phone: mobile
          ip: options.ip
          _userId: options._userId
          refer: options.refer
          msg: text
          uid: options.uid or options._userId
      requestAsync _options
      .spread (res) ->
        throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200
        res.body

    $setRate = $sendSMS.then ->
      remainSeconds = Math.floor((endOfToday - Date.now())/1000)
      redis
        .multi()
        .incr rateKey
        .expire rateKey, remainSeconds


Prompt:
Err = require 'err1st'
Promise = require 'bluebird'
requestAsync = Promise.promisify(require 'request')
config = require 'config'
moment = require 'moment'

module.exports =
  sendSMS: (mobile, text, options = {}, callback = ->) ->
    # @osv
    return callback(null, ok: 1)
    {redis} = require '../components'
    endOfToday = moment().endOf('day').valueOf()
    rateKey = "sms:#{mobile}:#{endOfToday}"

    if options.dailyRate
      $overRate = redis.getAsync rateKey

      .then (rateNum) ->
        return unless rateNum
        if Number(rateNum) > options.dailyRate
          throw new Err 'MOBILE_RATE_EXCEEDED'
        return

    else $overRate = Promise.resolve()

Response:
$sendSMS = $overRate.then ->
      _options =
        method: 'POST'
        url: config.sms.host + '/send'
        json: true
        body:
          key: config.sms.key
          secret: config.sms.secret
          phone: mobile
          ip: options.ip
          _userId: options._userId
          refer: options.refer
          msg: text
          uid: options.uid or options._userId
      requestAsync _options
      .spread (res) ->
        throw new Err('SEND_SMS_ERROR') unless res?.statusCode is 200
        res.body

    $setRate = $sendSMS.then ->
      remainSeconds = Math.floor((endOfToday - Date.now())/1000)
      redis
        .multi()
        .incr rateKey
        .expire rateKey, remainSeconds


Response:
.execAsync()

    Promise.all [$sendSMS, $setRate]
    .spread (body) -> body
    .nodeify callback


Response:
@tests =
  client: (t) ->
    t.expect 1, 2
    t.wait 3000

    zapp = zappa port++, ->
      @client '/index.js': ->
        @get '#/': -> alert 'hi'

    c = t.client(zapp.app)
    c.get '/index.js', (err, res) ->
      t.equal 1, res.body, ';zappa.run(function () {\n            return this.get({\n              \'#/\': function() {\n                return alert(\'hi\');\n              }\n            });\n          });'
      t.equal 2, res.headers['content-type'], 'application/javascript'

  coffee: (t) ->
    t.expect 1, 2
    t.wait 3000

    zapp = zappa port++, ->
      @coffee '/coffee.js': ->
        alert 'hi'

    c = t.client(zapp.app)
    c.get '/coffee.js', (err, res) ->
      t.equal 1, res.body, ';var __slice = Array.prototype.slice;var __hasProp = Object.prototype.hasOwnProperty;var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };var __extends = function(child, parent) {  for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }  function ctor() { this.constructor = child; }  ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype;  return child; };var __indexOf = Array.prototype.indexOf || function(item) {  for (var i = 0, l = this.length; i < l; i++) {    if (this[i] === item) return i;  } return -1; };(function () {\n            return alert(\'hi\');\n          })();'
      t.equal 2, res.headers['content-type'], 'application/javascript'

  js: (t) ->
    t.expect 1, 2
    t.wait 3000

    zapp = zappa port++, ->
      @js '/js.js': '''
        alert('hi');
      '''

    c = t.client(zapp.app)
    c.get '/js.js', (err, res) ->
      t.equal 1, res.body, "alert('hi');"
      t.equal 2, res.headers['content-type'], 'application/javascript'

  css: (t) ->
    t.expect 1, 2
    t.wait 3000

    zapp = zappa port++, ->
      @css '/index.css': '''
        font-family: sans-serif;
      '''