aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils/promise.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2020-04-28 22:20:49 +1000
committerGitHub <noreply@github.com>2020-04-28 22:20:49 +1000
commit99a26d65cf78851878841c5afc54830f1222ccb1 (patch)
tree6a2bf12ecfa2314725e6d8961ec9f6a986b5003b /src/js/utils/promise.js
parent6aa21c1fae4a7b6dbcf1db1ee3b06f11d674869a (diff)
parent4915cf0120870db4a52b3be117efa22f8ca2bd3e (diff)
downloadplyr-99a26d65cf78851878841c5afc54830f1222ccb1.tar.lz
plyr-99a26d65cf78851878841c5afc54830f1222ccb1.tar.xz
plyr-99a26d65cf78851878841c5afc54830f1222ccb1.zip
Merge pull request #1796 from sampotts/develop
v3.6.0
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 };