vian ebde4a48a4 chore: npm publish指定特定文件 5 年之前
..
src add76a8f63 feat(tree): 不维护seq连号,减少数据更新 5 年之前
tests add76a8f63 feat(tree): 不维护seq连号,减少数据更新 5 年之前
.eslintignore 59a7f87d7a feat: tree initial commit 5 年之前
.eslintrc.js add76a8f63 feat(tree): 不维护seq连号,减少数据更新 5 年之前
.gitignore ebde4a48a4 chore: npm publish指定特定文件 5 年之前
.huskyrc.js 59a7f87d7a feat: tree initial commit 5 年之前
README.md a19db1e037 docs(tree): 变更README 5 年之前
commitlint.config.js 59a7f87d7a feat: tree initial commit 5 年之前
lint-staged.config.js 59a7f87d7a feat: tree initial commit 5 年之前
package-lock.json 59a7f87d7a feat: tree initial commit 5 年之前
package.json ebde4a48a4 chore: npm publish指定特定文件 5 年之前
prettier.config.js 59a7f87d7a feat: tree initial commit 5 年之前
rollup.config.js 59a7f87d7a feat: tree initial commit 5 年之前
tsconfig.json 59a7f87d7a feat: tree initial commit 5 年之前

README.md

Tree

基于 TypeScript 编写的树结构库

安装

$ npm i -S @sc/tree

测试

$ npm run test

打包

$ npm run build

基本用法

const rawData: TreeRaw[] = [
  { ID: '1', parentID: '-1', seq: 1 },
  { ID: '2', parentID: '-1', seq: 2 },
  { ID: '3', parentID: '-1', seq: 3 },
];

const tree = new Tree(rawData);

树方法

const node = tree.find('1');

tree.prepareInsert(rawData);

...

节点方法

节点可用的方法均挂载在节点的ctx对象中。


node.ctx.row();

node.ctx.parent();

node.ctx.children();

...

具体接口请参考声明文件。