@luck-helper/utils
v0.0.6
Published
luck-design通用方法库
Downloads
15
Readme
luck-design通用方法库
通用方法
数组合并并去重
uniqueArr(arr1, arr2,compareKey)
树数据拉平
flattenTree(tree, Key, childKey = 'children')
ReactChildren 处理方法集
浅遍历子组件并返回一个数组
ChildrenUtil.map(children, (child, index)=>{})
浅遍历子组件
ChildrenUtil.forEach(children, (child, index)=>{})
统计子组件个数
ChildrenUtil.count(children)
验证 children 是否只有一个子节点(一个 React 元素),如果有则返回它,否则此方法会抛出错误
ChildrenUtil.only(children)
把子组件转化成数组
ChildrenUtil.toArray(children)
浅过滤子组件
ChildrenUtil.filter(children, filterFn)
深层过滤子组件
ChildrenUtil.deepFilter(children, deepFilterFn)
通过 type 对子组件进行分组
ChildrenUtil.groupByType(children, types, rest)
深层遍历子组件并返回一个数组
ChildrenUtil.deepMap(children, deepMapFn)
深层遍历子组件
ChildrenUtil.deepForEach(children, deepForEachFn)
深层查找子组件
ChildrenUtil.deepFind(children, deepFindFn)
仅获取子组件及其子组件中的文本
ChildrenUtil.onlyText(children)
Local 存储
const store = LocalStore.getInstance();
store.get(A);
store.set(A,B);
权限判断
PermissionHelp(permissions,wanted)
权限组件过滤
PermissionUtil(Array, permissions)
Session 存储
保存
sessionStorage.save('SAVE_KEY',{title:'test'});
或
sessionStorage.set('SAVE_KEY',{title:'test'});
读取
sessionStorage.read('SAVE_KEY',{title:'test'});
或
sessionStorage.get('SAVE_KEY',{title:'test'});
删除
sessionStorage.remove('SAVE_KEY',{title:'test'});
数组移动
arrayMove(array, from, to)
uuid
getUuid()