Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

versatile-tree

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

versatile-tree - npm Package Compare versions

Comparing version 1.2.1 to 1.3.1

9

dist/TreeNode.d.ts

@@ -63,2 +63,11 @@ /**

/**
* Sets the data for this node. By default, the children property is ignored.
*
* To replace children, pass the `replaceChildren` argument value as `true`.
*
* @param newData The new data for this node.
* @param replaceChildren Optional. When true, children of the node will be replaced with the children in the data. When false, the children property is ignored and only the node's data is set. Default false.
*/
setData(newData: Record<string, any>, replaceChildren?: boolean): void;
/**
* Returns the property name used for children.

@@ -65,0 +74,0 @@ *

@@ -80,2 +80,27 @@ "use strict";

/**
* Sets the data for this node. By default, the children property is ignored.
*
* To replace children, pass the `replaceChildren` argument value as `true`.
*
* @param newData The new data for this node.
* @param replaceChildren Optional. When true, children of the node will be replaced with the children in the data. When false, the children property is ignored and only the node's data is set. Default false.
*/
setData(newData, replaceChildren = false) {
var _a;
const newDataWithoutChildren = Object.assign({}, newData);
delete newDataWithoutChildren[this.childrenPropertyName];
this.data = newData;
if (replaceChildren) {
const childrenData = (_a = newData[this.childrenPropertyName]) !== null && _a !== void 0 ? _a : [];
const childrenDataIsArray = Array.isArray(childrenData);
this.children = [];
if (childrenDataIsArray) {
childrenData.forEach((childData) => this.addChildNode(new TreeNode(childData, this.options)));
}
else {
console.error(`TreeNode: Expected children property "${this.childrenPropertyName}" to be an array of children data. Instead got ${typeof childrenData}:`, childrenData);
}
}
}
/**
* Returns the property name used for children.

@@ -82,0 +107,0 @@ *

2

package.json
{
"name": "versatile-tree",
"version": "1.2.1",
"version": "1.3.1",
"author": "Justin Mahar <contact@justinmahar.com>",

@@ -5,0 +5,0 @@ "description": "A highly versatile tree structure for JavaScript.",

@@ -74,2 +74,3 @@ <h2 align="center">

- [getData](#getdata)
- [setData](#setdata)
- [getChildrenPropertyName](#getchildrenpropertyname)

@@ -206,2 +207,19 @@ - [hasParent](#hasparent)

#### setData
```ts
setData(newData: Record<string, any>, replaceChildren = false)
```
Sets the data for this node. By default, the children property is ignored.
To replace children, pass the `replaceChildren` argument value as `true`.
| Param | Description |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `newData` | The new data for this node. |
| `replaceChildren` | Optional. When true, children of the node will be replaced with the children in the data. When false, the children property is ignored and only the node's data is set. Default false. |
---
#### getChildrenPropertyName

@@ -208,0 +226,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc