codestar-string-util

1.2.1 • Public • Published

字符串常用方法

import stringUtil from "codestar-string-util";

字符串转数组

stringUtil.textToArray(text: string, separator = "\n", trimBlank = true): string[]
example:
 expect(stringUtil.textToArray(`
    1
    2
    `)).toStrictEqual(['1', '2'])

驼峰转下划线

  expect(stringUtil.camelToUnderline('userName')).toBe('user_name')
  expect(stringUtil.camelToUnderline('UserName')).toBe('user_name')

下划线转驼峰

  expect(stringUtil.underlineToCamel('user_name')).toBe('userName')

去掉字符串中的utf8-bom

stringUtil.stripBom(string: string): string

Readme

Keywords

none

Package Sidebar

Install

npm i codestar-string-util

Weekly Downloads

2

Version

1.2.1

License

ISC

Unpacked Size

3.08 kB

Total Files

4

Last publish

Collaborators

  • tangmanong