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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ture

v0.2.0

Published

Collection of algorithms and data structures written in TypeScript for fun and profit

Readme

Ture - Demo

Ture is a collection of algorithms and data structures written in TypeScript for fun and profit.

WTF does Ture mean? Essentially, it's a famous sicilian personal name, but it's contained in the word strucTUREs and remembers Alan Turing as well, so why not.

Beware that some algorithms and data structure aren't really optimized for production use, so please take this into account before depending on this package. At the moment I'm using it on personal small projects, especially small video game demos.

For instance the KdTree (a 2d tree implementation actually) and its operation are ready for production use and guaranteed to run on logarithmic time in the typical case, while some other algorithms on graphs are in the works and may need some testing.

Features

  • KdTree (2d tree implementation) with logarithmic running time (typical case)
  • KdTree with range and nearest operations
  • Test cases and examples (found in the /examples folder) to get started

Install

Simply npm install ture --save.

Then use it like in the following example:

import {
  KdTree
} from "ture";

// contains

const tree: KdTree = new KdTree();
tree.insert(new Point2D(0.7, 0.2));
tree.insert(new Point2D(0.5, 0.4));
tree.insert(new Point2D(0.2, 0.3));
tree.insert(new Point2D(0.4, 0.7));
tree.insert(new Point2D(0.9, 0.6));

tree.contains(new Point2D(0.4, 0.7)); // true
tree.contains(new Point2D(0.3, 0.7)); // false

// range

const tree: KdTree = new KdTree();
tree.insert(new Point2D(0.1, 0.4));
tree.insert(new Point2D(0.6, 0.5));
const points = tree.range(new Rect(0.4, 0.3, 0.8, 0.6));
console.log(points.length); // 1
console.log(points[0]); // (0.6, 0.5)

// nearest

const tree: KdTree = new KdTree();
tree.insert(new Point2D(0.206107, 0.095492)); // A
tree.insert(new Point2D(0.975528, 0.654508)); // B
tree.insert(new Point2D(0.024472, 0.345492)); // C
tree.insert(new Point2D(0.793893, 0.095492)); // D
tree.insert(new Point2D(0.793893, 0.904508)); // E
tree.insert(new Point2D(0.975528, 0.345492)); // F
tree.insert(new Point2D(0.206107, 0.904508)); // G
tree.insert(new Point2D(0.500000, 0.000000)); // H
tree.insert(new Point2D(0.024472, 0.654508)); // I
tree.insert(new Point2D(0.500000, 1.000000)); // L
const nearestPoint = tree.nearest(new Point2D(0.81, 0.30));
console.log(nearestPoint); // (0.975528, 0.345492)

or

import {
  Graph,
} from "ture";
const graph: Graph = createGraph([
  '1337',
  '1338',
  '1339',
]);
graph.addEdge('1337', '1338');

Credits

Some of the data structures are ported from Java from the wonderful book "Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne".

License

This project is licensed under the terms of the MIT license.