GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ifakejs/tree-path: Get a tree full path by the given condition.

BranchesTags
Open more actions menu

Latest commit

 

History

28 Commits
28 Commits

Folders and files

NameName
Last commit message
Last commit date
__test__
__test__
 
 
scripts
scripts
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.eslintignore
.eslintignore
 
 
.eslintrc.js
.eslintrc.js
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc.js
.prettierrc.js
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README.zh-CN.md
README.zh-CN.md
 
 
api-extractor.json
api-extractor.json
 
 
babel.config.js
babel.config.js
 
 
index.html
index.html
 
 
jest.config.js
jest.config.js
 
 
package.json
package.json
 
 
rollup.config.ts
rollup.config.ts
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.type.json
tsconfig.type.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

Welcome to @ifake/tree-path 👋

Version codecov Npm Bundle Size License: MIT Build Status

Get tree path by the given condition.

English | įŽ€äŊ“中文

🏠 Homepage

Install

npm install @ifake/tree-path -S
# or
yarn add @ifake/tree-path -S

Usage

  • Browser
// We expose a global variable that can be used directly in the browser.

const { treePath } = window.IFakeTP
  • ES6 Module
import { treePath } from '@ifake/tree-path'
  • CommonJs
const { treePath } = require('@ifake/tree-path')

API

treePath(TreePath)

export interface TreePath {
  tree: Tree
  childrenKey?: string
  breakCondition: BreakCondition
}
  • tree Receive an array of object data.
  • childrenKey Custom property values, default is children
  • breakCondition Receives a real-time value from inside the function, defines conditions based on the value and returns a boolean value.

Example

const sourceData = [
 {
   id: 1,
   child: [
     {
       id: '1-1'
     },
     {
       id: '1-2',
       child: [
         {
           id: '1-2-1'
         }
       ]
     }
   ]
 },
 {
   id: 2
 }
]

const result = treePath({
    tree: sourceData,
    childrenKey: 'child',
    breakCondition: treeNode => treeNode.id === '1-2-1'
})

// The value should be:
[
    {
       id: 1,
       child: [...]
     },
    {
       id: '1-2',
       child: [...]
     },
    {
      id: '1-2-1'
    }
]

Run tests

yarn run test

Author

👤 [email protected]

  • Website: http://loadingmore.com
  • Github: @BiYuqi

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

📝 License

Copyright Š 2020 [email protected].

This project is MIT licensed.


This README was generated with â¤ī¸ by readme-md-generator

About

Get a tree full path by the given condition.

Topics

breadcrumbsearch-treetreetree-pathtree-structuretypescript

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.