-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES6: migrated "util" #1114
ES6: migrated "util" #1114
Conversation
app/script/main/app.coffee
Outdated
@@ -239,7 +239,7 @@ class z.main.App | |||
if is_reload and error.type not in [z.client.ClientError.TYPE.MISSING_ON_BACKEND, z.client.ClientError.TYPE.NO_LOCAL_CLIENT] | |||
@auth.client.execute_on_connectivity(z.service.Client::CONNECTIVITY_CHECK_TRIGGER.APP_INIT_RELOAD).then -> window.location.reload false | |||
else if navigator.onLine | |||
@logger.error "Caused by: #{error?.message or error}" | |||
@logger.error "Caused by: #{error?.message or error}", error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problematic. If error is a string as it sometimes is and not the error object, we will end up with a log message that does no longer contain the "Caused by reference". Maybe we should be more explicit and do a proper _.isObject check with tow error logging cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this is due to our logger implementation, right?
return undefined; | ||
} | ||
|
||
for (let i = next_index; i <= array.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a proper array. We can use that:
for (const item of array) {
if(!_.isFunction(filter) || !!filter(item)) {
return item
}
}
let hash = uint32.toUint32(0); | ||
const key = str.toLowerCase(); | ||
|
||
for (let i = 0; i <= key.length - 1; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const index of [0..key.length - 1])
new_array[0] = array[0]; | ||
new_array[length - 1] = array[array.length - 1]; | ||
|
||
for (let i = 1; i < length - 1; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const index of [0..length - 1])
app/script/util/DebugUtil.js
Outdated
this.logger = new z.util.Logger('z.util.DebugUtil', z.config.LOGGER.OPTIONS); | ||
this.user_repository = user_repository; | ||
|
||
this.get_event_info = this.get_event_info.bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for these
app/script/util/util.js
Outdated
return window.URL.revokeObjectURL(object_url); | ||
}; | ||
img.onerror = reject; | ||
return img.src = object_url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return
app/script/util/util.js
Outdated
return resolve(this.result); | ||
}; | ||
reader.onerror = reject; | ||
return reader.readAsArrayBuffer(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return
app/script/util/util.js
Outdated
if (typeof xhr_accessor_function === 'function') { | ||
xhr_accessor_function(xhr); | ||
} | ||
return xhr.send(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return
app/script/util/util.js
Outdated
return resolve([xhr.response, xhr.getResponseHeader('content-type')]); | ||
} | ||
return reject(new Error(`Requesting arraybuffer failed with status ${xhr.status}`)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird empty line
app/script/util/worker.js
Outdated
const worker = new window.Worker(uri); | ||
worker.onmessage = (event) => resolve(event.data); | ||
worker.onerror = (error) => reject(error); | ||
return worker.postMessage(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return
PromiseQueue.coffee
will not be part of this conversion as per request from @gregor (he will convert it later).