@assistant-ui/react
Version:
Typescript/React library for AI Chat
62 lines (61 loc) • 2.08 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/json/is-json.ts
var is_json_exports = {};
__export(is_json_exports, {
isJSONArray: () => isJSONArray,
isJSONObject: () => isJSONObject,
isJSONValue: () => isJSONValue
});
module.exports = __toCommonJS(is_json_exports);
function isJSONValue(value, currentDepth = 0) {
if (currentDepth > 100) {
return false;
}
if (value === null || typeof value === "string" || typeof value === "boolean") {
return true;
}
if (typeof value === "number") {
return !Number.isNaN(value) && Number.isFinite(value);
}
if (Array.isArray(value)) {
return value.every((item) => isJSONValue(item, currentDepth + 1));
}
if (typeof value === "object") {
return Object.entries(value).every(
([key, val]) => typeof key === "string" && isJSONValue(val, currentDepth + 1)
);
}
return false;
}
function isJSONArray(value) {
return Array.isArray(value) && value.every(isJSONValue);
}
function isJSONObject(value) {
return value != null && typeof value === "object" && Object.entries(value).every(
([key, val]) => typeof key === "string" && isJSONValue(val)
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
isJSONArray,
isJSONObject,
isJSONValue
});
//# sourceMappingURL=is-json.js.map
;