-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: enhance camelize and genStringKey and update docs
- Loading branch information
Showing
21 changed files
with
357 additions
and
49 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
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,28 @@ | ||
export const generalItems = [ | ||
{ text: 'isString', link: '/general/is-string' }, | ||
{ text: 'isNumber', link: '/general/is-number' }, | ||
{ text: 'isNumeric', link: '/general/is-numeric' }, | ||
{ text: 'isBoolean', link: '/general/is-boolean' }, | ||
{ text: 'isTruthy', link: '/general/is-truthy' }, | ||
{ text: 'isPlainObject', link: '/general/is-plain-object' }, | ||
{ text: 'isObject', link: '/general/is-object' }, | ||
{ text: 'isArray', link: '/general/is-array' }, | ||
{ text: 'isNullish', link: '/general/is-nullish' }, | ||
{ text: 'isPromise', link: '/general/is-promise' }, | ||
{ text: 'isFunction', link: '/general/is-function' }, | ||
{ text: 'isDate', link: '/general/is-date' }, | ||
{ text: 'isSet', link: '/general/is-set' }, | ||
{ text: 'isMap', link: '/general/is-map' }, | ||
{ text: 'isSymbol', link: '/general/is-symbol' }, | ||
{ text: 'isWindow', link: '/general/is-window' }, | ||
{ text: 'isRegExp', link: '/general/is-reg-exp' }, | ||
{ text: 'isEmpty', link: '/general/is-empty' }, | ||
{ text: 'isNonEmptyArray', link: '/general/is-non-empty-array' }, | ||
{ text: 'inBrowser', link: '/general/in-browser' }, | ||
{ text: 'inMobile', link: '/general/in-mobile' }, | ||
{ text: 'hasOwn', link: '/general/has-own' }, | ||
{ text: 'supportTouch', link: '/general/support-touch' }, | ||
{ text: 'toTypeString', link: '/general/to-type-string' }, | ||
{ text: 'toRawType', link: '/general/to-raw-type' }, | ||
{ text: 'getGlobalThis', link: '/general/get-global-this' }, | ||
] |
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,3 @@ | ||
export * from './general' | ||
export * from './string' | ||
export * from './number' |
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,7 @@ | ||
export const numberItems = [ | ||
{ text: 'toNumber', link: '/number/to-number' }, | ||
{ text: 'genNumberKey', link: '/number/gen-number-key' }, | ||
{ text: 'randomNumber', link: '/number/random-number' }, | ||
{ text: 'clamp', link: '/number/clamp' }, | ||
{ text: 'clampArrayRange', link: '/number/clamp-array-range' }, | ||
] |
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 @@ | ||
export const stringItems = [ | ||
{ text: 'genStringKey', link: '/string/gen-string-key' }, | ||
{ text: 'camelize', link: '/string/camelize' }, | ||
{ text: 'kebabCase', link: '/string/kebab-case' }, | ||
{ text: 'pascalCase', link: '/string/pascal-case' }, | ||
{ text: 'capitalizeFirstLetter', link: '/string/capitalize-first-letter' }, | ||
{ text: 'slash', link: '/string/slash' }, | ||
] |
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
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,24 @@ | ||
# camelize | ||
|
||
Convert a string to `camelCase` | ||
|
||
### Usage | ||
|
||
```ts | ||
import { camelize } from 'rattail' | ||
|
||
camelize('hello-world') // return 'helloWorld' | ||
camelize('FooBar') // return 'fooBar' | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| --- | :----: | -------: | | ||
| `value` | `string` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `string` | |
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,24 @@ | ||
# capitalizeFirstLetter | ||
|
||
Capitalize the first letter of a string, leaving the rest of the string unchanged. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { capitalizeFirstLetter } from 'rattail' | ||
|
||
capitalizeFirstLetter('hello world') // return 'Hello world' | ||
capitalizeFirstLetter('rattail') // return 'Rattail' | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ------- | :------: | -------: | | ||
| `value` | `string` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `string` | |
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,19 @@ | ||
# genStringKey | ||
|
||
Generate a unique string key by incrementing a numeric value and converting it to a string | ||
|
||
### Usage | ||
|
||
```ts | ||
import { genStringKey } from 'rattail' | ||
|
||
genStringKey() // return 'generated-key-0' | ||
genStringKey() // return 'generated-key-1' | ||
genStringKey() // return 'generated-key-2' | ||
``` | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `string` | |
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,24 @@ | ||
# kebabCase | ||
|
||
Convert a string to `kebab-case` | ||
|
||
### Usage | ||
|
||
```ts | ||
import { kebabCase } from 'rattail' | ||
|
||
kebabCase('HelloWorld') // return 'hello-world' | ||
kebabCase('fooBar') // return 'foo-bar' | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| --- | :----: | -------: | | ||
| `value` | `string` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `string` | |
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,24 @@ | ||
pascalCase | ||
|
||
Convert a string to `PascalCase` | ||
|
||
### Usage | ||
|
||
```ts | ||
import { pascalCase } from 'rattail' | ||
|
||
pascalCase('hello-world') // return 'HelloWorld' | ||
pascalCase('fooBar') // return 'FooBar' | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ------- | :------: | -------: | | ||
| `value` | `string` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `string` | |
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,27 @@ | ||
# slash | ||
|
||
Convert all backslashes (`\`) in a path to forward slashes (`/`). If the path starts with `\\?\`, indicating an extended-length path, it is returned as-is without modification. | ||
|
||
### Usage | ||
|
||
```ts | ||
import { slash } from 'rattail' | ||
|
||
slash('C:\\path\\to\\file') | ||
// return 'C:/path/to/file' | ||
|
||
slash('\\\\?\\C:\\path\\to\\file') | ||
// return '\\\\?\\C:\\path\\to\\file' (unmodified) | ||
``` | ||
|
||
### Arguments | ||
|
||
| Arg | Type | Defaults | | ||
| ------ | :------: | -------: | | ||
| `path` | `string` | | | ||
|
||
### Return | ||
|
||
| Type | | ||
| :------: | | ||
| `string` | |
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
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,24 @@ | ||
# camelize | ||
|
||
将字符串转换为 camelCase 格式 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { camelize } from 'rattail' | ||
|
||
camelize('hello-world') // return 'helloWorld' | ||
camelize('FooBar') // return 'fooBar' | ||
``` | ||
|
||
### 参数列表 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| ------- | :------: | -----: | | ||
| `value` | `string` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| :------: | | ||
| `string` | |
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,24 @@ | ||
# capitalizeFirstLetter | ||
|
||
将字符串的首字母大写,其余部分保持不变 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { capitalizeFirstLetter } from 'rattail' | ||
|
||
capitalizeFirstLetter('hello world') // return 'Hello world' | ||
capitalizeFirstLetter('rattail') // return 'Rattail' | ||
``` | ||
|
||
### 参数列表 | ||
|
||
| 参数 | 类型 | 默认值 | | ||
| ------- | :------: | -----: | | ||
| `value` | `string` | | | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| :------: | | ||
| `string` | |
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,19 @@ | ||
# genStringKey | ||
|
||
生成一个唯一的字符串键,通过递增数字值并将其转换为字符串 | ||
|
||
### 使用 | ||
|
||
```ts | ||
import { genStringKey } from 'rattail' | ||
|
||
genStringKey() // return 'generated-key-0' | ||
genStringKey() // return 'generated-key-1' | ||
genStringKey() // return 'generated-key-2' | ||
``` | ||
|
||
### 返回值 | ||
|
||
| 类型 | | ||
| :------: | | ||
| `string` | |
Oops, something went wrong.