Catalog npm
PACKAGE EXPLORERView in registry

2048-danyo

npm

2048 game utility

2048
Versions collected2
Direct dependencies0From release 1.0.1
Last observed20 Oct, 18:55 UTC

README

Current package documentation

2048 Game Utility

A lightweight and extensible Node.js utility for managing the core logic of the classic 2048 game. This utility includes board initialization, tile spawning, movement logic, and game-over detection - ideal for building 2048 game UIs, simulations, or reinforcement learning environments.

Installation

You can install this package using npm:

npm install 2048-danyo

Usage

Importing the Module

const Twenty48 = require('2048-danyo');

Creating a Game Instance

const game = new Twenty48();
console.log(game.board); // Prints the initial board

Spawning a tile

Spawns a tile on a random empty square

game.spawnTile(game.board, true);
console.log(game.board); // Prints the board after spawning a tile

Copying a board

Returns a deep copy of the provided board

const boardCopy = game.copyBoard(game.board);
console.log(boardCopy); // Prints the copied board

Rotating a board

Rotates a board 90 degrees counter clockwise

const rotatedBoard = game.rot90(game.board);
console.log(rotatedBoard); // Prints the rotated board

Making a move

Performs a move in the specified direction, where:

  • L is left
  • R is right
  • U is up
  • D is down
game.makeMove(game.board, 'L');
console.log(game.board) // Prints the board after moving tiles left

Checking for an empty square

One of the conditions for the game to still be playable is for it to have at least one empty square.

const hasEmptySquare = game.hasEmptySquare(game.board);
console.log(hasEmptySquare); // true or false

Checking for tiles that can be merged

One of the conditions for the game to still be playable is for it to have at least one pair of tiles that can be merged.

const hasMergableTiles = game.hasMergableTiles(game.board);
console.log(hasMergableTiles); // true or false

Checking game over status

Checks for any remaining legal moves

const isGameOver = game.gameOver(game.board);
console.log(isGameOver); // true or false

String representation of the game board

Returns a string representation of the current board. Empty cells are shown as ..

const str = game.toString();
console.log(str);

Example Output

2..2
....
....
....

License

This project is licensed under the MIT License.

Downloads & popularity

0downloads
1-day window · source-reported counts19 Oct 2026
3718.50
2026-07-22: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-22–2026-07-222026-07-23: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-23–2026-07-232026-07-24: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-24–2026-07-242026-07-25: 5 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-25–2026-07-252026-07-26: 4 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-26–2026-07-262026-07-27: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-27–2026-07-272026-07-28: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-28–2026-07-282026-07-29: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-29–2026-07-292026-07-30: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-30–2026-07-302026-07-31: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-07-31–2026-07-312026-08-01: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-01–2026-08-012026-08-02: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-02–2026-08-022026-08-03: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-03–2026-08-032026-08-04: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-04–2026-08-042026-08-05: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-05–2026-08-052026-08-06: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-06–2026-08-062026-08-07: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-07–2026-08-072026-08-08: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-08–2026-08-082026-08-09: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-09–2026-08-092026-08-10: 6 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-10–2026-08-102026-08-11: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-11–2026-08-112026-08-12: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-12–2026-08-122026-08-13: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-13–2026-08-132026-08-14: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-14–2026-08-142026-08-15: 17 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-15–2026-08-152026-08-16: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-16–2026-08-162026-08-17: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-17–2026-08-172026-08-18: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-18–2026-08-182026-08-19: 4 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-19–2026-08-192026-08-20: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-20–2026-08-202026-08-21: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-21–2026-08-212026-08-22: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-22–2026-08-222026-08-23: 3 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-23–2026-08-232026-08-24: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-24–2026-08-242026-08-25: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-25–2026-08-252026-08-26: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-26–2026-08-262026-08-27: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-27–2026-08-272026-08-28: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-28–2026-08-282026-08-29: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-29–2026-08-292026-08-30: 6 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-30–2026-08-302026-08-31: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-08-31–2026-08-312026-09-01: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-01–2026-09-012026-09-02: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-02–2026-09-022026-09-03: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-03–2026-09-032026-09-04: 10 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-04–2026-09-042026-09-05: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-05–2026-09-052026-09-06: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-06–2026-09-062026-09-07: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-07–2026-09-072026-09-08: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-08–2026-09-082026-09-09: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-09–2026-09-092026-09-10: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-10–2026-09-102026-09-11: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-11–2026-09-112026-09-12: 4 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-12–2026-09-122026-09-13: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-13–2026-09-132026-09-14: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-14–2026-09-142026-09-15: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-15–2026-09-152026-09-16: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-16–2026-09-162026-09-17: 37 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-17–2026-09-172026-09-18: 3 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-18–2026-09-182026-09-19: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-19–2026-09-192026-09-20: 4 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-20–2026-09-202026-09-21: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-21–2026-09-212026-09-22: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-22–2026-09-222026-09-23: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-23–2026-09-232026-09-24: 5 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-24–2026-09-242026-09-25: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-25–2026-09-252026-09-26: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-26–2026-09-262026-09-27: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-27–2026-09-272026-09-28: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-28–2026-09-282026-09-29: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-29–2026-09-292026-09-30: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-09-30–2026-09-302026-10-01: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-01–2026-10-012026-10-02: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-02–2026-10-022026-10-03: 3 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-03–2026-10-032026-10-04: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-04–2026-10-042026-10-05: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-05–2026-10-052026-10-06: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-06–2026-10-062026-10-07: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-07–2026-10-072026-10-08: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-08–2026-10-082026-10-09: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-09–2026-10-092026-10-10: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-10–2026-10-102026-10-11: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-11–2026-10-112026-10-12: 3 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-12–2026-10-122026-10-13: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-13–2026-10-132026-10-14: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-14–2026-10-142026-10-15: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-15–2026-10-152026-10-16: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-16–2026-10-162026-10-17: 1 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-17–2026-10-172026-10-18: 2 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-18–2026-10-182026-10-19: 0 · observed 2026-10-20T23:26:43.4875180Z · period 2026-10-19–2026-10-19
22 Jul19 Oct

