Skip to content

fix: improve type safety and support synchronous return for strings#114

Open
jin-sir wants to merge 2 commits into
DTStack:masterfrom
jin-sir:fix_toBase64
Open

fix: improve type safety and support synchronous return for strings#114
jin-sir wants to merge 2 commits into
DTStack:masterfrom
jin-sir:fix_toBase64

Conversation

@jin-sir

@jin-sir jin-sir commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

变更内容

  • 添加函数重载,提升类型推断能力
  • 字符串输入时同步返回 string | undefined,无需异步操作
  • File/Blob 输入时返回 Promise<string | ArrayBuffer | null>
  • 使用 instanceof Blob 替代 getTypeOfValue 进行类型检查
  • 移除对 getTypeOfValue 的依赖

变更原因

  • 字符串编码不需要异步操作,同步返回即可
  • 提升 TypeScript 类型安全性和开发体验

@jin-sir jin-sir requested a review from liuxy0551 June 17, 2026 13:39
Comment thread src/toBase64/index.ts
Comment thread src/toBase64/__test__/index.test.ts Outdated
Comment thread src/toBase64/__test__/index.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants