From 84f2e6dd3d11b47ce44f036c7bc7b25794191c2d Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Thu, 18 Apr 2024 09:00:06 +1000 Subject: [PATCH] Changing spacing parameter --- package.json | 2 +- readme.md | 16 ++++++++-------- src/index.ts | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index d5394d8..f011094 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arsene", - "version": "1.0.1", + "version": "1.1.0", "description": "Arsene is a library for processing CJK text paragraphs, which are mixed with English characters and adding spacing between them.", "author": "Astrian Zheng", "keywords": [ diff --git a/readme.md b/readme.md index 779ecfb..03aba82 100644 --- a/readme.md +++ b/readme.md @@ -33,19 +33,19 @@ function App() { ``` ## 额外功能 -### 自定义空格宽度 +### 自定义间隙宽度 ```ts -arsene(selectedNode: string, spacing: 3|4|5|6|10 = 10) +arsene(selectedNode: string, spacing: 's'|'m'|'l'|'xl'|'2xl' = 10) // sample arsene(node, 5) ``` -你可以在第二个参数中选择一个你认为合适的空格宽度。可选参数如下: +你可以在第二个参数中选择一个你认为合适的间隙宽度。可选参数如下: -- `3`:添加 1/3 em 空格 `U+2004` -- `4`:添加 1/4 em 空格 `U+2005` -- `5`:添加 1/5 em 空格 `U+2009` -- `6`:添加 1/6 em 空格 `U+2006` -- `10`:添加小空隙 `U+200A` +- `2xl`:添加非常大间隙 `U+2004` +- `xl`:添加超大间隙 `U+2005` +- `l`:添加大间隙 `U+2009` +- `m`:添加中间隙 `U+2006` +- `s`:添加小间隙 `U+200A` 默认(不填写第二个参数时)将添加 `U+200A`。 \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6647ebc..216a079 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,19 +1,19 @@ -export default function (selectedNode: string, spacing: 3|4|5|6|10 = 10) { +export default function (selectedNode: string, spacing: '2xl'|'xl'|'l'|'m'|'s' = 's') { let spacingCharacter = '' switch (spacing) { - case 3: + case '2xl': spacingCharacter = '\u2004' break - case 4: + case 'xl': spacingCharacter = '\u2005' break - case 5: + case 'l': spacingCharacter = '\u2009' break - case 6: + case 'm': spacingCharacter = '\u2006' break - case 10: + case 's': spacingCharacter = '\u200A' break default: