@zhengxs/js.tree
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,2 +0,2 @@ | ||
# [0.2.0](https://github.com/zhengxs2018/js.tree/compare/v0.1.1...v0.2.0) (2021-05-19) | ||
# [0.3.0](https://github.com/zhengxs2018/js.tree/compare/v0.2.0...v0.3.0) (2021-06-14) | ||
@@ -6,7 +6,7 @@ | ||
* 添加 each 和 exclude 函数 ([0fa8aba](https://github.com/zhengxs2018/js.tree/commit/0fa8aba25e5d12f82f30932c6e45ad13e21c7e6c)) | ||
* toTree 的自定义 root 函数新增第二个参数 ([103a71a](https://github.com/zhengxs2018/js.tree/commit/103a71a6163f2fe2470fd138b3058f480b371f5b)) | ||
## [0.1.1](https://github.com/zhengxs2018/js.tree/compare/v0.1.0-rc3...v0.1.1) (2021-05-05) | ||
# [0.2.0](https://github.com/zhengxs2018/js.tree/compare/v0.1.1...v0.2.0) (2021-05-19) | ||
@@ -16,7 +16,7 @@ | ||
* **totree:** lodash 版本的 idKey 和 parentKey 支持 path ([6d7f436](https://github.com/zhengxs2018/js.tree/commit/6d7f43679db3fc0b7194f850776db084af7706f8)) | ||
* 添加 each 和 exclude 函数 ([0fa8aba](https://github.com/zhengxs2018/js.tree/commit/0fa8aba25e5d12f82f30932c6e45ad13e21c7e6c)) | ||
# [0.1.0-rc3](https://github.com/zhengxs2018/js.tree/compare/v0.1.0-rc2...v0.1.0-rc3) (2021-05-03) | ||
## [0.1.1](https://github.com/zhengxs2018/js.tree/compare/2777c9ca15b86195da891582ee40ecb72522d550...v0.1.1) (2021-05-05) | ||
@@ -26,13 +26,6 @@ | ||
* **totree:** lodash 版本的 idKey 和 parentKey 支持 path ([6d7f436](https://github.com/zhengxs2018/js.tree/commit/6d7f43679db3fc0b7194f850776db084af7706f8)) | ||
* 抽离 toTree 核心逻辑,允许外部定制转换行为 ([#2](https://github.com/zhengxs2018/js.tree/issues/2)) ([385f790](https://github.com/zhengxs2018/js.tree/commit/385f7900f287a15c78dc8d3189ed8ae1b2a53bfc)) | ||
# [0.1.0-rc2](https://github.com/zhengxs2018/js.tree/compare/v0.1.0-rc1...v0.1.0-rc2) (2021-05-02) | ||
# [0.1.0-rc1](https://github.com/zhengxs2018/js.tree/compare/2777c9ca15b86195da891582ee40ecb72522d550...v0.1.0-rc1) (2021-05-01) | ||
### Performance Improvements | ||
@@ -39,0 +32,0 @@ |
import type { ID, Exporter } from '../types'; | ||
import type { ParseResult } from './parse'; | ||
/** | ||
@@ -38,3 +39,3 @@ * 和 isNil 结果相反 | ||
*/ | ||
export declare function exporter<T>(nodes: Record<ID, T[]>, root?: ID | Exporter<T>): T[]; | ||
export declare function exporter<T>(result: ParseResult<T>, root?: ID | Exporter<T>): T[]; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -18,3 +18,3 @@ export type { ID, None, Row, Node, Exporter, Transform, Predicate } from './types'; | ||
*/ | ||
export declare const version = "0.2.0"; | ||
export declare const version = "0.3.0"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -213,5 +213,6 @@ 'use strict'; | ||
*/ | ||
function exporter(nodes, root) { | ||
function exporter(result, root) { | ||
const nodes = result.childNodes; | ||
if (typeof root === 'function') { | ||
return root(nodes) || []; | ||
return root(nodes, result) || []; | ||
} | ||
@@ -290,4 +291,3 @@ return nodes[defaultTo(root, ROOT_ID)] || []; | ||
function toTree(data, options = {}) { | ||
const { childNodes } = parse(data, options); | ||
return exporter(childNodes, defaultTo(options.root, ROOT_ID)); | ||
return exporter(parse(data, options), options.root); | ||
} | ||
@@ -320,3 +320,3 @@ | ||
*/ | ||
const version = '0.2.0'; | ||
const version = '0.3.0'; | ||
@@ -323,0 +323,0 @@ exports.CHILDREN_KEY = CHILDREN_KEY; |
@@ -181,5 +181,6 @@ 'use strict'; | ||
*/ | ||
function exporter(nodes, root) { | ||
function exporter(result, root) { | ||
const nodes = result.childNodes; | ||
if (typeof root === 'function') { | ||
return root(nodes) || []; | ||
return root(nodes, result) || []; | ||
} | ||
@@ -258,4 +259,3 @@ return nodes[lodash.defaultTo(root, ROOT_ID)] || []; | ||
function toTree(data, options = {}) { | ||
const { childNodes } = parse(data, options); | ||
return exporter(childNodes, lodash.defaultTo(options.root, ROOT_ID)); | ||
return exporter(parse(data, options), options.root); | ||
} | ||
@@ -288,3 +288,3 @@ | ||
*/ | ||
const version = '0.2.0'; | ||
const version = '0.3.0'; | ||
@@ -291,0 +291,0 @@ exports.CHILDREN_KEY = CHILDREN_KEY; |
@@ -36,3 +36,3 @@ | ||
*/ | ||
export declare type Exporter<T> = (nodes: Record<ID, T[]>) => T[]; | ||
export declare type Exporter<T> = (nodes: Record<ID, T[]>, result: ParseResult<T>) => T[] | null | undefined; | ||
@@ -47,3 +47,3 @@ /** | ||
*/ | ||
export declare function exporter<T>(nodes: Record<ID, T[]>, root?: ID | Exporter<T>): T[]; | ||
export declare function exporter<T>(result: ParseResult<T>, root?: ID | Exporter<T>): T[]; | ||
@@ -215,4 +215,4 @@ /** | ||
*/ | ||
export declare const version = "0.2.0"; | ||
export declare const version = "0.3.0"; | ||
export { } |
@@ -209,5 +209,6 @@ /** | ||
*/ | ||
function exporter(nodes, root) { | ||
function exporter(result, root) { | ||
const nodes = result.childNodes; | ||
if (typeof root === 'function') { | ||
return root(nodes) || []; | ||
return root(nodes, result) || []; | ||
} | ||
@@ -286,4 +287,3 @@ return nodes[defaultTo(root, ROOT_ID)] || []; | ||
function toTree(data, options = {}) { | ||
const { childNodes } = parse(data, options); | ||
return exporter(childNodes, defaultTo(options.root, ROOT_ID)); | ||
return exporter(parse(data, options), options.root); | ||
} | ||
@@ -316,4 +316,4 @@ | ||
*/ | ||
const version = '0.2.0'; | ||
const version = '0.3.0'; | ||
export { CHILDREN_KEY, ID_KEY, PARENT_ID_KEY, ROOT_ID, each, exclude, exporter, filter, map, parse, toRows, toTree, version }; |
@@ -177,5 +177,6 @@ import { defaultTo, isNil, get } from 'lodash-es'; | ||
*/ | ||
function exporter(nodes, root) { | ||
function exporter(result, root) { | ||
const nodes = result.childNodes; | ||
if (typeof root === 'function') { | ||
return root(nodes) || []; | ||
return root(nodes, result) || []; | ||
} | ||
@@ -254,4 +255,3 @@ return nodes[defaultTo(root, ROOT_ID)] || []; | ||
function toTree(data, options = {}) { | ||
const { childNodes } = parse(data, options); | ||
return exporter(childNodes, defaultTo(options.root, ROOT_ID)); | ||
return exporter(parse(data, options), options.root); | ||
} | ||
@@ -284,4 +284,4 @@ | ||
*/ | ||
const version = '0.2.0'; | ||
const version = '0.3.0'; | ||
export { CHILDREN_KEY, ID_KEY, PARENT_ID_KEY, ROOT_ID, each, exclude, exporter, filter, map, parse, toRows, toTree, version }; |
@@ -177,5 +177,6 @@ import { defaultTo, isNil, get } from 'lodash'; | ||
*/ | ||
function exporter(nodes, root) { | ||
function exporter(result, root) { | ||
const nodes = result.childNodes; | ||
if (typeof root === 'function') { | ||
return root(nodes) || []; | ||
return root(nodes, result) || []; | ||
} | ||
@@ -254,4 +255,3 @@ return nodes[defaultTo(root, ROOT_ID)] || []; | ||
function toTree(data, options = {}) { | ||
const { childNodes } = parse(data, options); | ||
return exporter(childNodes, defaultTo(options.root, ROOT_ID)); | ||
return exporter(parse(data, options), options.root); | ||
} | ||
@@ -284,4 +284,4 @@ | ||
*/ | ||
const version = '0.2.0'; | ||
const version = '0.3.0'; | ||
export { CHILDREN_KEY, ID_KEY, PARENT_ID_KEY, ROOT_ID, each, exclude, exporter, filter, map, parse, toRows, toTree, version }; |
@@ -139,5 +139,6 @@ (function (global, factory) { | ||
} | ||
function exporter(nodes, root) { | ||
function exporter(result, root) { | ||
var nodes = result.childNodes; | ||
if (typeof root === 'function') { | ||
return root(nodes) || []; | ||
return root(nodes, result) || []; | ||
} | ||
@@ -190,4 +191,3 @@ return nodes[defaultTo(root, ROOT_ID)] || []; | ||
if (options === void 0) { options = {}; } | ||
var childNodes = parse(data, options).childNodes; | ||
return exporter(childNodes, defaultTo(options.root, ROOT_ID)); | ||
return exporter(parse(data, options), options.root); | ||
} | ||
@@ -208,3 +208,3 @@ | ||
var version = '0.2.0'; | ||
var version = '0.3.0'; | ||
@@ -211,0 +211,0 @@ exports.CHILDREN_KEY = CHILDREN_KEY; |
@@ -15,3 +15,3 @@ !function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((n="undefined"!=typeof globalThis?globalThis:n||self).jsTree={})}(this,(function(n){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var r=function(){return(r=Object.assign||function(n){for(var r,e=1,t=arguments.length;e<t;e++)for(var o in r=arguments[e])Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o]);return n}).apply(this,arguments)};function e(n){return null==n}function t(n,r){return e(n)?r:n}function o(n,r,e){return t(n[r],e)}var i="__root__",u="parentId",f="children";function c(n,r){return"function"==typeof r?r(n)||[]:n[t(r,i)]||[]}function a(n,r){void 0===r&&(r={});var c=t(r.idKey,"id"),a=t(r.parentKey,u),d=t(r.childrenKey,f),s=t(r.transform,(function(n){return n})),h=t(r.insert,(function(n,r){return n.push(r)})),l={},v={};return n.forEach((function(n,r){var u,f=o(n,c);!function(n,r){if(!n){if(r instanceof Error)throw r;throw new Error(r)}}((u=f,!1===e(u)),"id is required, in "+r+".");var p=s(n,r);if(!e(p)){var y=v[f];y?p[d]=y:v[f]=p[d]=[];var E=t(o(n,a),i),_=v[E];h(_||(v[E]=[]),p),l[f]=p}})),{idKey:c,parentKey:a,childrenKey:d,nodes:l,childNodes:v}}n.CHILDREN_KEY=f,n.ID_KEY="id",n.PARENT_ID_KEY=u,n.ROOT_ID=i,n.each=function(n,r,e){return void 0===e&&(e=f),function n(o,i){return o.forEach((function(o,u){r(o,u,i)||n(t(o[e],[]),i.concat(o))})),[]}(n,[])},n.exclude=function(n,e,o){return void 0===o&&(o=f),function n(i,u){var f=[];return i.forEach((function(i,c){var a;if(!e(i,c,u)){var d=t(i[o],[]);if(0!==d.length){var s=n(d,u.concat(i));s.length>0&&f.push(r(r({},i),((a={})[o]=s,a)))}else f.push(i)}})),f}(n,[])},n.exporter=c,n.filter=function(n,e,o){return void 0===o&&(o=f),function n(i,u){var f=[];return i.forEach((function(i,c){var a;if(e(i,c,u))f.push(r({},i));else{var d=n(t(i[o],[]),u.concat(i));d.length>0&&f.push(r(r({},i),((a={})[o]=d,a)))}})),f}(n,[])},n.map=function(n,e,o){return void 0===o&&(o=f),function n(i,u){return i.map((function(i,f){var c,a=e(r({},i),f,u),d=n(t(a[o],[]),u.concat(i));return d.length>0?r(r({},a),((c={})[o]=d,c)):a}))}(n,[])},n.parse=a,n.toRows=function(n,e){void 0===e&&(e=f);var o=[];return n.forEach((function n(i){var u,f,c,a,d=r({},i),s=(c=[],a=(u=d)[f=e],delete u[f],t(a,c));o.push(d),s.forEach(n)})),o},n.toTree=function(n,r){return void 0===r&&(r={}),c(a(n,r).childNodes,t(r.root,i))},n.version="0.2.0",Object.defineProperty(n,"__esModule",{value:!0})})); | ||
***************************************************************************** */var r=function(){return(r=Object.assign||function(n){for(var r,e=1,t=arguments.length;e<t;e++)for(var o in r=arguments[e])Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o]);return n}).apply(this,arguments)};function e(n){return null==n}function t(n,r){return e(n)?r:n}function o(n,r,e){return t(n[r],e)}var i="__root__",u="parentId",f="children";function c(n,r){var e=n.childNodes;return"function"==typeof r?r(e,n)||[]:e[t(r,i)]||[]}function a(n,r){void 0===r&&(r={});var c=t(r.idKey,"id"),a=t(r.parentKey,u),d=t(r.childrenKey,f),s=t(r.transform,(function(n){return n})),h=t(r.insert,(function(n,r){return n.push(r)})),v={},l={};return n.forEach((function(n,r){var u,f=o(n,c);!function(n,r){if(!n){if(r instanceof Error)throw r;throw new Error(r)}}((u=f,!1===e(u)),"id is required, in "+r+".");var p=s(n,r);if(!e(p)){var y=l[f];y?p[d]=y:l[f]=p[d]=[];var E=t(o(n,a),i),_=l[E];h(_||(l[E]=[]),p),v[f]=p}})),{idKey:c,parentKey:a,childrenKey:d,nodes:v,childNodes:l}}n.CHILDREN_KEY=f,n.ID_KEY="id",n.PARENT_ID_KEY=u,n.ROOT_ID=i,n.each=function(n,r,e){return void 0===e&&(e=f),function n(o,i){return o.forEach((function(o,u){r(o,u,i)||n(t(o[e],[]),i.concat(o))})),[]}(n,[])},n.exclude=function(n,e,o){return void 0===o&&(o=f),function n(i,u){var f=[];return i.forEach((function(i,c){var a;if(!e(i,c,u)){var d=t(i[o],[]);if(0!==d.length){var s=n(d,u.concat(i));s.length>0&&f.push(r(r({},i),((a={})[o]=s,a)))}else f.push(i)}})),f}(n,[])},n.exporter=c,n.filter=function(n,e,o){return void 0===o&&(o=f),function n(i,u){var f=[];return i.forEach((function(i,c){var a;if(e(i,c,u))f.push(r({},i));else{var d=n(t(i[o],[]),u.concat(i));d.length>0&&f.push(r(r({},i),((a={})[o]=d,a)))}})),f}(n,[])},n.map=function(n,e,o){return void 0===o&&(o=f),function n(i,u){return i.map((function(i,f){var c,a=e(r({},i),f,u),d=n(t(a[o],[]),u.concat(i));return d.length>0?r(r({},a),((c={})[o]=d,c)):a}))}(n,[])},n.parse=a,n.toRows=function(n,e){void 0===e&&(e=f);var o=[];return n.forEach((function n(i){var u,f,c,a,d=r({},i),s=(c=[],a=(u=d)[f=e],delete u[f],t(a,c));o.push(d),s.forEach(n)})),o},n.toTree=function(n,r){return void 0===r&&(r={}),c(a(n,r),r.root)},n.version="0.3.0",Object.defineProperty(n,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=js.tree.min.js.map |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.15.1" | ||
"packageVersion": "7.15.2" | ||
} | ||
] | ||
} |
@@ -0,1 +1,2 @@ | ||
import type { ParseResult } from './common/parse'; | ||
/** | ||
@@ -34,3 +35,3 @@ * ID类型 | ||
*/ | ||
export declare type Exporter<T> = (nodes: Record<ID, T[]>) => T[]; | ||
export declare type Exporter<T> = (nodes: Record<ID, T[]>, result: ParseResult<T>) => T[] | null | undefined; | ||
/** | ||
@@ -37,0 +38,0 @@ * filter 回调 |
{ | ||
"name": "@zhengxs/js.tree", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "快速,轻量,无依赖的树结构数据处理函数库", | ||
@@ -65,19 +65,18 @@ "main": "./dist/js.tree.common.js", | ||
"devDependencies": { | ||
"@cypress/eslint-plugin-dev": "^5.1.0", | ||
"@microsoft/api-extractor": "^7.15.1", | ||
"@microsoft/api-extractor": "^7.15.2", | ||
"@rollup/plugin-alias": "^3.1.2", | ||
"@rollup/plugin-commonjs": "^18.1.0", | ||
"@rollup/plugin-commonjs": "^19.0.0", | ||
"@rollup/plugin-node-resolve": "^13.0.0", | ||
"@rollup/plugin-replace": "^2.3.4", | ||
"@rollup/plugin-replace": "^2.4.2", | ||
"@types/jest": "^26.0.23", | ||
"@types/lodash": "^4.14.168", | ||
"@types/lodash": "^4.14.169", | ||
"@types/lodash-es": "^4.17.4", | ||
"@types/node": "^15.0.2", | ||
"@typescript-eslint/eslint-plugin": "^4.22.1", | ||
"@typescript-eslint/parser": "^4.22.1", | ||
"@types/node": "^15.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.24.0", | ||
"@typescript-eslint/parser": "^4.24.0", | ||
"benchmark": "^2.1.4", | ||
"better-mock": "^0.3.1", | ||
"builtin-modules": "^3.2.0", | ||
"commitizen": "^4.2.3", | ||
"commitlint": "^12.1.1", | ||
"commitizen": "^4.2.4", | ||
"commitlint": "^12.1.4", | ||
"conventional-changelog-cli": "^2.1.1", | ||
@@ -87,18 +86,18 @@ "cross-env": "^7.0.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^7.25.0", | ||
"eslint": "^7.26.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-cypress": "^2.11.3", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-tsdoc": "^0.2.14", | ||
"husky": "^6.0.0", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.3", | ||
"lint-staged": "^11.0.0", | ||
"lodash": "^4.17.15", | ||
"performant-array-to-tree": "^1.8.1", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.47.0", | ||
"rollup-plugin-node-externals": "^2.1.3", | ||
"prettier": "^2.3.0", | ||
"rollup": "^2.48.0", | ||
"rollup-plugin-node-externals": "^2.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"ts-jest": "^26.4.4", | ||
"ts-jest": "^26.5.6", | ||
"typedoc": "^0.20.36", | ||
@@ -105,0 +104,0 @@ "typedoc-plugin-nojekyll": "^1.0.1", |
@@ -1,18 +0,64 @@ | ||
# @zhengxs/js.tree | ||
<div align="center"> | ||
<h1> | ||
<br/> | ||
<br/> | ||
👍 | ||
<br /> | ||
@zhengxs/js.tree | ||
<br /> | ||
<br /> | ||
</h1> | ||
<sup> | ||
<br /> | ||
<br /> | ||
<a href="https://www.typescriptlang.org"> | ||
<img src="https://img.shields.io/badge/lang-typescript-informational?style=flat" alt="TypeScript" /> | ||
</a> | ||
<a href="https://github.com/prettier/prettier"> | ||
<img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square" alt="code style: prettier" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@zhengxs/js.tree"> | ||
<img src="https://img.shields.io/npm/v/@zhengxs/js.tree.svg" alt="npm package" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@zhengxs/js.tree"> | ||
<img src="https://img.shields.io/npm/dt/@zhengxs/js.tree.svg" alt="npm downloads" /> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@zhengxs/js.tree"> | ||
<img src="https://img.shields.io/npm/dm/@zhengxs/js.tree.svg" alt="npm downloads" /> | ||
</a> | ||
<a href="https://unpkg.com/@zhengxs/js.tree/dist/js.tree.min.js"> | ||
<img src="https://img.badgesize.io/https:/unpkg.com/@zhengxs/js.tree/dist/js.tree.min.js?compression=gzip&style=flat" alt="Gzip Size" /> | ||
</a> | ||
<a href="https://david-dm.org/zhengxs2018/js.tree"> | ||
<img src="https://img.shields.io/david/zhengxs2018/js.tree" alt="Dependency Status" /> | ||
</a> | ||
<a href="https://david-dm.org/zhengxs2018/js.tree?type=dev"> | ||
<img src="https://img.shields.io/david/dev/zhengxs2018/js.tree" alt="DevDependency Status" /> | ||
</a> | ||
<a href="https://dashboard.cypress.io/projects/dtcor7/runs"> | ||
<img src="https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/dtcor7/main&style=flat&logo=cypress" alt="Cypress" /> | ||
</a> | ||
<a href="https://codecov.io/gh/zhengxs2018/js.tree"> | ||
<img src="https://codecov.io/gh/zhengxs2018/js.tree/branch/main/graph/badge.svg" alt="codecov" /> | ||
</a> | ||
<a href="https://github.com/zhengxs2018/js.tree/actions/workflows/tests.yaml"> | ||
<img src="https://github.com/zhengxs2018/js.tree/actions/workflows/tests.yaml/badge.svg" alt="Github action" /> | ||
</a> | ||
<a href="#typescript"> | ||
<img src="https://img.shields.io/badge/typings-included-brightgreen.svg?style=flat" alt="Typings" /> | ||
</a> | ||
<a href="#License"> | ||
<img src="https://img.shields.io/npm/l/@zhengxs/js.tree.svg?style=flat-square" alt="License" /> | ||
</a> | ||
<br /> | ||
<br /> | ||
</sup> | ||
<div>快速,轻量,无依赖的树结构数据处理函数库。</div> | ||
<br /> | ||
<br /> | ||
<br /> | ||
</div> | ||
[![lang](https://img.shields.io/badge/lang-typescript-informational?style=flat)](https://www.typescriptlang.org/) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier) | ||
[![npm version](https://img.shields.io/npm/v/%40zhengxs%2Fjs.tree.svg?style=flat)](https://www.npmjs.com/package/%40zhengxs%2Fjs.tree) | ||
[![Downloads](https://img.shields.io/npm/dt/%40zhengxs%2Fjs.tree.svg?style=flat)](https://www.npmjs.com/package/%40zhengxs%2Fjs.tree) | ||
[![Downloads](https://img.shields.io/npm/dm/%40zhengxs%2Fjs.tree.svg?style=flat)](https://www.npmjs.com/package/%40zhengxs%2Fjs.tree) | ||
[![Gzip Size](http://img.badgesize.io/https://unpkg.com/@zhengxs/js.tree/dist/js.tree.min.js?compression=gzip&style=flat)](https://unpkg.com/@zhengxs/js.tree/dist/js.tree.min.js) | ||
[![codecov](https://codecov.io/gh/zhengxs2018/js.tree/branch/main/graph/badge.svg?token=JBYVAK2RRG)](https://codecov.io/gh/zhengxs2018/js.tree) | ||
[![Dependency Status](https://david-dm.org/zhengxs2018/js.tree.SVG)](https://david-dm.org/zhengxs2018/js.tree?type=dev) | ||
[![devDependency Status](https://david-dm.org/zhengxs2018/js.tree/dev-status.svg)](https://david-dm.org/zhengxs2018/js.tree?type=dev) | ||
[![js.tree](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/dtcor7/main&style=flat&logo=cypress)](https://dashboard.cypress.io/projects/dtcor7/runs) | ||
[![Node.js CI](https://github.com/zhengxs2018/js.tree/actions/workflows/tests.yaml/badge.svg)](https://github.com/zhengxs2018/js.tree/actions/workflows/tests.yaml) | ||
[![typings included](https://img.shields.io/badge/typings-included-brightgreen.svg?style=flat)](#typescript) | ||
![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat) | ||
--- | ||
> `lodash` 是可选的,详见 [对不同构建版本的解释](#对不同构建版本的解释) | ||
@@ -30,2 +76,6 @@ 快速,轻量,无依赖的树结构数据处理函数库。 | ||
[国内镜像](https://gitee.com/zhengxs2018/js.tree) | ||
### 文档 | ||
@@ -99,2 +149,9 @@ | ||
// 数据添加进 children 数组前的处理,可选 | ||
transform(data) { | ||
// 通过浅拷贝避免修改原始数据 | ||
// 可以在这里动态添加属性 | ||
return { ...data, checked: false } | ||
}, | ||
// 接管插入行为 | ||
@@ -111,9 +168,2 @@ insert(siblings, node) { | ||
}, | ||
// 数据添加进 children 数组前的处理,默认:undefined | ||
transform(data) { | ||
// 通过浅拷贝避免修改原始数据 | ||
// 可以在这里动态添加属性 | ||
return { ...data, checked: false } | ||
}, | ||
}) | ||
@@ -150,7 +200,4 @@ // -> | ||
<br /> | ||
<a href="https://npm.runkit.com/@zhengxs/js.tree"> | ||
<img src="https://static.runkitcdn.com/assets/images/brand/horizontal-logo-full.svg" height="44" alt="Try on RunKit"> | ||
</a> | ||
[Try in runkit](https://npm.runkit.com/@zhengxs/bem) | ||
@@ -157,0 +204,0 @@ ## TypeScript |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96646
39
2157
247