Socket
Socket
Sign inDemoInstall

typescript-tree-structure

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    typescript-tree-structure

Versatile and feature-rich TypeScript library with the capability to calculate x and y positions for objects represented in a tree structure while ensuring avoidance of relationship crossings


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

typescript-tree-structure

Versatile and feature-rich TypeScript library with the capability to calculate x and y positions for objects represented in a tree structure while ensuring avoidance of relationship crossings.

*VersionSupported
npm>= 7.24.0:white_check_mark:

main features

Library provides class which will calculate position of object (x, y) with the following rules:

  1. Objects are calculated into groups (where separate groups do not have relationships to each other)
  2. Groups are places (horizontally position) or (vertically position) based on property
  3. Each groups are separated by space which is customized
  4. Groups are places from left-right where left is the biggest group (horizontally position) or top-bottom where top is the biggest group (vertically position)
  5. Each groups root object is the one which with no parent
  6. Each object within group are separated by space which is customized
  7. Each parent object is centered among its children
  8. Height and width of each object can be different
  9. Each new row (horizontally position) will start where last row ended (after biggest child height) or each new column (vertical position) will start where last column ended (after biggest child width)

So for example containing objects: a, b, c, d, e, i, i1, g, h, k, k1, k2, k3, k4, l, l1, l2, l3, l4, l5, h1, h2, h3

a -> has children: b, c, d, e
e -> has children: i, g, l3
b -> has children: h
c -> has children: k
i -> has children: i1, l4
k -> has children: k1, k2
k1 -> has children: k3, k4
h -> has children: h1, h2
h1 -> has children: h2, h3
l -> has children: l1, l5

horizontal example

alt text

vertical example

alt text

installation

$ npm install --save typescript-tree-structure

usage

After installation, the only thing you need to do is require the module:

import { TreeStructure } from 'typescript-tree-structure';

or

const { TreeStructure } = require('typescript-tree-structure');

run example

  • To run example locally it is required to run npm i for both projects (example and core)
  • After npm i need to run npm run build within core
  • Then need to run npm link within core
  • Then run npm link typescript-tree-structure within example
  • Everything is ready and you can perform npm run start within example which will auto generate index.html (open it via browser to see results)

Tests

This module is well-tested. You can run:

npm run test to run the tests under Node.js.
npm run test:nyc to run the tests under Node.js and get the coverage

Tests are not included in the npm package. If you want to play with them, you must clone the GitHub repository.

contributing

Please read our Contribution Guidelines before contributing to this project.

security

Please read our SECURITY REPORTS

license

MIT

Keywords

FAQs

Last updated on 03 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc