1.1.0 • Published 10 months ago

mictools v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

String

initialUppercaseRemaLowercase 首字母大写,其余字母小写

 initialUppercaseRemaLowercase('hello world')   =>  Hello world

getType 判断当前类型, 返回值为 Number -> String ->Boolean -> Undefined ->Null -> Object

 getType('hello world')   =>  String
 getType(Null)   =>  Null
 getType({})   =>  Object
 getType(undefined)   =>  Undefined
 getType([])   =>  Array

isString 判断是否是字符串

 isString('hello world')   =>   true

获取 对象、数组、字符串长度

 getLen('hello')   =>   5
 getLen({ name: 'test'})   =>   1
 getLen([])   =>   0

将字符串转成小写

convertToLowerCase('test')  =>  test

将字符串转成大写

convertToLowerCase('test')  =>  test

Object

判断当前对象是否为空

isEmptyObject({})  =>  true

将对象转成成字符串 url 地址

objectConvertToUrl({a:1,b:2})  => a=1&b=2

对象根据属性设置值

objectMappAssignment({a:1, b:2, c:{d: 4}}, 'c', 'test')  => {a:1, b:2, c: 'test'}

数组

查询数组中元素是否存在;或者查询到进行赋值

checkElementAssignment(
  [
    { id: 1, name: "323" },
    { id: 2, name: "ddfdfdf" },
  ],
  "id",
  1,
  {
    type: "query",
    newValue: {
      id: 33333,
      name: "lishi",
    },
  }
);   => type === 'query', 则返回 true/false;  => type ==='assignment',则进行赋值 =>
     [
        { id: 1, name: "323" },
        { id: 33333, name: "lishi" }
    ]

Route

动态获取浏览器路径参数值

getRouteParameters('a')  =>   'http://www.test.com?a=1&b=2'   =>    1

RegExp

校验邮箱格式是否正确

validatorEmail('test')  =>  false
validatorEmail('test@qq.com')  =>  true

校验手机号格式是否正确

validatorPhone('test')  =>  false
validatorEmail('13515246129')  =>  true
1.1.0

10 months ago

1.0.9

10 months ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago