@yongzhiluo/js-tools
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

@yongzhiluo/js-tools


Installation


Using npm:

npm i --save @yongzhiluo/js-tools

lead into

import _ from '@yongzhiluo/js-tools'
// 或
const _ = requrie('@yongzhiluo/js-tools')

Usage method


“checkType” Methods

_.isNumber(1);
// => true

_.isBoolean(true);
// => true

_.isPlainObject({});
// => true

_.isPromise(Promise.resolve());
// => true

_.isUndefined(undefined);
// => true

_.isNull(null);
// => true

_.isString('1');
// => true

_.isSymbol(Symbol('1'));
// => true

_.isDate(new Date());
// => true

_.isError(new Error('1'));
// => true

_.isFunction(fn);
// => true

_.isEmptyObject({});
// => true

“math” Methods

// 保留小数点几位数, 自动补零, 四舍五入
_.currencyFixed(666.666,2);
// => 666.67

// 加法运算
_.numAdd(66.66,0.111);
// => 66.771

// 减法运算
_.numSub(66.66,0.111);
// => 66.549

// 乘法运算
_.numMul(66.66,0.111);
// => 7.39926

// 除法运算
_.numDiv(66.66,0.111);
// => 600.5405405405405

“localStorage” Methods

// 增加
_.set(key, value);

// 获取
_.get(key);

// 删除
_.remove(key);

// 清除
_.clear();

“String” Methods

// 复制字符串
_.copyString('待复制的字符串', 复制成功后的回调函数)

// 11位手机号码正则验证
_.verifyConfig.isPhoneNum(15688888888)
// => true

// 身份证号码
_.verifyConfig.isIdCard(440100209901010101)
// => true

// 邮箱
_.verifyConfig.isEmail(asdfl@qq.com)
// => true

// 车牌号
_.verifyConfig.isCarNum(粤A88888)
// => true

// 返回手机掩码格式
_.phoneNumMask(13612345678)
// => 136****5678

// 返回身份证掩码格式;前6位和后4位
_.idCardMask(440100209901010101)
// => 440100****0101

Package Sidebar

Install

npm i @yongzhiluo/js-tools

Weekly Downloads

0

Version

1.0.6

License

none

Unpacked Size

65.7 kB

Total Files

6

Last publish

Collaborators

  • yongzhiluo