 
 
 DEFAULT_API_OPTIONS = { silent: false, source: 'api' }
-
-# fn(Number index, Number length, String name, String value, Object options = {})
-# fn(Number index, Number length, Object formats, Object options = {})
-# fn(Object range, String name, String value, Object options = {})
-# fn(Object range, Object formats, Object options = {})
-buildParams = (params...) ->
-  if _.isObject(params[0])
-    index = params[0].start
-    length = params[0].end - index
-    params.splice(0, 1, index, length)
-  if _.isString(params[2])
-    formats = {}
-    formats[params[2]] = params[3]
-    params.splice(2, 2, formats)
-  params[3] = _.defaults(params[3] or {}, DEFAULT_API_OPTIONS)
-  return params
 
 
 class Quill extends EventEmitter2

    @editor.applyDelta(delta, options)

  formatText: (index, length, name, value, options) ->
    [index, length, formats, options] = buildParams(index, length, name, value, options)
    return unless length > 0
    delta = Tandem.Delta.makeRetainDelta(this.getLength(), index, length, formats)
    @editor.applyDelta(delta, options)

    options = _.defaults(options, DEFAULT_API_OPTIONS)
    @editor.selection.update(options.silent)

  # fn(Number index, Number length, String name, String value, Object options = {})
  # fn(Number index, Number length, Object formats, Object options = {})
  # fn(Object range, String name, String value, Object options = {})
  # fn(Object range, Object formats, Object options = {})
  _buildParams: (params...) ->
    if _.isObject(params[0])
      index = params[0].start
      length = params[0].end - index
      params.splice(0, 1, index, length)
    if _.isString(params[2])
      formats = {}
      formats[params[2]] = params[3]
      params.splice(2, 2, formats)
    params[3] = _.defaults(params[3] or {}, DEFAULT_API_OPTIONS)
    return params


module.exports = Quill
