You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2025/04/10 02:45:58 UTC

(opendal) branch main updated: feat(bindings/nodejs): add check in js (#5996)

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new a70649927 feat(bindings/nodejs): add check in js (#5996)
a70649927 is described below

commit a70649927fcdaffceb4ba14b5b386846e2e692a4
Author: Asuka Minato <i...@asukaminato.eu.org>
AuthorDate: Thu Apr 10 11:45:53 2025 +0900

    feat(bindings/nodejs): add check in js (#5996)
    
    * add api
    
    * add test
    
    * rm a check
    
    * sep test
    
    * add codegen
---
 bindings/nodejs/generated.d.ts               |  9 +++++++++
 bindings/nodejs/src/lib.rs                   | 11 +++++++++++
 bindings/nodejs/tests/suites/async.suite.mjs |  4 ++++
 bindings/nodejs/tests/suites/sync.suite.mjs  |  4 ++++
 4 files changed, 28 insertions(+)

diff --git a/bindings/nodejs/generated.d.ts b/bindings/nodejs/generated.d.ts
index 7b4bb4632..9394c9e55 100644
--- a/bindings/nodejs/generated.d.ts
+++ b/bindings/nodejs/generated.d.ts
@@ -244,6 +244,15 @@ export class Operator {
    * ```
    */
   check(): Promise<void>
+  /**
+   * Check the op synchronously.
+   *
+   * ### Example
+   * ```javascript
+   * op.checkSync();
+   * ```
+   */
+  checkSync(): void
   /**
    * Check if this path exists or not.
    *
diff --git a/bindings/nodejs/src/lib.rs b/bindings/nodejs/src/lib.rs
index cda253fc4..d6e8ab06c 100644
--- a/bindings/nodejs/src/lib.rs
+++ b/bindings/nodejs/src/lib.rs
@@ -123,6 +123,17 @@ impl Operator {
         self.0.check().await.map_err(format_napi_error)
     }
 
+    /// Check the op synchronously.
+    ///
+    /// ### Example
+    /// ```javascript
+    /// op.checkSync();
+    /// ```
+    #[napi]
+    pub fn check_sync(&self) -> Result<()> {
+        self.0.blocking().check().map_err(format_napi_error)
+    }
+
     /// Check if this path exists or not.
     ///
     /// ### Example
diff --git a/bindings/nodejs/tests/suites/async.suite.mjs b/bindings/nodejs/tests/suites/async.suite.mjs
index 9431679a7..63844a349 100644
--- a/bindings/nodejs/tests/suites/async.suite.mjs
+++ b/bindings/nodejs/tests/suites/async.suite.mjs
@@ -114,5 +114,9 @@ export function run(op) {
         op.deleteSync(filename)
       }
     })
+
+    test.runIf(op.capability().list)('test check', async () => {
+      await op.check()
+    })
   })
 }
diff --git a/bindings/nodejs/tests/suites/sync.suite.mjs b/bindings/nodejs/tests/suites/sync.suite.mjs
index 504e3c67c..37781ed7b 100644
--- a/bindings/nodejs/tests/suites/sync.suite.mjs
+++ b/bindings/nodejs/tests/suites/sync.suite.mjs
@@ -111,5 +111,9 @@ export function run(op) {
         op.deleteSync(filename)
       }
     })
+
+    test.runIf(op.capability().list)('blocking check', () => {
+      op.checkSync()
+    })
   })
 }