https://github.com/imcuttle/detect-tree-changed
Detect tow tree what is updated
https://github.com/imcuttle/detect-tree-changed
Last synced: 4 months ago
JSON representation
Detect tow tree what is updated
- Host: GitHub
- URL: https://github.com/imcuttle/detect-tree-changed
- Owner: imcuttle
- License: mit
- Created: 2019-02-03T13:19:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T16:17:38.000Z (over 3 years ago)
- Last Synced: 2025-10-26T06:58:38.691Z (8 months ago)
- Language: JavaScript
- Size: 1.07 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: License
Awesome Lists containing this project
README
# detect-tree-changed
[](https://travis-ci.org/imcuttle/detect-tree-changed)
[](https://codecov.io/github/imcuttle/detect-tree-changed?branch=master)
[](https://www.npmjs.com/package/detect-tree-changed)
[](https://www.npmjs.com/package/detect-tree-changed)
[](https://prettier.io/)
[](https://conventionalcommits.org)
> Detect tow tree what is updated
## Installation
```bash
npm install detect-tree-changed
# or use yarn
yarn add detect-tree-changed
```
## Usage
```javascript
const detectTreeChanged = require('detect-tree-changed')
detectTreeChanged(
{
node: 'Root'
},
{
node: 'root'
}
)
// => Map {
{node: 'Root'}: {status: 'updated', ctx: {...}}
}
```
It's shameless of use document of [@moyuyc/visit-tree](https://github.com/imcuttle/visit-tree#context) about the `ctx` which is returned.
## API
### detectTreeChanged
[index.js:23-131](https://github.com/imcuttle/detect-tree-changed/blob/6bf6a879939a1e39ba8075d94428f8cd3e4a1d4f/index.js#L23-L131 "Source code on GitHub")
#### Parameters
- `treeA` {T}
- `treeB` {T}
- `opt` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** {{}}
- `opt.limit` The limit of changed node (optional, default `Infinity`)
- `opt.equal` The compare strategy of two node (optional, default `(a,b)=>a===b`)
- `opt.path` (optional, default `'children'`)
Returns **[Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)**
## Related
- [@moyuyc/visit-tree](https://github.com/imcuttle/visit-tree) - Visit tree by pre or post DFS.
- [detect-one-changed](https://github.com/imcuttle/detect-one-changed) - Detect first changed html and markdown between old text and new.
## Contributing
- Fork it!
- Create your new branch:
`git checkout -b feature-new` or `git checkout -b fix-which-bug`
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
`git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`
- Push to the branch: `git push`
- Submit a pull request :)
## Authors
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
## License
MIT - [imcuttle](https://github.com/imcuttle) 🐟