@vswift/utils
v1.1.2
Published
Quickly develop public methods
Downloads
4
Readme
@vswift/utils
Quickly develop public methods.
Install
pnpm add @vswift/utils
Usage
import { findArraryValueFromTreeData } from '@vswift/utils'
const treeData = [
{
key: '1',
name: 'como1',
children: [
{
key: '1-1',
name: 'como11',
children: [
{ key: '1-1-1', name: 'como111' }
]
}
]
}
]
const finds = findArraryValueFromTreeData('1-1-1', treeData, { id: 'key', label: 'name' })
// ['1', '1-1', '1-1-1']
const finds = findArraryValueFromTreeData('1-1-1', treeData, { id: 'key', label: 'name', returnType: 'labels' })
// ['como1', 'como11', 'como111']
Preview
findArraryValueFromTreeData
- Query all parent elements based on child ID, including itself.findNodeObjectFromTreeData
- Find the node object where the target ID is located from the tree data.getLabelByValue
- Get the label name based on value.imageCompress
- Image quality compression.dataURLToBlob
- Convert dataURL to blob data, dataURL is generated bycanvas.toDataURL
.fileDownload
- File download, suitable for back-end interface to return file stream.countDown
- Simple countdown.recursiveTreeData
- Recursive tree data, modify and return the original data object.isArraryObject
- Judgment object array.isAsyncFunction
- Determine asynchronous function.xlsxExport
- Xlsx file export.