Skip to content

Commit

Permalink
chore(release): 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lete114 committed Mar 10, 2023
0 parents commit 146e81e
Show file tree
Hide file tree
Showing 13 changed files with 5,109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data.js
dist
40 changes: 40 additions & 0 deletions .eslintrc.yml
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
data.js
pnpm-lock.yaml
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data.js
dist
8 changes: 8 additions & 0 deletions .prettierrc.yml
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
9 changes: 9 additions & 0 deletions LICENSE
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.
62 changes: 62 additions & 0 deletions README.md
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('我最喜欢吃的水果是火龙果'))
// => '我最喜歡吃的💧果是🔥🐉果'
```
18 changes: 18 additions & 0 deletions build.cjs
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)
Loading

0 comments on commit 146e81e

Please sign in to comment.