2.3.16 • Published 5 years ago

@alisports/jx-util v2.3.16

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

JavaScript工具函数库

TODO

更新/发布/分发

// 版本号
main.minor.patch

// 第一次发布
npm adduser
npm publish

// 第n+1次发布
npm login
npm publish

// 查看包的版本
npm view jx-util version
@alisports/jx-util

npm publish --access=public

单元测试

Mocha测试异步代码, 在Nodejs中贯彻单元测试

// 安装依赖
npm install es6-promise --save --verbose
npm install -g mocha --verbose // 测试框架
npm install --save-dev chai --verbose // 断言库

npm install --save-dev mocha --verbose
npm install --save-dev mochawesome --verbose

npm install -g istanbul --verbose

// 单次测试
mocha tests/test-regex.js

// 持续测试
mocha --watch tests

// 生成测试结果html报表
mocha --reporter mochawesome tests

// 测试覆盖率
istanbul cover ./node_modules/mocha/bin/_mocha -- -t 2000 --recursive -R spec tests/

core

函数名功能
uniqId唯一ID码
uuid'8-4-4-4-12' 字符串
timing测量函数执行时间
forEach遍历数组、字典
map映射函数
filter过滤函数
clone克隆函数
extend对象扩展函数
slice片取函数
stamp邮戳函数

from

函数名功能
string从string转换为本有类型

function

函数名功能
bind上下文绑定
returnimmutable 值
falsifyimmutable 假
truthifyimmutable 真
nullifyimmutable 空
undefinifyimmutable 为定义
alwaysimmutable 值
args获取实参名称数组
chain链异步函数
compose执行从右向左的函数组合
curry函数柯里化
allPass条件判断
anyPass条件判断
tryCatch异常捕获封装
pipes执行从左向右的函数组合
promisify转换异步
runPromisesInSeries异步串行
sleep延迟异步执行
throttle函数节流
debounce函数防抖

is

函数名功能
instanceof------
function------
array------
object------
string------
error------
regexp------
HTMLelement------
number------
undefined------
true------
false------
null------
jsonjson 字符串,不为字符串,则返回false
bool------
symbol------
date------
promise------
not------
ok------
plain------
empty------
equal------

object

函数名功能
forEach, each------
map------
filter------
clone------
isEmpty------
clean------
fromPairs------
toPairs------
shallowClone------
has------
merge------
mergeDeep------
mergeWith------
keys------
values------
entries------
pick------
omit------
prop------
propApply------
propEq------
size------

to

函数名功能
string------

array

函数名功能
head/first首位元素
tail/last末尾元素
disorder/shuffle打乱
equal等价
contains包含
flatten扁平化
randomOne随机选取
countOccurrences计算元素数目
unique去重
sum求和(数值型数组)
maxify求最大值(数值型数组)
minify求最小值(数值型数组)
forEach/each遍历
clone克隆
map映射
filter过滤
del/rm/remove移除
randomFilter指定元素数目,随机过滤
empty清空
union/merge求并集
intersect求交集
adjust对指定元素加值
allPass全量判定
anyPass选择判定
append追加元素
concat拼接数组
diff求差集
slice片取

date

函数名功能
head/first首位元素

number

regex

string

timer

url

logger

基本功能

  • 日志级别
  • 模块信息、字段信息与格式

重要组件

组件名称对应类名功能描述
日志器Logger提供了应用程序可一直使用的接口
处理器Handler将logger创建的日志记录发送到合适的目的输出
过滤器Filter提供了更细粒度的控制工具来决定输出哪条日志记录,丢弃哪条日志记录
格式器Formatter决定日志记录的最终输出格式
2.3.16

5 years ago

2.3.14

5 years ago

2.3.12

5 years ago

2.3.4

5 years ago

2.3.0

5 years ago