
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
c-tools-js
Advanced tools
/**
* rgb 转 hex
* @param {Number} r 颜色 R
* @param {Number} g 颜色 G
* @param {Number} b 颜色 B
* @return hex
*/
RgbToHex
/**
* hex 转 rgb 例如:'#23ff45'
* @param {String} hex 颜色
* @return string
*/
HexToRgb
/**
* 生成随机十六进制颜色
* @return hex
*/
RandomHex
/**
* 生成随机RGB颜色
* @return string
*/
RandomRGB
/**
* 获取cookie
* @param {String} name cookie名
*/
GetCookie
/**
* 清除全部Cookie
*/
ClearCookies
/**
* 查找日期位于一年中的第几天
* @param {Date} date new Date()
* dayOfYear(new Date())
* Result: 272
*/
DayOfYear
/**
* Comma用于分割数字,默认为3位分割,一般用于格式化金额
* @param {Number} source 数字
* @param {Int} length 分割位, 默认为3位
* Comma(21342132) // 21,342,132
* Comma(21342132, 4) // 2134,2132
* Comma(21342132.234) // 21,342,132.234
*/
Comma
/**
* Pad用于按照位数补0
* @param {Number} source 数字
* @param {Int} length 补充位, 默认为2位
* Pad(1) // 01
* Pad(234, 4) // 0234
*/
Pad
/**
* Random用于生成两个整数范围内的随机整数
* @param {Int} min 最小
* @param {Int} max 最大
*/
Random
/**
* 检查是否对象数组
* @param {Array|Object} data
* @return Boolean
*/
IsArrayObject
/**
* 检查是否对象
* @param {Array|Object} data
* @return Boolean
*/
IsObject
/**
* 检查是否函数
* @param {Array|Object} data
* @return Boolean
*/
IsFunction
/**
* 检查是否数组
* @param {Array|Object} data
* @return Boolean
*/
IsArray
/**
* 检查是否字符串
* @param {Array|Object} data
* @return Boolean
*/
IsString
/**
* 拷贝
* @param {Array | Object} obj
* @returns obj
*/
Clone
/**
* 使用递归的方式实现数组、对象的深拷贝
* @param {Array | Object} obj
* @returns obj
*/
DeepClone
/**
* 删除空的参数(常用于post请求)
* @param {*} obj
* @return obj
*/
DeleteNullObj
/**
* 打乱数组
* @param {Array} arr 数组
* shuffleArray([1, 2, 3, 4])
* Result: [ 1, 4, 3, 2 ]
*/
ShuffleArray
/**
* 验证手机号码
* @param {Number, String} str
*/
RegExpChinaMobile
/**
* 火车车次
* @param {Number, String} str
* 例如: G1868, D102, D9, Z5, Z24, Z17
*/
RegExpTrainNumber
/**
* 身份证号, 支持1/2代(15位/18位数字)
* 例如: 622223199912051311, 12345619991205131x, 123456991010193
*/
RegExpIDCard
/**
* 香港身份证
* @param {Number, String} str
* 例如: K034169(1)
*/
RegExpHKIDCard
/**
* 澳门身份证
* 例如: 5686611(1)
*/
RegExpMacaoIDCard
/**
* 台湾身份证
* 例如: U193683453
*/
RegExpTaiwanIDCard
/**
* 护照(包含香港、澳门)
* 例如: s28233515, 141234567, 159203084, MA1234567, K25345719
*/
RegExpPassport
/**
* 邮政编码(中国)
* 例如: 734500, 100101
*/
RegExpPostalCode
/**
* 密码强度校验,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
* 例如: Kd@curry666
*/
RegExpPassword
/**
* 用户名校验,4到16位(字母,数字,下划线,减号)
* 例如: xiaohua_qq
*/
RegExpUserName
/**
* 必须带端口号的网址(或ip)
* 例如: https://www.qq.com:8080, 127.0.0.1:5050, baidu.com:8001, http://192.168.1.1:9090 , 反例: 192.168.1.1, https://www.jd.com
*/
RegExpAddressOrIp
/**
* 网址(url,支持端口和"?+参数"和"#+参数)
* 例如: www.qq.com, https://baidu.com, 360.com:8080/vue/#/a=1&b=2
*/
RegExpAddress
/**
* 统一社会信用代码
* 例如: 91230184MA1BUFLT44, 92371000MA3MXH0E3W
*/
RegExpSocialCredit
/**
* 视频(video)链接地址
* 例如: http://www.abc.com/video/wc.avi
* 格式:swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4
*/
RegExpVideo
/**
* 图片(image)链接地址
* 例如: https://www.abc.com/logo.png
* 格式:gif|png|jpg|jpeg|webp|svg|psd|bmp|tif
*/
RegExpImage
/**
* 数字/货币金额(支持负数、千分位分隔符)
* 例如: 100, -0.99, 3, 234.32, -1, 900, 235.09, 12,345,678.90
*/
RegExpCurrency
/**
* 邮箱
* 例如: 90203918@qq.com, nbilly@126.com, 汉字@qq.com
*/
RegExpEmail
/**
* ip-v4[:端口]
* 例如: 172.16.0.0, 172.16.0.0:8080, 127.0.0.0, 127.0.0.0:998
*/
RegExpIPv4
/**
* ip-v6[:端口]
* 例如: 2031:0000:130f:0000:0000:09c0:876a:130b, [2031:0000:130f:0000:0000:09c0:876a:130b]:8080
*/
RegExpIPv6
/**
* 英文字符串首字母大写
* @param {String} str 英文字符串
* @return str
*/
Capitalize
/**
* 去除空格
* @param {String} string 字符串
* @return str
*/
Trim
/**
* json对象转url参数: {aaa: 1} => a=1
* @param {*} obj 转化对象
* @param {*} encode 是否需要encode
* @return str
*/
Query2String
/**
* url参数转json对象: a=1 => {aaa: 1}
* @param {*} str 转化字符串
* @param {*} decode 是否需要decode
* @return obj
*/
String2Query
/**
* 以json的格式获取当前url上的参:
* http://www.taobao.com?a=1 => {a: 1}
* @return obj
*/
GetLocationQuery
/**
* 递归 -> children 数组小于1 设置为 undefined
* @param {Array} data 递归数组
* @param {String} children 递归字段键
* @returns data
*/
SetTreeChildrenBlankToUndefined
/**
* 递归修改键
* @param {Array} data 递归数组
* @param {Array} changeKey 递归修改名 [{ from: val, to: val }, { from: val, to: val }]
* @param {Array} children 递归数组名
* @returns data
*/
ChangeTreeDataName
/**
* 递归排序
* @param {Array} data 递归数组
* @param {String} children 递归字段键
* @param {String} sort 排序字段键
* @returns data
*/
SortTreeData
/**
* 根据子级id递归寻找所有父级
* @param {array} list 寻找数组
* @param {id} id id
* @param {string} checkId 递归id字段名 默认id
* @param {string} checkChildren 递归children字段名 默认children
*/
FindTreeParentId
/**
* 根据数组遍历所有id
* @param {array} list 寻找数组
* @param {string} checkId 需要遍历的字段
* @param {string} checkChildren 需要遍历的children键
*/
FindTreeAllId
FAQs
The npm package c-tools-js receives a total of 7 weekly downloads. As such, c-tools-js popularity was classified as not popular.
We found that c-tools-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.