web-streams 0.1.3

WASM bindings for the Streams API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use wasm_bindgen::prelude::*;
use web_sys::js_sys;

/// A helper to ignore the result of a promise.
pub(crate) trait PromiseExt {
	fn ignore(self);
}

impl PromiseExt for js_sys::Promise {
	// Ignore the result of the promise by using an empty catch.
	fn ignore(self) {
		let closure = Closure::wrap(Box::new(|_: JsValue| {}) as Box<dyn FnMut(JsValue)>);
		let _ = self.catch(&closure);
		closure.forget();
	}
}