Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
使用方法
const selector = zhjs.useFileSelector({
multiple: true,
// 参考 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input/file#accept
accept: ".jpg,.png",
});
selector.openFileDialog().then((files) => {
// TODO: use files here
});
使用方法
const arr = [
{ id: 10, pid: 9 },
{ id: 9, pid: 5 },
{ id: 8, pid: 5 },
{ id: 7, pid: 2 },
{ id: 6, pid: 1 },
{ id: 5, pid: 1 },
{ id: 4, pid: 1 },
{ id: 3, pid: 0 },
{ id: 2, pid: 0 },
{ id: 1, pid: 0 },
{ id: 0, pid: null },
];
// output: 树形结构
const tree = zhjs.arrayToTree(arr, { parentProperty: "pid" });
// getRootNode
console.log(tree.getRoot());
// getLevelChildren
console.log(tree.getLevel(1));
// output 1 2 3
console.log(tree.find(9));
// output { id: 9, pid: 5 }
console.log(tree.sort((a, b) => a.id - b.id));
// sort by node.id, from low to height
console.log(tree.getRoot().flat());
// return flat tree nodes array
iife
模式下工具方法被挂载在全局zhjs_array
变量上。
zip
创建一个分组元素数组,其中第一个包含给定数组的第一个元素,第二个包含给定数组的第二个元素,依此类推。import { zip } from "zhjs/array";
zip(["a", "b"], [1, 2], [true, false]);
// => [['a', 1, true], ['b', 2, false]]
Tree
增加update
方法 传入数组对整棵树进行动态更新arratToTree
返回类型为Tree
增加Tree
类型的公开方法getRoot
和getLevel
Tree.getLevel
无法获取0层节点 的问题
增加Tree
类型的公开方法find
用于获取给定customID
的节点Tree.sort
公开方法,对每个children进行排序,参考Array.sort
增加Tree.getArray
方法,获取树的源数组TreeNode.flat
方法,返回打平后的TreeNode
数组
修复Tree
根节点如果在给定的源数组中存在时,不能正确往TreeNode.data
中插入数据的问Tree
模块的单元测试
增加Tasker
类
增加FileSelector.dispose
手动释放内存的方法
修复FileSelector
类取消弹窗事件无法触发的问题FileSelector.openFileDialog
返回的文件对象延迟之后被释放的问题FAQs
## 文件选择器
The npm package h2o receives a total of 5 weekly downloads. As such, h2o popularity was classified as not popular.
We found that h2o demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.