npm · 90 observations shown. Missing days are unknown.

View observed values
Date / source periodValueObserved at
2026-10-19 – 2026-10-1902026-10-20T23:26:43.4875180Z
2026-10-18 – 2026-10-1822026-10-20T23:26:43.4875180Z
2026-10-17 – 2026-10-1712026-10-20T23:26:43.4875180Z
2026-10-16 – 2026-10-1612026-10-20T23:26:43.4875180Z
2026-10-15 – 2026-10-1502026-10-20T23:26:43.4875180Z
2026-10-14 – 2026-10-1402026-10-20T23:26:43.4875180Z
2026-10-13 – 2026-10-1302026-10-20T23:26:43.4875180Z
2026-10-12 – 2026-10-1232026-10-20T23:26:43.4875180Z
2026-10-11 – 2026-10-1102026-10-20T23:26:43.4875180Z
2026-10-10 – 2026-10-1002026-10-20T23:26:43.4875180Z
2026-10-09 – 2026-10-0902026-10-20T23:26:43.4875180Z
2026-10-08 – 2026-10-0802026-10-20T23:26:43.4875180Z
2026-10-07 – 2026-10-0712026-10-20T23:26:43.4875180Z
2026-10-06 – 2026-10-0602026-10-20T23:26:43.4875180Z
2026-10-05 – 2026-10-0512026-10-20T23:26:43.4875180Z
2026-10-04 – 2026-10-0412026-10-20T23:26:43.4875180Z
2026-10-03 – 2026-10-0332026-10-20T23:26:43.4875180Z
2026-10-02 – 2026-10-0212026-10-20T23:26:43.4875180Z
2026-10-01 – 2026-10-0102026-10-20T23:26:43.4875180Z
2026-09-30 – 2026-09-3002026-10-20T23:26:43.4875180Z
2026-09-29 – 2026-09-2902026-10-20T23:26:43.4875180Z
2026-09-28 – 2026-09-2802026-10-20T23:26:43.4875180Z
2026-09-27 – 2026-09-2702026-10-20T23:26:43.4875180Z
2026-09-26 – 2026-09-2612026-10-20T23:26:43.4875180Z
2026-09-25 – 2026-09-2512026-10-20T23:26:43.4875180Z
2026-09-24 – 2026-09-2452026-10-20T23:26:43.4875180Z
2026-09-23 – 2026-09-2312026-10-20T23:26:43.4875180Z
2026-09-22 – 2026-09-2202026-10-20T23:26:43.4875180Z
2026-09-21 – 2026-09-2112026-10-20T23:26:43.4875180Z
2026-09-20 – 2026-09-2042026-10-20T23:26:43.4875180Z
2026-09-19 – 2026-09-1902026-10-20T23:26:43.4875180Z
2026-09-18 – 2026-09-1832026-10-20T23:26:43.4875180Z
2026-09-17 – 2026-09-17372026-10-20T23:26:43.4875180Z
2026-09-16 – 2026-09-1602026-10-20T23:26:43.4875180Z
2026-09-15 – 2026-09-1502026-10-20T23:26:43.4875180Z
2026-09-14 – 2026-09-1422026-10-20T23:26:43.4875180Z
2026-09-13 – 2026-09-1302026-10-20T23:26:43.4875180Z
2026-09-12 – 2026-09-1242026-10-20T23:26:43.4875180Z
2026-09-11 – 2026-09-1102026-10-20T23:26:43.4875180Z
2026-09-10 – 2026-09-1002026-10-20T23:26:43.4875180Z
2026-09-09 – 2026-09-0912026-10-20T23:26:43.4875180Z
2026-09-08 – 2026-09-0802026-10-20T23:26:43.4875180Z
2026-09-07 – 2026-09-0702026-10-20T23:26:43.4875180Z
2026-09-06 – 2026-09-0612026-10-20T23:26:43.4875180Z
2026-09-05 – 2026-09-0522026-10-20T23:26:43.4875180Z
2026-09-04 – 2026-09-04102026-10-20T23:26:43.4875180Z
2026-09-03 – 2026-09-0302026-10-20T23:26:43.4875180Z
2026-09-02 – 2026-09-0212026-10-20T23:26:43.4875180Z
2026-09-01 – 2026-09-0122026-10-20T23:26:43.4875180Z
2026-08-31 – 2026-08-3102026-10-20T23:26:43.4875180Z
2026-08-30 – 2026-08-3062026-10-20T23:26:43.4875180Z
2026-08-29 – 2026-08-2922026-10-20T23:26:43.4875180Z
2026-08-28 – 2026-08-2812026-10-20T23:26:43.4875180Z
2026-08-27 – 2026-08-2702026-10-20T23:26:43.4875180Z
2026-08-26 – 2026-08-2612026-10-20T23:26:43.4875180Z
2026-08-25 – 2026-08-2502026-10-20T23:26:43.4875180Z
2026-08-24 – 2026-08-2402026-10-20T23:26:43.4875180Z
2026-08-23 – 2026-08-2332026-10-20T23:26:43.4875180Z
2026-08-22 – 2026-08-2202026-10-20T23:26:43.4875180Z
2026-08-21 – 2026-08-2122026-10-20T23:26:43.4875180Z
2026-08-20 – 2026-08-2002026-10-20T23:26:43.4875180Z
2026-08-19 – 2026-08-1942026-10-20T23:26:43.4875180Z
2026-08-18 – 2026-08-1802026-10-20T23:26:43.4875180Z
2026-08-17 – 2026-08-1702026-10-20T23:26:43.4875180Z
2026-08-16 – 2026-08-1602026-10-20T23:26:43.4875180Z
2026-08-15 – 2026-08-15172026-10-20T23:26:43.4875180Z
2026-08-14 – 2026-08-1402026-10-20T23:26:43.4875180Z
2026-08-13 – 2026-08-1302026-10-20T23:26:43.4875180Z
2026-08-12 – 2026-08-1202026-10-20T23:26:43.4875180Z
2026-08-11 – 2026-08-1102026-10-20T23:26:43.4875180Z
2026-08-10 – 2026-08-1062026-10-20T23:26:43.4875180Z
2026-08-09 – 2026-08-0912026-10-20T23:26:43.4875180Z
2026-08-08 – 2026-08-0802026-10-20T23:26:43.4875180Z
2026-08-07 – 2026-08-0702026-10-20T23:26:43.4875180Z
2026-08-06 – 2026-08-0622026-10-20T23:26:43.4875180Z
2026-08-05 – 2026-08-0502026-10-20T23:26:43.4875180Z
2026-08-04 – 2026-08-0402026-10-20T23:26:43.4875180Z
2026-08-03 – 2026-08-0302026-10-20T23:26:43.4875180Z
2026-08-02 – 2026-08-0202026-10-20T23:26:43.4875180Z
2026-08-01 – 2026-08-0112026-10-20T23:26:43.4875180Z
2026-07-31 – 2026-07-3102026-10-20T23:26:43.4875180Z
2026-07-30 – 2026-07-3002026-10-20T23:26:43.4875180Z
2026-07-29 – 2026-07-2912026-10-20T23:26:43.4875180Z
2026-07-28 – 2026-07-2802026-10-20T23:26:43.4875180Z
2026-07-27 – 2026-07-2702026-10-20T23:26:43.4875180Z
2026-07-26 – 2026-07-2642026-10-20T23:26:43.4875180Z
2026-07-25 – 2026-07-2552026-10-20T23:26:43.4875180Z
2026-07-24 – 2026-07-2422026-10-20T23:26:43.4875180Z
2026-07-23 – 2026-07-2312026-10-20T23:26:43.4875180Z
2026-07-22 – 2026-07-2202026-10-20T23:26:43.4875180Z

Versions 2

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.1Registry latest20 Apr 20250
1.0.020 Apr 20250

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
dhong9/2048-danyo

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:55 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:bca090b3ddeceef55e0314a5d4b95d53b25a64339c40bcdee842c81daa532e53