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

@godbayd/ouro

v1.0.0

Published

Ouro is a library that assists in creating snake game applications.The Business logic is handled in a set of exposed methods that allows for users to bring in behaviors as needed without needing to get too mired in the details.

Readme

Ouro

Ouro is a library that assists in creating snake game applications.The Business logic is handled in a set of exposed methods that allows for users to bring in behaviors as needed without needing to get too mired in the details.

Examples

npm run example

npm run example-loop

Main

instance: new Ouro(xCount, yCount, speed)

  • params
    • xCount: number
      • defines the number of columns in the grid
    • yCount: number
      • defines the number of rows in the grid
    • speed: number(optional)
      • If game loop is being used, speed defines the number of miliseconds per frame. If not specified, the default speed is 100.

Exposed Properties

  • grid: Array<Array<number>>: Houses the game state that should be reflected in a game board.
  • crash: Boolean: Indicates whether or not the snake has reached a crash state.
  • appleCoords: [number, number]: x and y value that point to the coordinates of the apple cell
  • snakeCoords: [number, number]: Same as appleCoords but for snake head coordinates
  • bodyCoordsStore: Array<[number, number]>: Essentially a queue that houses the snakeCoords of the snake body cells
  • direction: string: Current direction that step() should use to update grid. Essentially the direction that the snake should move within the grid.
  • count: number: How many times the snake head cell collides with the apple cell. Essentially a score of how many times the snake successfully ate an apple.
  • cell: { head: number, body: number, apple: number, space: number }: A frozen object. Object that gives names to the number values used within grid to represent snakes head, body and apple cells

Exposed Methods

  • blankGrid():void: Method to initialize or replace existing grid property with a "blank slate", which is realized as a 2d array, where the amount of inner arrays is equal to yCount and the inner arrays are filled with xCount amount of 0's(representing cell space). Note that xCount and yCount are defined when creating a new instance of Ouro.

    Ie:

    const O = new Ouro(3, 2).blankGrid()

    would set O.grid to have the value:

    [
        [0,0,0],
        [0,0,0]
    ]
  • startingGridState():void: Convenience method that first initializes a grid, or replaces existing grid with a blank one(using the method: blankGrid()) and then updates the grid with a single starting snake value and a single starting apple value(using the internal method: _placeSnakeAndApple())

  • step():void: Probably the most crucial of the methods. step() takes in the current state of the grid and updates the snake and snake body, based on the current direction property(set by the method: setDirection()). This would normally be used within a game loop and aids in moving the snake - step by step - in an animation.

  • setDirection(direction: string):void: Sets the direction of the moving snake. Internally this methods takes care of the rules that disallow end users to move in directly opposing direction(ie: from left to right, right to left, up to down, and down to up) and also ignores repeated direction(from left to left, up to up, etc...). This would normally be used within an event handler(probably listening for arrow button presses) made to alter the direction of the snakes movements.

    direction param accepted values: "ArrowUp" | "ArrowDown" | "ArrowLeft" | "ArrowRight"

  • resetGameState():void: Resets the Ouro instance to it's prototypes state. Note: this is a pretty heavy handed method, if any properties are meant to be preserved, take propper care when using this method. Once this method is called, even the grid will have a null value and need.

  • gameLoop():void: Creates an interval and accepts a callback thats first and only parameter will have in it the state, current to each interval. Note that the interval is held within the main object internally, so the running state is in effect and accessible outside of the callback.

Todos

  • add an options to choose between interval and animation frame in gameLoop
  • change setDirection args to accept more generic values. ie: left, right etc... instead of ArrowLeft, ArrowRight...