another vanilla vec-2 library with recycling

Usage no npm install needed!

<script type="module">
  import vec2Recycle from '';



Another vanilla vector 2 library with recycling

Similar in scope (and based on) Differences:

  • uses a cache to recycle vectors to minimize garbage collection
  • uses a number[2] without any prototypes
  • is not watchable (unlike the above library--removed for speed purposes)

Simple Example

import * as vec2 from 'vec2-recycle'

const v1 = vec2.create(5, 4)
const v2 = vec2.create(8, 9)

// copies to a new vector
const v3 = vec2.add(v1, v2, true)

// v1 is replaced
vec2.subtract(v1, v2)


API Documentation


yarn add vec2-recycle


npm i vec2-recycle


  1. Clone repository
  2. yarn install
  3. yarn test (for jest test code)

Other Libraries

If you liked pixi-viewport, please try my other open source libraries:

  • pixi-scrollbox - pixi.js scrollbox: a masked box that can scroll vertically or horizontally with scrollbars (uses pixi-viewport)
  • pixi-ease - pixi.js animation library using easing functions
  • intersects - a simple collection of 2d collision/intersects functions. Supports points, circles, lines, axis-aligned boxes, and polygons


MIT License
(c) 2020 YOPEY YOPEY LLC by David Figatner