@webchuanzhou96/lcz-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

lcz-utils

omit

  • 排除 key
let obj = {
  a: '12',
  b: '34',
  c: '56',
}
const output = {
  b: '34',
  c: '56',
}
omit(obj, ['a'])

uuid

  • 获取唯一 ID
uuid()

to

  • 减少 try catch 拦截
const [error, data] = await to(api)
if (error) {
}

regForm

const rules = {
  phone: [
    {
      require: true,
      errorMsg: '请输入账号',
    },
    {
      reg: /^1[3456789]\d{9}$/,
      errorMsg: '手机号码不合法',
    },
  ],
  password: {
    require: true,
    errorMsg: '请输入密码',
  },
}
let form = {
  phone: '187655478',
  password: '',
}
let [errInfo, status] = regFrom(form, rules)
if (errInfo && !status) {
  //提示有错
}

getQueryString

  • 获取 url 的参数
getQueryString('code')

isWeiXin

  • 是否在微信内置浏览器
isWeiXin()

deleteEmptyProperty

  • 删除对象中空值
let obj = {
  a: '12',
  b: '34',
  c: '',
}
let output = {
  a: '12',
  b: '34',
}
deleteEmptyProperty(obj)

arrify

arrify('🦄')
//=> ['🦄']

arrify(['🦄'])
//=> ['🦄']

arrify(new Set(['🦄']))
//=> ['🦄']

arrify(null)
//=> []

arrify(undefined)
//=> []

isCalc

isCalc('calc(100% - 20px)') true

pick

  • 获取 key
let obj = {
  a: '12',
  b: '34',
  c: '56',
}
const output = {
  b: '34',
  c: '56',
}
pick(obj, ['a'])

Readme

Keywords

Package Sidebar

Install

npm i @webchuanzhou96/lcz-utils

Weekly Downloads

1

Version

1.0.7

License

ISC

Unpacked Size

16.4 kB

Total Files

34

Last publish

Collaborators

  • webchuanzhou96