
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
轻量级简繁体中文转换工具,ESM、CJS、IIFE 三种模块格式。
fanti# npm
npm install fanti
# yarn
yarn add fanti
# pnpm
pnpm add fanti
import { toFanti, toJianti, isFanti } from 'fanti';
// 简体转繁体
console.log(toFanti('简体中文转繁体')); // 输出: 簡體中文轉繁體
// 繁体转简体
console.log(toJianti('繁體中文轉簡體')); // 输出: 繁体中文转简体
// 判断是否为繁体字
console.log(isFanti('轉')); // true
console.log(isFanti('转')); // false
const { toFanti, toJianti } = require('fanti');
console.log(toFanti('CommonJS 模块测试')); // 输出: CommonJS 模組測試
<!-- 通过 CDN 引入 -->
<script src="https://unpkg.com/fanti@latest/dist/fanti.iife.js"></script>
<!-- 或本地引入 -->
<script src="./node_modules/fanti/dist/fanti.iife.js"></script>
<script>
// 通过全局变量 fanti 访问
console.log(fanti.toFanti('全局变量使用')); // 输出: 全局變量使用
console.log(fanti.toJianti('IIFE 格式測試')); // 输出: IIFE 格式测试
</script>
toFanti(text: string): string将简体中文转换为繁体中文。
text - 待转换的简体字符串(非字符串类型会抛出 TypeError)console.log(toFanti('你好,世界')); // 输出: 你好,世界
toJianti(text: string): string将繁体中文转换为简体中文。
text - 待转换的繁体字符串(非字符串类型会抛出 TypeError)console.log(toJianti('臺灣')); // 输出: 台湾
isFanti(char: string): boolean判断单个字符是否为繁体字。
char - 待检测的单个字符(非单字符会抛出 TypeError)true 表示是繁体字,false 表示不是console.log(isFanti('灣')); // true
console.log(isFanti('湾')); // false
安装后可在 node_modules/fanti/dist 目录获取以下文件:
| 文件 | 模块类型 | 适用场景 |
|---|---|---|
fanti.esm.js | ESM | 现代前端工程化项目 |
fanti.cjs.js | CJS | Node.js 项目 |
fanti.iife.js | IIFE | 传统 HTML 页面、全局变量使用 |
fanti.d.ts | TypeScript | 类型定义文件 |
import { toFanti } from 'fanti';
const sentences = ['简体测试', '繁體測試'];
const convertedSentences = sentences.map((text) => toFanti(text));
console.log(convertedSentences); // 输出: ['簡體測試', '繁體測試']
import React from 'react';
import { toFanti } from 'fanti';
const App = () => {
const text = '简体中文转繁体';
return <div>{toFanti(text)}</div>;
};
export default App;
查看 CHANGELOG.md 了解版本迭代记录。
如遇转换错误或功能建议,请在 GitHub Issues 提交反馈。
欢迎提交 Pull Request 或 Issue!请遵循以下规范:
MIT © 2025
FAQs
轻量级简繁体中文转换工具,ESM、CJS、IIFE 三种模块格式。
The npm package fanti receives a total of 13 weekly downloads. As such, fanti popularity was classified as not popular.
We found that fanti demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.