-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 146e81e
Showing
13 changed files
with
5,109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data.js | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
env: | ||
es6: true | ||
node: true | ||
browser: true | ||
extends: eslint:recommended | ||
parserOptions: | ||
ecmaVersion: latest | ||
sourceType: module | ||
|
||
rules: | ||
# off OR 0 | ||
# warn OR 1 | ||
# error OR 2 | ||
|
||
no-console: error # disable console | ||
no-var: error ## disable var | ||
quotes: [error, single, { avoidEscape: true }] ## Use single quotes | ||
indent: [error, 2, { SwitchCase: 1 }] ## Indent two spaces | ||
comma-dangle: [error, never] ## Prohibit end commas | ||
semi: [error, never] ## Prohibit end semicolons | ||
arrow-parens: [error, always] ## Arguments to arrow functions must be enclosed in parentheses | ||
array-bracket-spacing: [error, never] ## Prohibit spaces inside the array brackets | ||
brace-style: error ## Force one true brace style | ||
camelcase: warn ## Force property name to hump style | ||
computed-property-spacing: [error, never] ## Prohibit the use of spaces within calculated attributes | ||
curly: [error, multi-line] ## https://cn.eslint.org/docs/rules/curly#multi | ||
eol-last: [error, always] ## Forced use of line feeds (LF) | ||
eqeqeq: [error, smart] ## https://cn.eslint.org/docs/rules/eqeqeq#smart | ||
max-depth: [error, 3] ## Maximum nesting depth for mandatory block statements | ||
max-len: [warn, 120] ## Line feed after 120 characters | ||
max-statements: [warn, 20] ## Limit the maximum number of statements in a function block | ||
new-cap: [warn, { capIsNew: false }] ## Requires constructors to be initialized with capital letters | ||
no-extend-native: error ## Disable extension of native types | ||
no-mixed-spaces-and-tabs: error ## Disable mixed indentation of spaces and tabs | ||
no-trailing-spaces: error ## Disable end-of-line spaces | ||
no-unused-vars: warn ## Prohibit the appearance of unused variables | ||
no-use-before-define: [error, nofunc] ## Prohibit the use of variables before they are defined | ||
object-curly-spacing: [error, always] ## No spaces in brackets allowed | ||
keyword-spacing: [error, { before: true, after: true }] ## Force the use of consistent spaces before and after keywords | ||
space-unary-ops: error ## Prohibit spaces before or after unary operators |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist | ||
node_modules | ||
data.js | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data.js | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
trailingComma: none # Whether to add a comma at the end of an object or array es5|none|all | ||
tabWidth: 2 # indent | ||
printWidth: 120 # Line feed after 120 characters | ||
semi: false # Whether to add a semicolon at the end | ||
singleQuote: true # Whether to use single quotes | ||
# always:(x) => x | ||
# avoid:x => x | ||
arrowParens: always # Arrow functions with only one argument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Lete114 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# zhconver | ||
|
||
Convert between Simplified Chinese and Traditional Chinese | ||
|
||
- **No dependencies.** | ||
- **Support for running in browsers and node.** | ||
- Support for modifying conversion characters. | ||
- Support Type Tips. | ||
- Small volume ([zhconver](https://packagephobia.com/result?p=zhconver) 15~20kB). | ||
|
||
## Install | ||
|
||
```bash | ||
npm install zhconver --save | ||
``` | ||
|
||
browsers | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/zhconver/dist/zhconver.js"></script> | ||
``` | ||
|
||
CommonJS | ||
|
||
```js | ||
const { cn2tw, tw2cn, set } = require('zhconver') | ||
``` | ||
|
||
ES Modules | ||
|
||
```js | ||
import { cn2tw, tw2cn, set } from 'zhconver' | ||
``` | ||
|
||
## Usage | ||
|
||
### cn2tw | ||
|
||
```js | ||
cn2tw('这是一段简体字') | ||
// => '這是壹段簡體字' | ||
``` | ||
|
||
### tw2cn | ||
|
||
```js | ||
tw2cn('這是壹段簡體字') | ||
// => '这是一段简体字' | ||
``` | ||
|
||
### set | ||
|
||
```js | ||
const mapper = [ | ||
['水', '💧'], | ||
['火', '🔥'], | ||
['龙', '🐉'] | ||
] | ||
set(mapper) | ||
console.log(cn2tw('我最喜欢吃的水果是火龙果')) | ||
// => '我最喜歡吃的💧果是🔥🐉果' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { readFileSync, writeFileSync } = require('fs') | ||
|
||
const data = JSON.parse(readFileSync('font.json', { encoding: 'utf8' })) | ||
|
||
let CN = 'export const CN = "' | ||
let TW = 'export const TW = "' | ||
|
||
for (const [key, value] of Object.entries(data)) { | ||
if (key === value) continue | ||
CN += key | ||
TW += value | ||
} | ||
CN += '"' | ||
TW += '"' | ||
|
||
const code = CN + '\n' + TW | ||
|
||
writeFileSync('data.js', code) |
Oops, something went wrong.