Commit 2a84e764 authored by Denys Mishunov's avatar Denys Mishunov

Applying reviewer's suggestion

parent 7dbdf10e
...@@ -100,14 +100,13 @@ export default class EditorInstance { ...@@ -100,14 +100,13 @@ export default class EditorInstance {
static useUnuse(extensionsStore, fn, extensions) { static useUnuse(extensionsStore, fn, extensions) {
if (Array.isArray(extensions)) { if (Array.isArray(extensions)) {
if (!extensions.length) { /**
return fn.call(this, extensionsStore, undefined); * We cut short if the Array is empty and let the destination function to throw
} * Otherwise, we run the destination function on every entry of the Array
const exts = new Array(extensions.length); */
extensions.forEach((ext, i) => { return extensions.length
exts[i] = fn.call(this, extensionsStore, ext); ? extensions.map(fn.bind(this, extensionsStore))
}); : fn.call(this, extensionsStore);
return exts;
} }
return fn.call(this, extensionsStore, extensions); return fn.call(this, extensionsStore, extensions);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment