mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 12:10:24 +00:00
Initial commit of eigent-main
This commit is contained in:
commit
723df5a03e
1144 changed files with 103478 additions and 0 deletions
31
package/@stackframe/stack-shared/dist/esm/utils/json.js
vendored
Normal file
31
package/@stackframe/stack-shared/dist/esm/utils/json.js
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// src/utils/json.tsx
|
||||
import { Result } from "./results";
|
||||
function isJson(value) {
|
||||
switch (typeof value) {
|
||||
case "object": {
|
||||
if (value === null) return true;
|
||||
if (Array.isArray(value)) return value.every(isJson);
|
||||
return Object.keys(value).every((k) => typeof k === "string") && Object.values(value).every(isJson);
|
||||
}
|
||||
case "string":
|
||||
case "number":
|
||||
case "boolean": {
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
function parseJson(json) {
|
||||
return Result.fromThrowing(() => JSON.parse(json));
|
||||
}
|
||||
function stringifyJson(json) {
|
||||
return Result.fromThrowing(() => JSON.stringify(json));
|
||||
}
|
||||
export {
|
||||
isJson,
|
||||
parseJson,
|
||||
stringifyJson
|
||||
};
|
||||
//# sourceMappingURL=json.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue