# @bucky24/toolbox

> Collection of tools

Latest version **0.5.1** (published 2025-08-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @bucky24/toolbox
pnpm add @bucky24/toolbox
yarn add @bucky24/toolbox
bun add @bucky24/toolbox
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2025-08-26 |
| First published | 2022-07-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bucky24 |
| Maintainers | bucky24 |

## Links

- npm: https://www.npmjs.com/package/@bucky24/toolbox
- Repository: https://gitlab.com/bucky24/toolbox
- Homepage: https://gitlab.com/bucky24/toolbox#readme
- Issues: https://gitlab.com/bucky24/toolbox/issues
- npm.io page: https://npm.io/package/@bucky24/toolbox

## Recent versions

- 0.5.1 (latest) — 2025-08-26
- 0.5.0 — 2025-08-26
- 0.3.1 — 2024-05-01
- 0.3.0 — 2024-03-25
- 0.2.1 — 2024-03-24
- 0.2.0 — 2024-03-24
- 0.1.0 — 2022-07-10

## README

# Toolbox

This is intended to be a collection of misc things that I've had to do over and over again. It is small but will hopefully continue to grow.

## Importing

Import the code by using:

```
import { Polygon } from '@bucky24/toolbox';
```

Or for client items:

```
import { usePersistedState } from '@bucky24/toolbox/client';
```

## Exports

### Polygon

The Polygon class contains methods for manipulating and getting data about polygons.

#### pointInsidePolygon

This method returns a boolean indicating if the given Point is inside the given Polygon

| param | type | description |
| -- | -- | -- |
| point | Point | The point to check against the polygon |
| polygon | Polygon | The Polygon to check |

### Line

The Line class contains methods for getting data about lines

#### distanceFromLine

This method will calculate the distance from a Point to a Line. Note this does not calculate distance to a line segment, the Points given in the Line are used to calculate a line of infinite length.

| param | type | description |
| -- | -- | -- |
| line | Line | The line to use for distance |
| point | Point | The point to use for distance |

#### doLinesIntersect

This method returns a boolean if the two Lines provided intersect. This is done on line segments, not infinite lines.

| param | type | description |
| -- | -- | -- |
| line1 | Line | The line to compare |
| line2 | Line | The second line to compare |

### usePersistedState

This behaves like `useState` in React, but persists the value to localStorage. On load, it attempts to load any value from localStorage. This allows a simple persisting of various state across reloads.

## Types

### Point

A point is a simple object that contains a numeric x and a numeric y.

### Polygon

The Polygon type is simply an array of Points.

### Line

A line is simply an array containing two Points, representing the start and end of a line segment.

---
_Source: https://npm.io/package/@bucky24/toolbox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
