aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils/promise.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/utils/promise.js')
-rw-r--r--src/js/utils/promise.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/js/utils/promise.js b/src/js/utils/promise.js
new file mode 100644
index 00000000..4b59bba3
--- /dev/null
+++ b/src/js/utils/promise.js
@@ -0,0 +1,14 @@
+import is from './is';
+/**
+ * Silence a Promise-like object.
+ * This is useful for avoiding non-harmful, but potentially confusing "uncaught
+ * play promise" rejection error messages.
+ * @param {Object} value An object that may or may not be `Promise`-like.
+ */
+export function silencePromise(value) {
+ if (is.promise(value)) {
+ value.then(null, () => {});
+ }
+}
+
+export default { silencePromise };