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

spase

v12.0.0

Published

Micro library for performing 2D spatial calculations of DOM elements

Readme

spase npm CI CD

Micro library for performing 2D spatial calculations of DOM elements.

Usage

import { hitTest, Point, Rect, Size } from 'spase';

API

Point

A type representing a point on a 2D plane.

Properties

| Property | Type | Description | |----------|------|-------------| | zero | Point | A Point with x and y values of 0. |

Methods

| Method | Params | Returns | Description | |--------|--------|---------|-------------| | make | descriptor: PointDescriptor | Point | Creates a new Point. | | make | x: numbery: number | Point | Creates a new Point. | | clone | point: PointnewDescriptor: Partial<PointJsonDescriptor> | Point | Clones and returns a new Point. | | add | a: Pointb: Point | Point | Returns the resulting Point by adding one to another. | | subtract | a: Pointb: Point | Point | Returns the resulting Point by subtracting one from another. | | multiply | a: Pointb: Point | Point | Returns the resulting Point by multiplying one by another. | | divide | a: Pointb: Point | Point | Returns the resulting Point by dividing one by another. | | reflect | point: Point | Point | Returns the resulting Point by reflecting x/y values. | | isEqual | a: Pointb: Point | boolean | Checks to see if a Point is equivalent to another. | | toString | point: Point | string | Returns the string representation of a Point | | toJSON | point: Point | PointJsonDescriptor | Returns the JSON representation of a Point. | | toArray | point: Point | PointArrayDescriptor | Returns the array representation of a Point. | | isValidDescriptor | value: any | boolean | Checks if a value is a valid Point descriptor. | | isPoint | value: any | boolean | Checks to see if a value is a Point. | | isZero | point: Point | boolean | Checks to see if a Point only contains 0 values. |

Size

A type that represents a size on a 2D plane.

Properties

| Property | Type | Description | |----------|------|-------------| | zero | Size | A Size with width and height values of 0. |

Methods

| Method | Params | Returns | Description | |--------|--------|---------|-------------| | make | descriptor: SizeDescriptor | Size | Creates a new Size. | | make | width: numberheight: number | Size | Creates a new Size. | | clone | size: SizenewDescriptor: Partial<SizeJsonDescriptor> | Size | Clones and returns a new Size. | | add | a: Sizeb: Size | Size | Returns the resulting Size by adding one to another. | | subtract | a: Sizeb: Size | Size | Returns the resulting Size by subtracting one from another. | | multiply | a: Sizeb: Size | Size | Returns the resulting Size by multiplying one by another. | | divide | a: Sizeb: Size | Size | Returns the resulting Size by dividing one by another. | | rotate | size: Size | Size | Returns the resulting Size after applying a 90˚ rotation, essentially swapping the width/height values. | | isEqual | a: Sizeb: Size | boolean | Checks to see if a Size is equivalent to another. | | toString | size: Size | string | Returns the string representation of a Size | | toJSON | size: Size | SizeJsonDescriptor | Returns the JSON representation of a Size. | | toArray | size: Size | SizeArrayDescriptor | Returns the array representation of a Size. | | isValidDescriptor | value: any | boolean | Checks if a value is a valid Size descriptor. | | isSize | value: any | boolean | Checks to see if a value is a Size. | | isZero | size: Size | boolean | Checks if a Size only contains 0 values. |

Rect

A type representing a rectangle on a 2D plane.

Properties

| Property | Type | Description | |----------|------|-------------| | zero | Rect | A Rect with top, right, bottom and left values of 0. |

Methods

| Method | Params | Returns | Description | |--------|--------|---------|-------------| | make | descriptor: Rect.Descriptor | Rect | Creates a new Rect. | | make | point: Pointsize: Size | Rect | Creates a new Rect. | | make | x: numbery: numberwidth: numberheight: number | Rect | Creates a new Rect. | | center | rect: Rect | Point | Gets the center point of a Rect. | | size | rect: Rect | Size | Gets the size of the current Rect. | | from | target: Rect \| Window \| Element \| Element[]options: Rect.Options | Rect | Gets the combined Rect of one or more spatial objects. | | fromViewport | | Rect | Computes and returns the Rect of the viewport (a.k.a. the window). | | fromChildrenOf | parent: Element \| Windowoptions: Rect.Options | Rect | Gets the Rect of all the children of an element. This automatically sets the reference to the parent element. | | fromChildrenBefore | childIndex: numberparent: Elementoptions: Rect.Options | Rect | Gets the Rect of the children of an element up to the specified index. This automatically sets the reference to the parent element. | | fromChildrenAfter | childIndex: numberparent: Elementoptions: Rect.Options | Rect | Gets the Rect of the children of an element after the specified index. This automatically sets the reference to the parent element. | | fromChildAt | childIndex: numberparent: Elementoptions: Rect.Options | Rect | Gets the Rect of a child of an element at its index. This automatically sets the reference to the parent element. | | intersecting | ...elements: Element[] | Rect | Computes the intersecting Rect of a rect against one or more elements. If only 1 element is specified, the intersection will be computed against the viewport. | | clone | rect: RectnewDescriptor: Partial<Rect.Descriptor> | Rect | Clones and returns a new Rect. | | concat | a: Rectb: Rect | Rect | Concatenates one Rect with another. | | rotate | rect: Rect | Rect | Returns a new Rect after applying a 90˚ rotation, essentially swapping the width/height values. | | isEqual | a: Rectb: Rect | boolean | Checks to see if the current Rect is equivalent to another Rect. | | contains | rect: Rectobj: Point \| PointDescriptor \| Rect \| Rect[] \| Element \| Element[] | boolean | Checks if a Rect contains any part of another spatial object, i.e. a Point, PointDescriptor, Rect(s), or Element(s). | | toString | rect: Rect | string | Returns the string representation of a Rect | | toJSON | rect: Rect | Rect.JSONDescriptor | Returns the JSON representation of a Rect. | | isValidDescriptor | value: any | boolean | Checks if an object can be used to create a new Rect. | | isRect | value: any | boolean | Checks to see if a value is a Rect. | | isZero | rect: Rect | boolean | Checks to see if a Rect only contains 0 values. |

Utilities

| Method | Params | Returns | Description | |--------|--------|---------|-------------| | hitTest | a: Point \| PointDescriptor \| Rect \| Rect[] \| Element \| Element[]b: Point \| Rect \| Rect[] \| Element \| Element[] | boolean | Hit-tests one spatial object against one or more spatial objects. In order for the test to pass, the object just needs to collide with at least one of the specified objects. |