@ 贴出/ 共享
为 Esposter 平台提供共享的TypeScript 工具,类型和出错类别.
设计笔记在现场 规格。 。 。 .
目录
开始
安装软件包和 Zod .
pnpm i @esposter/shared zod
该软件包在浏览器和服务器环境中工作.
QQ 密钥导出
错误分类
import { InvalidOperationError, NotFoundError, ForbiddenError, NotInitializedError } from "@esposter/shared";
throw new InvalidOperationError(Operation.Read, file.name, zodError.message);
阵列公用事业
import { takeOne } from "@esposter/shared";
// The first item, typed without `undefined`; an out-of-bounds index still yields `undefined` at runtime
const first = takeOne(items);
类型公用事业
import type { ToData, DeepOmit, GetPaths } from "@esposter/shared";
// ToData<T> — the plain data shape of T, with its `toJSON` method removed at every depth
type RawColumn = ToData<Column>;
反应
import { toRawDeep, getRawData } from "@esposter/shared";
// Recursively unwrap Vue reactive proxies
const raw = toRawDeep(reactiveObject);
文本 / 字符串
import { capitalize, truncate, toKebabCase } from "@esposter/shared";
错误处理( 反应模式)
import { getResult, getResultAsync, withFinalizer } from "@esposter/shared";
许可证
本项目根据以下规定获得许可证: Apache-2.0 许可证。 。 。 .