npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

typescript-tree-structure

v1.0.3

Published

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

Readme

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 | Supported | | --- | --------- | ------------------ | | npm | >= 7.24.0 | :white_check_mark: |

main features

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

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