summaryrefslogtreecommitdiff
path: root/ext/bg/js/mecab.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-08 19:40:49 -0500
committerGitHub <noreply@github.com>2021-02-08 19:40:49 -0500
commit0f5fb804d03041b58813516721d897c4315dca8b (patch)
tree40d637ea5e696b0da5f9d083d7069c64ad23717f /ext/bg/js/mecab.js
parent0ed24347ee275250bcd2c044a1b664f9f0273653 (diff)
Mecab test (#1361)
* Update Mecab API * Add testMecab API function * Add a test button for the Mecab component
Diffstat (limited to 'ext/bg/js/mecab.js')
-rw-r--r--ext/bg/js/mecab.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js
index ef5d6821..4eff2927 100644
--- a/ext/bg/js/mecab.js
+++ b/ext/bg/js/mecab.js
@@ -54,6 +54,39 @@ class Mecab {
}
/**
+ * Disconnects the current port, but does not disable future connections.
+ */
+ disconnect() {
+ if (this._port !== null) {
+ this._clearPort();
+ }
+ }
+
+ /**
+ * Returns whether or not the connection to the native application is active.
+ * @returns `true` if the connection is active, `false` otherwise.
+ */
+ isConnected() {
+ return (this._port !== null);
+ }
+
+ /**
+ * Returns whether or not any invocation is currently active.
+ * @returns `true` if an invocation is active, `false` otherwise.
+ */
+ isActive() {
+ return (this._invocations.size > 0);
+ }
+
+ /**
+ * Gets the local API version being used.
+ * @returns An integer representing the API version that Yomichan uses.
+ */
+ getLocalVersion() {
+ return this._version;
+ }
+
+ /**
* Gets the version of the MeCab component.
* @returns The version of the MeCab component, or `null` if the component was not found.
*/