« get me outta code hell

annotate bindOpts function name - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-04-24 21:52:57 -0300
committer(quasar) nebula <qznebula@protonmail.com>2022-04-24 21:52:57 -0300
commit8e0c17d921cb57970dc9a681c07e44aace790082 (patch)
tree4048fb9aefdf7c12120a4b3e507b2a807a4542cc /src/util
parent2edbfa62f627469d399917d77d44474fc7b0679c (diff)
annotate bindOpts function name
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sugar.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js
index f425989b..99f706f1 100644
--- a/src/util/sugar.js
+++ b/src/util/sugar.js
@@ -82,10 +82,16 @@ export function escapeRegex(string) {
 export function bindOpts(fn, bind) {
     const bindIndex = bind[bindOpts.bindIndex] ?? 1;
 
-    return (...args) => {
+    const bound = function(...args) {
         const opts = args[bindIndex] ?? {};
         return fn(...args.slice(0, bindIndex), {...bind, ...opts});
     };
+
+    Object.defineProperty(bound, 'name', {
+        value: (fn.name ? `(options-bound) ${fn.name}` : `(options-bound)`)
+    });
+
+    return bound;
 }
 
 bindOpts.bindIndex = Symbol();