Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@ones-design/utils
Advanced tools
import { Meta } from '@storybook/blocks'
在 ONES Design 中,工具函数是独立维护的。在使用它们之前,你需要先进行安装:
npm install @ones-design/utils
移动列表节点的位置,返回更新后的新数组。
function moveNode<NodeType extends Record<string, any>>(
nodes: NodeType[],
source: number | string,
target: number | string,
): NodeType[]
参数 | 说明 |
---|---|
nodes | 节点数组 |
source | 原位置 |
target | 目标位置 |
移动树节点的位置,返回更新后的新数组。
function moveTreeNode<NodeType extends Record<string, any>>(
nodes: NodeType[],
source: number | string | (number | string)[],
target: number | string | (number | string)[],
pos: -1 | 0 | 1,
childrenName?: string,
): NodeType[]
参数 | 说明 | 默认值 |
---|---|---|
nodes | 节点数组 | |
source | 原位置 | |
target | 目标位置 | |
pos | 相对目标的位置,-1 为上面,0 为里面,1 为下面 | |
childrenName | 存放子节点的字段名 | 'children' |
在指定位置插入节点,返回更新后的新数组。
function insertTreeNode<NodeType extends Record<string, any>>(
nodes: NodeType[],
target: number | string | (number | string)[],
node: NodeType,
pos: -1 | 0 | 1,
childrenName?: string,
): NodeType[]
参数 | 说明 | 默认值 |
---|---|---|
nodes | 节点数组 | |
target | 目标位置 | |
node | 要插入的节点 | |
pos | 相对目标的位置,-1 为上面,0 为里面,1 为下面 | |
childrenName | 存放子节点的字段名 | 'children' |
移除指定位置的节点,返回移除的节点和更新后的新数组。
function removeTreeNode<NodeType extends Record<string, any>>(
nodes: NodeType[],
pos: number | string | (number | string)[],
childrenName?: string,
): {
node: NodeType | null
nodes: NodeType[]
}
参数 | 说明 | 默认值 |
---|---|---|
nodes | 节点数组 | |
pos | 节点位置 | |
childrenName | 存放子节点的字段名 | 'children' |
获取指定位置的节点。
function getTreeNode<NodeType extends Record<string, any>>(
nodes: NodeType[],
pos: number | string | (number | string)[],
childrenName?: string,
): NodeType | null
参数 | 说明 | 默认值 |
---|---|---|
nodes | 节点数组 | |
pos | 节点位置 | |
childrenName | 存放子节点的字段名 | 'children' |
FAQs
ONES Design
The npm package @ones-design/utils receives a total of 341 weekly downloads. As such, @ones-design/utils popularity was classified as not popular.
We found that @ones-design/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.