- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/mwc/treeify
- 软件文档: https://github.com/mwc/treeify
- 官方下载: https://github.com/mwc/treeify
软件介绍
treeify.js - v0.0.3(MIT)
treeify 是将一个数组(每个元素包含相同的特定的规则)转换为一个树对象的工具。
Constructor Parameters
treeify(data, idKey = 'id', parentIdKey = 'parentId', childrenName = 'children')
data{Array} 一个一维数组,该数组中每个元素均必须是一个对象,对象至少包含两个属性:唯一id的属性,如名称为 "id" 的属性;
指向父级id的属性,如名称为 "parentId" 的属性。
idKey{string} 标识元素中哪个属性是代表唯一id的名称,默认为 "id"parentIdKey{string} 标识元素中哪个属性是代表指向父元素的id,默认为 "parentId"childrenName{string} 默认情况下将向元素添加一个名为 'children' 的属性,代表当前元素的子级。可通过此参数修改这个名称。
Installation
$ npm install --save-dev treeify-js
Build
$ npm run build
Usage
你有一个 arr:
var arr = [
{
id: 'a1',
parentId: 'a'
},
{
id: 'aq',
parentId: 'a2'
},
{
id: 'a2',
parentId: 'a'
},
{
id: 'a1-1',
parentId: 'a1'
},
{
id: 'a',
parentId: ''
}
];想要转换成下边这样的 tree:
{
id: 'a',
parentId: '',
children: [
{
id: 'a1',
parentId: 'a',
children: [
{
id: 'a1-1',
parentId: 'a1',
children: []
}
]
},
{
id: 'a2',
parentId: 'a',
children: [
{
id: 'aq',
parentId: 'a2',
children: []
}
]
}
]
}只需要这样写:
treeify(arr);
Netty实战
诺曼·毛瑞尔(Norman Maurer)、马文·艾伦·沃尔夫泰尔(Marvin Allen Wolfthal) / 何品 / 人民邮电出版社 / 2017-5-1 / 69.00
编辑推荐 - Netty之父”Trustin Lee作序推荐 - 阿里巴巴中间件高级技术专家为本书中文版作序推荐 - 系统而详细地介绍了Netty的各个方面并附带了即用型的优质示例 - 附带行业一线公司的案例研究 - 极实用的Netty技术书 无论是构建高性能的Web、游戏服务器、推送系统、RPC框架、消息中间件还是分布式大数据处理引擎,都离不开Nett......一起来看看 《Netty实战》 这本书的介绍吧!
