     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



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.root.focus()

  formatLines: (index, length, name, value, options) ->
    [index, length, formats, options] = this._buildParams(index, length, name, value, options)
    [line, offset] = @editor.doc.findLineAt(index)
    # TODO potential util function with editor._formatAt
    delta = Tandem.Delta.getIdentity(this.getLength())
