electron/atom/browser/api/lib/protocol.coffee

34 lines
983 B
CoffeeScript
Raw Normal View History

app = require 'app'
throw new Error('Can not initialize protocol module before app is ready') unless app.isReady()
2014-04-21 08:33:32 +00:00
protocol = process.atomBinding('protocol').protocol
2013-08-29 12:38:04 +00:00
EventEmitter = require('events').EventEmitter
2014-04-21 08:33:32 +00:00
protocol.__proto__ = EventEmitter.prototype
2013-08-29 12:38:04 +00:00
protocol.RequestStringJob =
class RequestStringJob
constructor: ({mimeType, charset, data}) ->
if typeof data isnt 'string' and not data instanceof Buffer
throw new TypeError('Data should be string or Buffer')
@mimeType = mimeType ? 'text/plain'
@charset = charset ? 'UTF-8'
@data = String data
2015-03-16 12:53:45 +00:00
protocol.RequestBufferJob =
class RequestBufferJob
constructor: ({mimeType, encoding, data}) ->
if not data instanceof Buffer
throw new TypeError('Data should be Buffer')
@mimeType = mimeType ? 'application/octet-stream'
@encoding = encoding ? 'utf8'
@data = new Buffer(data)
2013-08-29 12:38:04 +00:00
protocol.RequestFileJob =
class RequestFileJob
constructor: (@path) ->
2013-08-29 12:38:04 +00:00
module.exports = protocol