aboutsummaryrefslogtreecommitdiff
path: root/ext/js/core
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/core')
-rw-r--r--ext/js/core/object-utilities.js32
-rw-r--r--ext/js/core/utilities.js9
2 files changed, 32 insertions, 9 deletions
diff --git a/ext/js/core/object-utilities.js b/ext/js/core/object-utilities.js
new file mode 100644
index 00000000..8cbba7cd
--- /dev/null
+++ b/ext/js/core/object-utilities.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2024 Yomitan Authors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @param {unknown} value
+ * @returns {value is Record<string, unknown>}
+ */
+export function isObjectNotArray(value) {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+}
+
+/**
+ * @param {unknown} value
+ * @returns {value is Record<string|number|symbol, unknown>}
+ */
+export function isObject(value) {
+ return typeof value === 'object' && value !== null;
+}
diff --git a/ext/js/core/utilities.js b/ext/js/core/utilities.js
index 1b785e79..1428a744 100644
--- a/ext/js/core/utilities.js
+++ b/ext/js/core/utilities.js
@@ -17,15 +17,6 @@
*/
/**
- * Checks whether a given value is a non-array object.
- * @param {unknown} value The value to check.
- * @returns {boolean} `true` if the value is an object and not an array, `false` otherwise.
- */
-export function isObject(value) {
- return typeof value === 'object' && value !== null && !Array.isArray(value);
-}
-
-/**
* Converts any string into a form that can be passed into the RegExp constructor.
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
* @param {string} string The string to convert to a valid regular expression.