@vzx/utils
v0.0.20
Published
防抖
Downloads
15
Readme
debounce
防抖
const debounceFunc = debounce(function() {
// ...some code
}[, 300[, true]]);
debounceFunc();throttle
节流
const throttleFunc = throttle(function() {
// ...some code
}[, 300[, true]]);
throttleFunc();randomString
生成随机字符串
randomString(16);resolvePath
把路径或路径片段的序列解析为绝对路径
resolvePath("/a", "./b", "../b/c", "d");getUrlParams
获取 url 参数
getUrlParams("http://abc.com?id=1", "id");listToTree
列表转树形结构
listToTree(
list,
(item) => {
return {
...item,
name: "v-" + item.name,
};
},
{
id: "idKey",
parentId: "parentIdKey",
children: "childrenKey",
leaf: "isLeaf",
rootId: null,
}
);upperFirst
首字母大写
upperFirst("case");camelize
字符串转驼峰命名
camelize("case");pascalize
字符串转大驼峰命名
pascalize("case");kebabize
字符串转中线命名
kebabize("case");snakelize
字符串转下划线命名
snakelize("case");