php-trim-plus - PHP风格的trim函数加强版
PHP的trim比较好用,但默认trim如果指定了charList,则只截取charList中的文本,默认的空格(换行字符等)就不处理了,修改了次模式,默认为追加模式,即whitespace + charList。
安装说明
npm install php-trim-plus --save// oryarn add php-trim-plus
使用说明
默认打包的版本(index.js),已经将依赖的 lodash 整合打包。
trim.js 未打包 lodash
const trim ltrim rtrim toSafeString isSymbol isString isEmptyString isEmptyStringOrWhitespace = ;// or;
; // '开源中国'; // '红薯'
str: string
要截取的字符串
charList: string
要额外截取的字符串
isPlus: boolean
对 charList 是在现有空字符的基础上追加 charList,默认为 true,trim.Replace
or trim.Plus
; // 'a/b/c'
将字符串转为安全字符串。
如果 value 为数组类型,会将数组打扁 flattenDeep 后,再join,可以指定第二参数 spr
字符串转换,默认增加了 value.normalize()
转换 unicode。
;
lodash.isString 的引用
; ; // true; // true; // true; // false; // false
是否为空白字符串,这里不会对 value
进行trim,如果需要检查是否为纯粹的空格,请使用 isEmptyStringOrWhitespace
。
; ; // true; // true; // true; // true; // true; // true; // false; // false
是否为空白字符串或者是只包含空格符号的空白字符串,这里对 value
进行trim。
;
判断值是否为Symbol