@shencom/utils-string
v1.3.0
Published
字符串相关工具方法
Downloads
108
Readme
@shencom/utils-string
字符串相关工具方法
Install
pnpm add @shencom/utils
# or
pnpm add @shencom/utils-string
Basic Usage
import { StringToArray } from '@shencom/utils';
// import { StringToArray } from '@shencom/utils-string';
Methods
StringToArray
- 说明: 字符串转数组
- 类型:
(data?: string[] | string, separator?: string): string[]
- 参数:
data
- 需要转换的字符串separator
- 分隔符
- 示例:
StringToArray(''); // [] StringToArray(undefined); // [] StringToArray('aa,bb'); // ['aa', 'bb'] StringToArray('aa|bb', '|'); // ['aa', 'bb'] StringToArray(['1', '2', '3']); // ['1', '2', '3']
StringToHash
- 说明: 将字符串转换为哈希值
- 类型:
(path: string): number
- 参数:
path
- 需要转换的字符串
- 示例:
StringToHash('hello'); // 99162322 StringToHash('HelloWorld'); // 439329280