summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/lib')
-rw-r--r--app/assets/javascripts/ide/lib/common/disposable.js4
-rw-r--r--app/assets/javascripts/ide/lib/common/model.js4
-rw-r--r--app/assets/javascripts/ide/lib/create_diff.js16
-rw-r--r--app/assets/javascripts/ide/lib/create_file_diff.js10
-rw-r--r--app/assets/javascripts/ide/lib/decorations/controller.js2
-rw-r--r--app/assets/javascripts/ide/lib/diff/controller.js6
-rw-r--r--app/assets/javascripts/ide/lib/diff/diff.js2
-rw-r--r--app/assets/javascripts/ide/lib/diff/diff_worker.js2
-rw-r--r--app/assets/javascripts/ide/lib/editor.js12
-rw-r--r--app/assets/javascripts/ide/lib/editor_options.js4
-rw-r--r--app/assets/javascripts/ide/lib/editorconfig/parser.js13
-rw-r--r--app/assets/javascripts/ide/lib/editorconfig/rules_mapper.js12
-rw-r--r--app/assets/javascripts/ide/lib/errors.js14
-rw-r--r--app/assets/javascripts/ide/lib/files.js21
-rw-r--r--app/assets/javascripts/ide/lib/languages/hcl.js14
-rw-r--r--app/assets/javascripts/ide/lib/languages/vue.js8
-rw-r--r--app/assets/javascripts/ide/lib/mirror.js26
17 files changed, 102 insertions, 68 deletions
diff --git a/app/assets/javascripts/ide/lib/common/disposable.js b/app/assets/javascripts/ide/lib/common/disposable.js
index 84b29bdb600..c5d0773c9a2 100644
--- a/app/assets/javascripts/ide/lib/common/disposable.js
+++ b/app/assets/javascripts/ide/lib/common/disposable.js
@@ -4,11 +4,11 @@ export default class Disposable {
}
add(...disposers) {
- disposers.forEach(disposer => this.disposers.add(disposer));
+ disposers.forEach((disposer) => this.disposers.add(disposer));
}
dispose() {
- this.disposers.forEach(disposer => disposer.dispose());
+ this.disposers.forEach((disposer) => disposer.dispose());
this.disposers.clear();
}
}
diff --git a/app/assets/javascripts/ide/lib/common/model.js b/app/assets/javascripts/ide/lib/common/model.js
index 2471b3627ce..4969875439e 100644
--- a/app/assets/javascripts/ide/lib/common/model.js
+++ b/app/assets/javascripts/ide/lib/common/model.js
@@ -75,7 +75,7 @@ export default class Model {
}
onChange(cb) {
- this.events.add(this.disposable.add(this.model.onDidChangeContent(e => cb(this, e))));
+ this.events.add(this.disposable.add(this.model.onDidChangeContent((e) => cb(this, e))));
}
onDispose(cb) {
@@ -121,7 +121,7 @@ export default class Model {
dispose() {
if (!this.model.isDisposed()) this.applyCustomOptions();
- this.events.forEach(cb => {
+ this.events.forEach((cb) => {
if (typeof cb === 'function') cb();
});
diff --git a/app/assets/javascripts/ide/lib/create_diff.js b/app/assets/javascripts/ide/lib/create_diff.js
index 3e915afdbcb..51d4967fb23 100644
--- a/app/assets/javascripts/ide/lib/create_diff.js
+++ b/app/assets/javascripts/ide/lib/create_diff.js
@@ -32,8 +32,8 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} })
// We need to clean "move" actions, because we can only support 100% similarity moves at the moment.
// This is because the previous file's content might not be loaded.
Object.values(changes)
- .filter(change => change.action === commitActionTypes.move)
- .forEach(change => {
+ .filter((change) => change.action === commitActionTypes.move)
+ .forEach((change) => {
const prev = changes[change.file.prevPath];
if (!prev) {
@@ -51,14 +51,14 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} })
// Next, we need to add deleted directories by looking at the parents
Object.values(changes)
- .filter(change => change.action === commitActionTypes.delete && change.file.parentPath)
+ .filter((change) => change.action === commitActionTypes.delete && change.file.parentPath)
.forEach(({ file }) => {
// Do nothing if we've already visited this directory.
if (changes[file.parentPath]) {
return;
}
- getDeletedParents(entries, file).forEach(parent => {
+ getDeletedParents(entries, file).forEach((parent) => {
changes[parent.path] = { action: commitActionTypes.delete, file: parent };
});
});
@@ -66,13 +66,15 @@ const filesWithChanges = ({ stagedFiles = [], changedFiles = [], entries = {} })
return Object.values(changes);
};
-const createDiff = state => {
+const createDiff = (state) => {
const changes = filesWithChanges(state);
- const toDelete = changes.filter(x => x.action === commitActionTypes.delete).map(x => x.file.path);
+ const toDelete = changes
+ .filter((x) => x.action === commitActionTypes.delete)
+ .map((x) => x.file.path);
const patch = changes
- .filter(x => x.action !== commitActionTypes.delete)
+ .filter((x) => x.action !== commitActionTypes.delete)
.map(({ file, action }) => createFileDiff(file, action))
.join('');
diff --git a/app/assets/javascripts/ide/lib/create_file_diff.js b/app/assets/javascripts/ide/lib/create_file_diff.js
index 5ae4993321c..b417b4765d8 100644
--- a/app/assets/javascripts/ide/lib/create_file_diff.js
+++ b/app/assets/javascripts/ide/lib/create_file_diff.js
@@ -12,13 +12,13 @@ const NEW_LINE = '\n';
*
* - Removes "=======" separator added at the beginning
*/
-const cleanTwoFilesPatch = text => text.replace(/^(=+\s*)/, '');
+const cleanTwoFilesPatch = (text) => text.replace(/^(=+\s*)/, '');
-const endsWithNewLine = val => !val || val[val.length - 1] === NEW_LINE;
+const endsWithNewLine = (val) => !val || val[val.length - 1] === NEW_LINE;
-const addEndingNewLine = val => (endsWithNewLine(val) ? val : val + NEW_LINE);
+const addEndingNewLine = (val) => (endsWithNewLine(val) ? val : val + NEW_LINE);
-const removeEndingNewLine = val => (endsWithNewLine(val) ? val.substr(0, val.length - 1) : val);
+const removeEndingNewLine = (val) => (endsWithNewLine(val) ? val.substr(0, val.length - 1) : val);
const diffHead = (prevPath, newPath = '') =>
`diff --git "a/${prevPath}" "b/${newPath || prevPath}"`;
@@ -37,7 +37,7 @@ const createDiffBody = (path, content, isCreate) => {
const chunkHead = isCreate ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`;
const chunk = lines
- .map(line => `${prefix}${line}`)
+ .map((line) => `${prefix}${line}`)
.concat(!hasNewLine ? [NO_NEW_LINE] : [])
.join(NEW_LINE);
diff --git a/app/assets/javascripts/ide/lib/decorations/controller.js b/app/assets/javascripts/ide/lib/decorations/controller.js
index 13d477bb2cf..b5d3eb10952 100644
--- a/app/assets/javascripts/ide/lib/decorations/controller.js
+++ b/app/assets/javascripts/ide/lib/decorations/controller.js
@@ -11,7 +11,7 @@ export default class DecorationsController {
const modelDecorations = this.decorations.get(model.url);
const decorations = [];
- modelDecorations.forEach(val => decorations.push(...val));
+ modelDecorations.forEach((val) => decorations.push(...val));
return decorations;
}
diff --git a/app/assets/javascripts/ide/lib/diff/controller.js b/app/assets/javascripts/ide/lib/diff/controller.js
index 35fcda6a6c5..3efe692be13 100644
--- a/app/assets/javascripts/ide/lib/diff/controller.js
+++ b/app/assets/javascripts/ide/lib/diff/controller.js
@@ -3,7 +3,7 @@ import { throttle } from 'lodash';
import DirtyDiffWorker from './diff_worker';
import Disposable from '../common/disposable';
-export const getDiffChangeType = change => {
+export const getDiffChangeType = (change) => {
if (change.modified) {
return 'modified';
} else if (change.added) {
@@ -15,7 +15,7 @@ export const getDiffChangeType = change => {
return '';
};
-export const getDecorator = change => ({
+export const getDecorator = (change) => ({
range: new Range(change.lineNumber, 1, change.endLineNumber, 1),
options: {
isWholeLine: true,
@@ -71,7 +71,7 @@ export default class DirtyDiffController {
}
decorate({ data }) {
- const decorations = data.changes.map(change => getDecorator(change));
+ const decorations = data.changes.map((change) => getDecorator(change));
const model = this.modelManager.getModel(data.path);
this.decorationsController.addDecorations(model, 'dirtyDiff', decorations);
}
diff --git a/app/assets/javascripts/ide/lib/diff/diff.js b/app/assets/javascripts/ide/lib/diff/diff.js
index 62ec798b372..5a6401f56ec 100644
--- a/app/assets/javascripts/ide/lib/diff/diff.js
+++ b/app/assets/javascripts/ide/lib/diff/diff.js
@@ -11,7 +11,7 @@ export const computeDiff = (originalContent, newContent) => {
let lineNumber = 1;
return changes.reduce((acc, change) => {
- const findOnLine = acc.find(c => c.lineNumber === lineNumber);
+ const findOnLine = acc.find((c) => c.lineNumber === lineNumber);
if (findOnLine) {
Object.assign(findOnLine, change, {
diff --git a/app/assets/javascripts/ide/lib/diff/diff_worker.js b/app/assets/javascripts/ide/lib/diff/diff_worker.js
index 77416a8de9d..78b2eab6399 100644
--- a/app/assets/javascripts/ide/lib/diff/diff_worker.js
+++ b/app/assets/javascripts/ide/lib/diff/diff_worker.js
@@ -1,7 +1,7 @@
import { computeDiff } from './diff';
// eslint-disable-next-line no-restricted-globals
-self.addEventListener('message', e => {
+self.addEventListener('message', (e) => {
const { data } = e;
// eslint-disable-next-line no-restricted-globals
diff --git a/app/assets/javascripts/ide/lib/editor.js b/app/assets/javascripts/ide/lib/editor.js
index 493dedcd89a..4fad0c09ce7 100644
--- a/app/assets/javascripts/ide/lib/editor.js
+++ b/app/assets/javascripts/ide/lib/editor.js
@@ -12,7 +12,7 @@ import { clearDomElement } from '~/editor/utils';
import { registerLanguages } from '../utils';
function setupThemes() {
- themes.forEach(theme => {
+ themes.forEach((theme) => {
monacoEditor.defineTheme(theme.name, theme.data);
});
}
@@ -108,7 +108,7 @@ export default class Editor {
this.instance.updateOptions(
editorOptions.reduce((acc, obj) => {
- Object.keys(obj).forEach(key => {
+ Object.keys(obj).forEach((key) => {
Object.assign(acc, {
[key]: obj[key](model),
});
@@ -177,7 +177,7 @@ export default class Editor {
onPositionChange(cb) {
if (!this.instance.onDidChangeCursorPosition) return;
- this.disposable.add(this.instance.onDidChangeCursorPosition(e => cb(this.instance, e)));
+ this.disposable.add(this.instance.onDidChangeCursorPosition((e) => cb(this.instance, e)));
}
updateDiffView() {
@@ -213,14 +213,14 @@ export default class Editor {
addCommands() {
const { store } = this;
- const getKeyCode = key => {
+ const getKeyCode = (key) => {
const monacoKeyMod = key.indexOf('KEY_') === 0;
return monacoKeyMod ? KeyCode[key] : KeyMod[key];
};
- keymap.forEach(command => {
- const keybindings = command.bindings.map(binding => {
+ keymap.forEach((command) => {
+ const keybindings = command.bindings.map((binding) => {
const keys = binding.split('+');
// eslint-disable-next-line no-bitwise
diff --git a/app/assets/javascripts/ide/lib/editor_options.js b/app/assets/javascripts/ide/lib/editor_options.js
index f182a1ec50e..9f2a9a8cf4a 100644
--- a/app/assets/javascripts/ide/lib/editor_options.js
+++ b/app/assets/javascripts/ide/lib/editor_options.js
@@ -31,7 +31,7 @@ export const defaultModelOptions = {
export const editorOptions = [
{
- readOnly: model => Boolean(model.file.file_lock),
- quickSuggestions: model => !(model.language === 'markdown'),
+ readOnly: (model) => Boolean(model.file.file_lock),
+ quickSuggestions: (model) => !(model.language === 'markdown'),
},
];
diff --git a/app/assets/javascripts/ide/lib/editorconfig/parser.js b/app/assets/javascripts/ide/lib/editorconfig/parser.js
index 1597e4a8bfa..2adc643a15b 100644
--- a/app/assets/javascripts/ide/lib/editorconfig/parser.js
+++ b/app/assets/javascripts/ide/lib/editorconfig/parser.js
@@ -2,7 +2,7 @@ import { parseString } from 'editorconfig/src/lib/ini';
import minimatch from 'minimatch';
import { getPathParents } from '../../utils';
-const dirname = path => path.replace(/\.editorconfig$/, '');
+const dirname = (path) => path.replace(/\.editorconfig$/, '');
function isRootConfig(config) {
return config.some(([pattern, rules]) => !pattern && rules?.root === 'true');
@@ -44,11 +44,16 @@ function getRulesWithConfigs(filePath, configFiles = [], rules = {}) {
export function getRulesWithTraversal(filePath, getFileContent) {
const editorconfigPaths = [
- ...getPathParents(filePath).map(x => `${x}/.editorconfig`),
+ ...getPathParents(filePath).map((x) => `${x}/.editorconfig`),
'.editorconfig',
];
return Promise.all(
- editorconfigPaths.map(path => getFileContent(path).then(content => ({ path, content }))),
- ).then(results => getRulesWithConfigs(filePath, results.filter(x => x.content)));
+ editorconfigPaths.map((path) => getFileContent(path).then((content) => ({ path, content }))),
+ ).then((results) =>
+ getRulesWithConfigs(
+ filePath,
+ results.filter((x) => x.content),
+ ),
+ );
}
diff --git a/app/assets/javascripts/ide/lib/editorconfig/rules_mapper.js b/app/assets/javascripts/ide/lib/editorconfig/rules_mapper.js
index f9d5579511a..25ffa9a15be 100644
--- a/app/assets/javascripts/ide/lib/editorconfig/rules_mapper.js
+++ b/app/assets/javascripts/ide/lib/editorconfig/rules_mapper.js
@@ -1,23 +1,23 @@
import { isBoolean, isNumber } from 'lodash';
-const map = (key, validValues) => value =>
+const map = (key, validValues) => (value) =>
value in validValues ? { [key]: validValues[value] } : {};
-const bool = key => value => (isBoolean(value) ? { [key]: value } : {});
+const bool = (key) => (value) => (isBoolean(value) ? { [key]: value } : {});
-const int = (key, isValid) => value =>
+const int = (key, isValid) => (value) =>
isNumber(value) && isValid(value) ? { [key]: Math.trunc(value) } : {};
const rulesMapper = {
indent_style: map('insertSpaces', { tab: false, space: true }),
- indent_size: int('tabSize', n => n > 0),
- tab_width: int('tabSize', n => n > 0),
+ indent_size: int('tabSize', (n) => n > 0),
+ tab_width: int('tabSize', (n) => n > 0),
trim_trailing_whitespace: bool('trimTrailingWhitespace'),
end_of_line: map('endOfLine', { crlf: 1, lf: 0 }),
insert_final_newline: bool('insertFinalNewline'),
};
-const parseValue = x => {
+const parseValue = (x) => {
let value = typeof x === 'string' ? x.toLowerCase() : x;
if (/^[0-9.-]+$/.test(value)) value = Number(value);
if (value === 'true') value = true;
diff --git a/app/assets/javascripts/ide/lib/errors.js b/app/assets/javascripts/ide/lib/errors.js
index e62d9d1e77f..f975034a872 100644
--- a/app/assets/javascripts/ide/lib/errors.js
+++ b/app/assets/javascripts/ide/lib/errors.js
@@ -6,17 +6,17 @@ const CODEOWNERS_REGEX = /Push.*protected branches.*CODEOWNERS/;
const BRANCH_CHANGED_REGEX = /changed.*since.*start.*edit/;
const BRANCH_ALREADY_EXISTS = /branch.*already.*exists/;
-const createNewBranchAndCommit = store =>
+const createNewBranchAndCommit = (store) =>
store
.dispatch('commit/updateCommitAction', consts.COMMIT_TO_NEW_BRANCH)
.then(() => store.dispatch('commit/commitChanges'));
-export const createUnexpectedCommitError = message => ({
+export const createUnexpectedCommitError = (message) => ({
title: __('Unexpected error'),
messageHTML: escape(message) || __('Could not commit. An unexpected error occurred.'),
});
-export const createCodeownersCommitError = message => ({
+export const createCodeownersCommitError = (message) => ({
title: __('CODEOWNERS rule violation'),
messageHTML: escape(message),
primaryAction: {
@@ -25,7 +25,7 @@ export const createCodeownersCommitError = message => ({
},
});
-export const createBranchChangedCommitError = message => ({
+export const createBranchChangedCommitError = (message) => ({
title: __('Branch changed'),
messageHTML: `${escape(message)}<br/><br/>${__('Would you like to create a new branch?')}`,
primaryAction: {
@@ -34,19 +34,19 @@ export const createBranchChangedCommitError = message => ({
},
});
-export const branchAlreadyExistsCommitError = message => ({
+export const branchAlreadyExistsCommitError = (message) => ({
title: __('Branch already exists'),
messageHTML: `${escape(message)}<br/><br/>${__(
'Would you like to try auto-generating a branch name?',
)}`,
primaryAction: {
text: __('Create new branch'),
- callback: store =>
+ callback: (store) =>
store.dispatch('commit/addSuffixToBranchName').then(() => createNewBranchAndCommit(store)),
},
});
-export const parseCommitError = e => {
+export const parseCommitError = (e) => {
const { message } = e?.response?.data || {};
if (!message) {
diff --git a/app/assets/javascripts/ide/lib/files.js b/app/assets/javascripts/ide/lib/files.js
index 789e09fa8f2..3fdf012bbb2 100644
--- a/app/assets/javascripts/ide/lib/files.js
+++ b/app/assets/javascripts/ide/lib/files.js
@@ -1,6 +1,6 @@
import { decorateData, sortTree } from '../stores/utils';
-export const splitParent = path => {
+export const splitParent = (path) => {
const idx = path.lastIndexOf('/');
return {
@@ -11,8 +11,20 @@ export const splitParent = path => {
/**
* Create file objects from a list of file paths.
+ *
+ * @param {Array} options.data Array of blob paths to parse and create a file tree from.
+ * @param {Boolean} options.tempFile Web IDE flag for whether this is a "new" file or not.
+ * @param {String} options.content Content to initialize the new blob with.
+ * @param {String} options.rawPath Raw path used for the new blob.
+ * @param {Object} options.blobData Extra values to initialize each blob with.
*/
-export const decorateFiles = ({ data, tempFile = false, content = '', rawPath = '' }) => {
+export const decorateFiles = ({
+ data,
+ tempFile = false,
+ content = '',
+ rawPath = '',
+ blobData = {},
+}) => {
const treeList = [];
const entries = {};
@@ -20,7 +32,7 @@ export const decorateFiles = ({ data, tempFile = false, content = '', rawPath =
let file;
let parentPath;
- const insertParent = path => {
+ const insertParent = (path) => {
if (!path) {
return null;
} else if (entries[path]) {
@@ -55,7 +67,7 @@ export const decorateFiles = ({ data, tempFile = false, content = '', rawPath =
return tree;
};
- data.forEach(path => {
+ data.forEach((path) => {
const { parent, name } = splitParent(path);
const fileFolder = parent && insertParent(parent);
@@ -73,6 +85,7 @@ export const decorateFiles = ({ data, tempFile = false, content = '', rawPath =
content,
rawPath,
parentPath,
+ ...blobData,
});
Object.assign(entries, {
diff --git a/app/assets/javascripts/ide/lib/languages/hcl.js b/app/assets/javascripts/ide/lib/languages/hcl.js
index 4539719b1f2..bbb2ca66f33 100644
--- a/app/assets/javascripts/ide/lib/languages/hcl.js
+++ b/app/assets/javascripts/ide/lib/languages/hcl.js
@@ -11,7 +11,11 @@ const conf = {
lineComment: '//',
blockComment: ['/*', '*/'],
},
- brackets: [['{', '}'], ['[', ']'], ['(', ')']],
+ brackets: [
+ ['{', '}'],
+ ['[', ']'],
+ ['(', ')'],
+ ],
autoClosingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
@@ -140,7 +144,7 @@ const language = {
],
heredocBody: [
[
- /^([\w\-]+)$/,
+ /([\w\-]+)$/,
{
cases: {
'$1==$S2': [
@@ -161,7 +165,11 @@ const language = {
[/\/\/.*$/, 'comment'],
[/#.*$/, 'comment'],
],
- comment: [[/[^\/*]+/, 'comment'], [/\*\//, 'comment', '@pop'], [/[\/*]/, 'comment']],
+ comment: [
+ [/[^\/*]+/, 'comment'],
+ [/\*\//, 'comment', '@pop'],
+ [/[\/*]/, 'comment'],
+ ],
string: [
[/\$\{/, { token: 'delimiter', next: '@stringExpression' }],
[/[^\\"\$]+/, 'string'],
diff --git a/app/assets/javascripts/ide/lib/languages/vue.js b/app/assets/javascripts/ide/lib/languages/vue.js
index b9ff5c5d776..f2f81307981 100644
--- a/app/assets/javascripts/ide/lib/languages/vue.js
+++ b/app/assets/javascripts/ide/lib/languages/vue.js
@@ -37,7 +37,13 @@ const conf = {
blockComment: ['{{!--', '--}}'],
},
- brackets: [['<!--', '-->'], ['<', '>'], ['{{', '}}'], ['{', '}'], ['(', ')']],
+ brackets: [
+ ['<!--', '-->'],
+ ['<', '>'],
+ ['{{', '}}'],
+ ['{', '}'],
+ ['(', ')'],
+ ],
autoClosingPairs: [
{ open: '{', close: '}' },
diff --git a/app/assets/javascripts/ide/lib/mirror.js b/app/assets/javascripts/ide/lib/mirror.js
index a516c28ad7a..6f9cfec9465 100644
--- a/app/assets/javascripts/ide/lib/mirror.js
+++ b/app/assets/javascripts/ide/lib/mirror.js
@@ -12,23 +12,23 @@ export const MSG_CONNECTION_ERROR = __('Could not connect to Web IDE file mirror
const noop = () => {};
export const SERVICE_DELAY = 8000;
-const cancellableWait = time => {
+const cancellableWait = (time) => {
let timeoutId = 0;
const cancel = () => clearTimeout(timeoutId);
- const promise = new Promise(resolve => {
+ const promise = new Promise((resolve) => {
timeoutId = setTimeout(resolve, time);
});
return [promise, cancel];
};
-const isErrorResponse = error => error && error.code !== 0;
+const isErrorResponse = (error) => error && error.code !== 0;
-const isErrorPayload = payload => payload && payload.status_code !== 200;
+const isErrorPayload = (payload) => payload && payload.status_code !== 200;
-const getErrorFromResponse = data => {
+const getErrorFromResponse = (data) => {
if (isErrorResponse(data.error)) {
return { message: data.error.Message };
} else if (isErrorPayload(data.payload)) {
@@ -38,9 +38,9 @@ const getErrorFromResponse = data => {
return null;
};
-const getFullPath = path => mergeUrlParams({ service: SERVICE_NAME }, getWebSocketUrl(path));
+const getFullPath = (path) => mergeUrlParams({ service: SERVICE_NAME }, getWebSocketUrl(path));
-const createWebSocket = fullPath =>
+const createWebSocket = (fullPath) =>
new Promise((resolve, reject) => {
const socket = new WebSocket(fullPath, [PROTOCOL]);
const resetCallbacks = () => {
@@ -59,7 +59,7 @@ const createWebSocket = fullPath =>
};
});
-export const canConnect = ({ services = [] }) => services.some(name => name === SERVICE_NAME);
+export const canConnect = ({ services = [] }) => services.some((name) => name === SERVICE_NAME);
export const createMirror = () => {
let socket = null;
@@ -71,23 +71,23 @@ export const createMirror = () => {
cancelHandler = noop;
};
- const onCancelConnect = fn => {
+ const onCancelConnect = (fn) => {
cancelHandler = fn;
};
- const receiveMessage = ev => {
+ const receiveMessage = (ev) => {
const handle = nextMessageHandler;
nextMessageHandler = noop;
handle(JSON.parse(ev.data));
};
- const onNextMessage = fn => {
+ const onNextMessage = (fn) => {
nextMessageHandler = fn;
};
const waitForNextMessage = () =>
new Promise((resolve, reject) => {
- onNextMessage(data => {
+ onNextMessage((data) => {
const err = getErrorFromResponse(data);
if (err) {
@@ -133,7 +133,7 @@ export const createMirror = () => {
return wait
.then(() => createWebSocket(fullPath))
- .then(newSocket => {
+ .then((newSocket) => {
socket = newSocket;
socket.onmessage = receiveMessage;
});