# lcz-utils **Repository Path**: webchuanzhou/lcz-utils ## Basic Information - **Project Name**: lcz-utils - **Description**: 工具库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-08-16 - **Last Updated**: 2022-11-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # `lcz-utils` ## omit - 排除 key ```ts let obj = { a: '12', b: '34', c: '56', } const output = { b: '34', c: '56', } omit(obj, ['a']) ``` ## uuid - 获取唯一 ID ```ts uuid() ``` ## to - 减少 try catch 拦截 ```ts const [error, data] = await to(api) if (error) { } ``` ## regForm ```ts 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 的参数 ```ts getQueryString('code') ``` ## isWeiXin - 是否在微信内置浏览器 ```ts isWeiXin() ``` ## deleteEmptyProperty - 删除对象中空值 ```ts let obj = { a: '12', b: '34', c: '', } let output = { a: '12', b: '34', } deleteEmptyProperty(obj) ``` ## arrify ```ts arrify('🦄') //=> ['🦄'] arrify(['🦄']) //=> ['🦄'] arrify(new Set(['🦄'])) //=> ['🦄'] arrify(null) //=> [] arrify(undefined) //=> [] ``` ## isCalc ```ts isCalc('calc(100% - 20px)') true ``` ## pick - 获取 key ```ts let obj = { a: '12', b: '34', c: '56', } const output = { b: '34', c: '56', } pick(obj, ['a']) ```