🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@luck-helper/utils

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luck-helper/utils

luck-design通用方法库

latest
npmnpm
Version
0.0.6
Version published
Weekly downloads
39
105.26%
Maintainers
1
Weekly downloads
 
Created
Source

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()

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts