Catalog npm
Back to packageRELEASE DETAILS

0.0.1-security

npm

2048-board-renderer

security holding package

2048boardgameguirenderer
Published13 Jul 2022
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

2048 board renderer

Build

Package for easily rendering boards from the game 2048. Uses data in the format provided from 2048-engine to render the board.

See 2048-react for a convenient wrapper for use in React.

API

The package exposes one method.

createBoard(boardData)

It takes one argument, boardData, which is a Board object from 2048-engine.

The function returns an object with the following properties:

  • htmlElement: A HTMLElement containing the rendered board.
  • update: A function that takes an updated boardData Board object and modifies htmlElement to match the new state.

Any updates to the board should be made using the update function for animations to be played. New games should create new boards using createBoard to avoid weird animations.

Usage

import { createBoard } from '2048-board-renderer';
import { createGame, Direction } from '2048-engine';

const game = createGame();

const board = createBoard(game.currentState.board);
document.getElementById('game')?.appendChild(board.htmlElement);

const move = (direction: Direction) => {
  const gameState = game.move(direction);
  board.update(gameState.board);
};

move(Direction.UP);

For a playable example see example directory

Notes on the board HTMLElement

The board HTMLElement is a div with no styling regarding width. The width of the board is therefore determined by its parent container.

The height of the board is determined based on width and the aspect ratio of the board.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-cfbVjivLgpkVAPpXRVdlX+W5sDDrEFwi0nkKD/Rg+3rXMUsS8398ZDtKXxzWYdM0NO9ysh8YRTxeDp/TIS9Uwg==",
  "shasum": "9965ab0c3c2fd364a5b14d3e3acbdadd95bb334f",
  "tarball": "https://registry.npmjs.org/2048-board-renderer/-/2048-board-renderer-0.0.1-security.tgz",
  "fileCount": 2,
  "unpackedSize": 350,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIEs3/FgxFPZkR8Ry9SCZACzOCOXdmd7LOqaiHfASJi4KAiBUytWG23axBk4RWSFAUt8rruoMF6JWhFEE4e9UH+k9aA=="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizxkqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpItA//VpTsp1RdMDYWJmnCen7htHQhTYP7l3U/OrtBcy1fg6a+HYYd\r\nR67VwBcHj/JaVI7jdgUVfb7rOc0gHlvs+rwcgoTQ+tgUhUeWakAsny1YUnV+\r\nfuABbvR3TVSa4RoXeYjP04axpLZRI+fglb2RYf/7xRGDCWa9ENd7cWXgkF7b\r\nW+W2UWvihAUqGNkFbJeB3MQjydYXf8d0oX05ZCCiBxa/XRBRmAM4xEUQ4cin\r\nwq4f9H1j1pHljUrYAk1yn6n62e3a1jdZv8zqnGjAiiJhzLhsvqsotrBgIBlN\r\nwi6o3/ScOFGY3df17uAKDeiFzAEukicYPP1rMJ1cITny5duvYfCxyTa2U4Fn\r\nkgUEXFu5/0Xz5J80oNKFEJvqsaXkmqKlHZtd5qTHsdczCaAV1yZgJ9HyZC/m\r\nY8jXNcHXOsBlmvUOaBTnqeCikT2lESa9zuEOXaQnY76pb6wQVboT45RZCogE\r\ncQcYY1E8LHOUQHGllEOkYFgzfzMLxSw3LrjoxF+k8mUKRfWHt6sXxYAMOJPf\r\n+jvzwo7cVIROcS3MX8OENWuWweKXSwcAaf6APdPYPajHvcghMrEGhigwrsfw\r\nUrnOkSpCB3QN/hw1Pw/hAjGNI1zRVymTRfibrkJE5rkxYefmFiKO0tZUzOr1\r\n3WTyYQogviGHC5Vt0eu+vFWoow34SJgfVcE=\r\n=2R4+\r\n-----END PGP SIGNATURE-----\r\n"
}

Repository

PENDING
npm/security-holder

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
eikhr/react-2048

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_version:a6e99877fd96b60c83e00a6ba64500ac588e4aa4a17033e6e6a51c2267dbfe32

Other collected versions

0.1.013 JulView all collected versions →