diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2023-11-22 22:11:20 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 12:11:20 +0100 |
commit | 616354e76cba0be8af20a0ffefeacfcf6101bafc (patch) | |
tree | c832c81dd93498e196840c8d59c0a4ab76396d07 /test_ffi/tests | |
parent | 0ffcb46e0f60110c07e21151db6066f5a1b5f710 (diff) |
refactor: replace `deferred()` from `std/async` with `Promise.withResolvers()` (#21234)
Closes #21041
---------
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Diffstat (limited to 'test_ffi/tests')
-rw-r--r-- | test_ffi/tests/test.js | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/test_ffi/tests/test.js b/test_ffi/tests/test.js index 9f6cc4547..b91dc43de 100644 --- a/test_ffi/tests/test.js +++ b/test_ffi/tests/test.js @@ -482,30 +482,12 @@ function test_fill_buffer(fillValue, arr) { test_fill_buffer(0, [2, 3, 4]); test_fill_buffer(5, [2, 7, 3, 2, 1]); -// Test non blocking calls - -function deferred() { - let methods; - const promise = new Promise((resolve, reject) => { - methods = { - async resolve(value) { - await value; - resolve(value); - }, - reject(reason) { - reject(reason); - }, - }; - }); - return Object.assign(promise, methods); -} - -const promise = deferred(); +const deferred = Promise.withResolvers(); const buffer3 = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); dylib.symbols.nonblocking_buffer(buffer3, buffer3.length).then(() => { - promise.resolve(); + deferred.resolve(); }); -await promise; +await deferred.promise; let start = performance.now(); dylib.symbols.sleep_blocking(100); |