Fix addon lint

This commit is contained in:
Daniel Imms
2018-01-17 10:20:04 -08:00
parent 5888cd7938
commit 70236f6818
13 changed files with 94 additions and 97 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert, expect } from 'chai';
import * as zmodem from './zmodem'
import * as zmodem from './zmodem';
class MockTerminal {}
+20 -27
View File
@@ -29,45 +29,38 @@
let Zmodem;
export function zmodemAttach(term, ws, opts) {
if (!opts) opts = {};
export interface IZModemOptions {
noTerminalWriteOutsideSession?: boolean;
}
var senderFunc = function _ws_sender_func(octets) {
ws.send(new Uint8Array(octets));
};
export function zmodemAttach(term: any, ws: WebSocket, opts: IZModemOptions = {}): void {
const senderFunc = (octets: ArrayLike<number>) => ws.send(new Uint8Array(octets));
var zsentry;
let zsentry;
function _shouldWrite() {
function _shouldWrite(): boolean {
return !!zsentry.get_confirmed_session() || !opts.noTerminalWriteOutsideSession;
}
zsentry = new Zmodem.Sentry( {
to_terminal: function _to_terminal(octets) {
zsentry = new Zmodem.Sentry({
to_terminal: (octets: ArrayLike<number>) => {
if (_shouldWrite()) {
term.write(
String.fromCharCode.apply(String, octets)
);
}
},
sender: senderFunc,
on_retract: () => term.emit('zmodemRetract'),
on_detect: (detection: any) => term.emit('zmodemDetect', detection)
});
on_retract: function _on_retract() {
term.emit('zmodemRetract');
},
function handleWSMessage(evt: MessageEvent): void {
on_detect: function _on_detect(detection) {
term.emit('zmodemDetect', detection);
},
} );
function handleWSMessage(evt) {
//In testing with xterm.js’s demo the first message was
//always text even if the rest were binary. While that
//may be specific to xterm.js’s demo, ultimately we
//should reject anything that isn’t binary.
// In testing with xterm.js’s demo the first message was
// always text even if the rest were binary. While that
// may be specific to xterm.js’s demo, ultimately we
// should reject anything that isn’t binary.
if (typeof evt.data === 'string') {
if (_shouldWrite()) {
term.write(evt.data);
@@ -82,9 +75,9 @@ export function zmodemAttach(term, ws, opts) {
ws.addEventListener('message', handleWSMessage);
}
export function apply(terminalConstructor) {
Zmodem = (typeof window == 'object') ? (<any>window).ZModem : {Browser: null}; // Nullify browser for tests
export function apply(terminalConstructor: any): void {
Zmodem = (typeof window === 'object') ? (<any>window).ZModem : {Browser: null}; // Nullify browser for tests
terminalConstructor.prototype.zmodemAttach = zmodemAttach.bind(this, this);
terminalConstructor.prototype.zmodemBrowser = Zmodem.Browser
terminalConstructor.prototype.zmodemBrowser = Zmodem.Browser;
}